Skip to content

Pipeline parallel: agree on overflow once when explicitly unscaling - #16417

Merged
danielhanchen merged 7 commits into
mainfrom
dh/pp-fused-scaler-agree
Nov 3, 2026
Merged

danielhanchen merged 7 commits into
mainfrom
dh/pp-fused-scaler-agree

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Explicit PipelineParallel.unscale_ performs stage overflow agreement twice when the scaler is already bound. Bind it before unscaling and let the existing wrapper perform the single agreement, preserving main's fused Adam/AdamW support.

The regression test covers 64 configurations across Adam/AdamW, fused and non-fused optimizers, implicit and explicit unscaling, finite steps and overflow on either or both ranks. It checks updates against an independent optimizer, scale growth/backoff, collective counts, pickling and hook cleanup. Base performs [2, 2, 2] reductions; head performs [1, 1, 1], with numerical and cleanup checks passing on both arms. The composed PP/FSDP2 fixture injects overflow before agreement and retains its original global-skip assertions.

Validation on e63094e40 against merge base ff3f063a3:

  • CPU differential: 1 FIXED, 3 UNCHANGED, zero head failures or skips. The real two-T4 CUDA/NCCL differential also confirms the fix.
  • Linux and Windows: 16 tests and 320 subtests passed on each.
  • Paired macOS: 15 passing head tests and 320 passing optimizer subtests, zero new failures. One Gemma3 tensor-parallel norm assertion fails with exactly the same values and failure details on base and head.
  • AMD-host CPU/gloo: base 16, head 19 and integration 19 passed, zero failures/skips. This does not claim multi-GPU AMD coverage.
  • Full selected switchboard:CURRENT and NO_REGRESSION, all six targets complete, all 42 comparison rows SAME (39 UI comparisons and three Core results). Remote L4 regression: 103 cases per arm, 66 passed, 13 XPASS, 24 skipped, zero failures or metric regressions. SFT losses and grad norms are bit-identical; inference checks pass.

Focused performance on an exclusive Kaggle T4x2 kernel, torch 2.11.0, ABBA x3 in fresh processes, disjoint rank CPUs, 200 warmup and 1000 measured calls/process:

Unscale helper Base Head
Median latency 646.0 us 409.9 us
Range across six process medians 635.0-661.4 us 399.6-444.2 us

The 236.0 us improvement exceeds the 44.6 us maximum arm spread. The paired bootstrap interval is 33.2%-36.5% lower helper latency; memory readings are unchanged. This measures the helper rather than total training throughput. The focused reproduction needs no model weights.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T07:23:51.784217Z e63094e Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen danielhanchen self-assigned this Nov 3, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: a0df9dc16f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@danielhanchen danielhanchen changed the title Pipeline parallel: agree on overflow for fused Adam / AdamW and only once per step Pipeline parallel: agree on overflow once when explicitly unscaling Nov 3, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: f1931d2da3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: e63094e404

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@danielhanchen
danielhanchen merged commit d0a16f9 into main Nov 3, 2026
@danielhanchen
danielhanchen deleted the dh/pp-fused-scaler-agree branch November 3, 2026 08:08
danielhanchen added a commit that referenced this pull request Nov 4, 2026
…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.
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