Repository navigation
Pipeline parallel: end a non-last stage without a graph break under torch.compile - #16167
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…shards (#16634) ## Summary `Repo tests (CPU, gloo-tp-pp)` is at its 2100 s cap. On #16618, which only touches the Studio MLX worker, it was interrupted with the suite almost done: ``` !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! KeyboardInterrupt !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 174 passed, 7 skipped, 79 warnings, 320 subtests passed in 2088.59s (0:34:48) ##[error]Process completed with exit code 124. ``` The other recent runs of that job, across the last 20 PRs, took 30.5 to 36.2 minutes end to end, setup included, so a slightly slower runner is enough to tip it over. When this shard was created (#15951 split, #16447 comment) tensor plus pipeline parallel were about 1397 s. Pipeline parallel has grown a lot since then: every `torch.distributed.pipelining` schedule (#15655), per-stage sharded loading (#15656), no graph break on a non-last stage (#16167), and explicit-unscale overflow agreement (#16417). Nothing is wrong with those tests. The shard just outgrew its slot, the same way `gloo` did in #15951 and #16447. ## Change - `.github/workflows/studio-backend-ci.yml`: `gloo-tp-pp` becomes two shards with the same settings (`-n 4`, the 2100 s cap, the marker filter): - `gloo-tp`: `tests/test_tp_n*gloo*.py` (2 files); - `gloo-pp`: `tests/test_pp*gloo*.py` (8 files). - `tests/studio/test_backend_ci_parallel_isolation.py`: `test_the_command_scan_sees_the_parallel_run_and_the_serial_steps` pins the number of parallel pytest runs. It asks to be told when a shard is added, so its counts go from 12 to 13 parallel runs and from 9 to 10 repo-root shards. The selections are the old one split in two, so every file still runs exactly once. ## Testing - `tests/test_ci_repo_cpu_shards.py`: 15 passed. With `test_pp*gloo*` narrowed to `test_pp_[!n]*gloo*` as a sabotage, `test_no_file_is_dropped_or_run_twice` fails, so a dropped file is still caught. - `tests/studio/test_backend_ci_parallel_isolation.py`, `tests/test_ci_repo_cpu_shards.py` and the workflow and cache-budget guards under `tests/studio`: 164 passed. - The two new shards' run times on this PR's own CI are the real check. Both should finish well under the cap.
Problem
A non-last pipeline stage ends its forward by raising
_StageOutput(hidden)from the first decoder layer it does not own;_PPStageModule.forwardcatches it and sends the hidden states on._StageOutputdefined its own__init__(callingsuper().__init__()and storingself.hidden), and Dynamo cannot trace that constructor.Repro on main, 2 gloo ranks, a LoRA Llama split with
apply_pipeline_parallel, stage module compiled withbackend = "aot_eager", dynamic = True:fullgraph = True: stage 0 fails on its first forward withDynamo does not know how to trace method __init__ of class _StageOutput.fullgraph = False: training runs and matches eager (loss error 2.4e-7), but stage 0 captures 5 graphs with 6 graph breaks (5 on_StageOutput.__init__, 1 onsuper().__init__()). The last stage is 1 graph, 0 breaks.Change
_StageOutputno longer defines__init__; the hidden states travel as the exception's first argument (raise _StageOutput(hidden)is unchanged, the handler readsstop.args[0]). Eager behaviour is identical: it is still aBaseException, so noexcept Exceptioninside a model forward swallows it.With the same 2-rank repro:
fullgraph = Truenow runs on both stages, and underfullgraph = Falsestage 0 is 1 graph with 0 graph breaks. Loss and gradient errors against the one-process model are unchanged (2.4e-7 loss, 2.7e-7 max grad on stage 0, 1.2e-7 on stage 1).Tests
tests/test_pp_native_gloo.py::test_non_last_stage_compiles_as_one_graph(a stage-0_PPStageModulewhose second layer is a pass-through, compiled withfullgraph = True; output and gradients must equal eager with 0 graph breaks): main 1 failed, this branch 1 passed.tests/test_pp_native_gloo.py,tests/test_pp_native_fp16_skip_gloo.py,tests/test_pp_fsdp2_gloo.py: 47 passed on this branch.Not covered
CPU only (gloo,
eager/aot_eagerbackends): no GPU, NCCL or Inductor run. Unsloth does not compile the stage module itself; this matters when the user compiles it.