Skip to content

HF export staging is private to each island process; tests keep out of ~/yeto-output - #929

Open
michaellchung wants to merge 1 commit into
mainfrom
oc-z/hf-export-private-staging
Open

michaellchung wants to merge 1 commit into
mainfrom
oc-z/hf-export-private-staging

Conversation

@michaellchung

Copy link
Copy Markdown
Contributor

Summary

Product bug: the HF exports of the verl and Miles islands staged in one fixed directory
under the system temp dir, <tmp>/yeto-hf-export/round-<r>. Two island processes on one
host that export the same round at the same time shared it. One export's cleanup
(rmtree of a torn earlier attempt, and of the staging copy after the upload) ran
inside the other's write. The second export then failed, or an island's store received
the other island's weights.

This is how tests/test_verl_miles_parity.py::test_one_file_when_the_model_fits_and_the_round_lands_in_the_store
failed in a full run with four shards: another test process on the same host exported
round 6 into the same directory.

When it happens

  • Two islands of one run on one host (or one container's /tmp) whose export rounds
    coincide (--rl-export-hf-rounds, for example final).
  • Two test sessions on one host (the flaky test above).
  • One island alone is not affected: it exports its rounds one after another.

Fix

  • yeto.rl.engine.hf_export.private_staging(): each island process stages in a new
    tempfile.mkdtemp(prefix="yeto-hf-export-") directory. Only that process writes or
    removes anything in it. The export flow is unchanged: write, take the marker, upload,
    delete the staging copy, or keep it after a failed upload (staging_kept).
  • verl (adapters/verl/hf_export.hf_round_exports) and Miles
    (adapters/miles/entry.hf_exports_for) use it. Miles' one-node path, where every
    rank writes its share, gets the directory passed to the ranks as before.
  • verl Megatron (megatron_ports): every trainer rank must name the same directory,
    so the island driver (MegatronHfExports) picks one name per driver,
    yeto-verl-hf-export-<random>, and passes it to the ranks in the export config.
    Before this change the name was the same for every island on the host.

Impact

  • What lands in the store is unchanged: the same files, markers, final.json and tape
    fields. Only the local staging path changes, which shows in staging_kept after a
    failed upload.
  • The customer K3.1 path does not reach this code. Neither examples/k31 run config
    nor the customer kit enables --rl-export-hf-rounds, and the customer gate below is
    identical to main. With exports enabled, a single island writes the same store
    content as on main.
  • No CLI, config, plan or launch argv change.

Tests keep out of the real ~/yeto-output

The launcher's syncer command writes --dispense-log ~/yeto-output/task-dispense.jsonl.
Nine test files replace the checkpoint and tape paths of that command but not this one,
so every session appended to the developer's real ~/yeto-output/task-dispense.jsonl
(over 100 MB on one host). The island entry parse in test_prod_defaults_argv also
wrote ~/yeto-output/rl-island-<k>.jsonl. test_modal_two_islands_with_syncer_rebuild_tapes_and_fail_closed
reached the launcher's teardown, which copies the dispenser log of a syncer on this
machine. It read the developer's ~/yeto-output/task-dispense.jsonl and wrote
~/yeto-output/dispense-check.json.

  • Those helpers now also point --dispense-log at tmp_path.
  • The island entry parse in test_prod_defaults_argv writes its event tape under
    tmp_path.
  • The Modal two-island teardown test runs with its own HOME.
  • tests/yeto_home_guard.py, which already guards the real ~/.yeto, now also guards
    ~/yeto-output:
    • It refuses in-process writes under it.
    • It refuses a local child process (a shell, Python or the syncer) whose command line
      names the real ~/yeto-output: its absolute path, or ~/, $HOME/ or ${HOME}/
      while the child's HOME is the real one.
    • Either refusal fails the session, with the test named.
    • Not refused: another machine's path (node:~/yeto-output/..., an ssh or rsync
      argument) and a child given its own HOME.
    • Other changes from child processes are reported as warnings, as for ~/.yeto.

Verification

  • test_two_islands_on_one_host_export_the_same_round_at_the_same_time: both exports
    meet inside their first parameter export (a barrier), so they write the same round at
    the same time. On main it fails on every run: an island's store gets the other
    island's tensors, or an export fails. With this change it passes.

  • The flaky test: on main, with another process's export of the same round started
    between its cleanup and its write (local-only injection), it failed 20/20. With this
    change it stages under its own temp dir and passes.

  • Mutations (each applied alone):

    • verl staging back to the fixed directory
    • Miles staging back to the fixed directory
    • private_staging returning a fixed name
    • one Megatron staging name per host
    • Megatron ranks ignoring the driver's name
    • the guard without the child check
    • the guard without ~/yeto-output
    • the guard counting remote specs
    • the guard counting ssh/rsync arguments
    • the guard ignoring the child's HOME
    • a test syncer helper without the --dispense-log replacement

    All are caught.

  • With the guard on, 192 test files ran: every file that starts a launcher-built
    syncer, uses the dispenser evidence or an event tape, or names yeto-output. The
    guard found the teardown test above, now fixed; after the fix the real
    ~/yeto-output gets no write from them. 4131 passed. The one failure,
    test_rl_full_parameter_async::test_real_fixed_roster_quorum_timeout_keeps_the_pushes_and_the_attempt,
    is a known flaky test that does not touch this change; it has its own fix in the
    flaky-test batch. CI runs the guard over the full suite.

  • Customer gate: the 52 goldens pass, and the examples/k31 dry-runs (run up --dry-run
    of both run configs with their preflight logs, and the pool --dry-run) are identical
    line by line to origin/main after normalization.

The existing ~/yeto-output/task-dispense.jsonl on a developer host is left as it is.

🤖 Generated with Claude Code

…f ~/yeto-output

The verl and Miles island exports staged in one fixed directory under the system
temp dir (yeto-hf-export/round-<r>). Two island processes on one host exporting the
same round shared it: one export's cleanup ran inside the other's write, and an
island's store could get the other island's weights. Each process now stages in its
own mkdtemp directory; each Megatron island driver names its own staging directory
for its ranks.

Tests: the launcher-built syncer commands get a tmp_path --dispense-log, the island
entry parse writes its event tape under tmp_path, and the home guard also refuses
in-process writes to the real ~/yeto-output and local child processes whose command
line names it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant