Repository navigation
Use default fp32 tolerances in AutoTP training tests - #8796
Conversation
TestTiedRowParallelOutputHeadTraining compares row-parallel logits, which sum per-shard partial matmuls through an all-reduce, against an unsharded fp32 matmul with atol=1e-6. The tied head uses the embedding's N(0,1) weights, so logits reach about 14 and the two summation orders can differ by a few fp32 ulps. On Modal's L40S runners this gives 1.12e-6 at a near-zero logit, so every Modal merge-queue run that executes the test has failed since #8680 landed. Use torch.testing's default fp32 tolerance for this check, as TestLegacyLmHeadGatheredTraining already does. Real sharding bugs move logits by 0.1 to 10, so the check still catches them. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Hongwei Chen <hongweichen@microsoft.com>
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5858a4fc0a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Drop the custom atol/rtol from the remaining fp32 assert_close checks in test_autotp_training.py, including the row-parallel head logits check in TestRowParallelOutputHeadTraining. The defaults still catch the sharding bugs these tests target, and every changed check stays under 3% of the default limit on H200. The custom values only tie the tests to fp32 rounding, which varies by GPU. The half-precision tolerances in run_tp_layer_fwd_bwd are unchanged. Also drop the comment on the tied logits check, which now uses the same default as every other fp32 check in the file. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Hongwei Chen <hongweichen@microsoft.com>
|
Let's run AWS and modal test on this PR manually to ensure the new tolerence work on both platform. @hwchen2017 https://github.com/deepspeedai/DeepSpeed/actions/runs/38029376284 |
Problem
Since #8680 landed,
modal-torch-latest / DeepSpeedAI CIhas failed for every merge-queue entry that runs this test on Modal's L40S runners (#8794, #8701, #8670). Example: run 38009529440.#8680's own merge-queue run and the next nightly run both used the AWS fallback, where the test passes, so the failure wasn't caught there.
Root cause
The row-parallel head (
LinearAllreduceWithReplicatedInput) slices the hidden vector, computes a partial matmul on each rank, and all-reduces the partial logits. The reference is one unsharded fp32 matmul, and the two summation orders round differently. The tied head uses the embedding's N(0,1) weights, so logits reach about 14, where one fp32 ulp is about 1e-6. Logits that are near zero through cancellation can therefore differ by more thanatol=1e-6. Even the fp32 reference differs from a float64 ground truth by up to 2.2e-6.Fix
Use torch.testing's default fp32 tolerance (
atol=1e-5,rtol=1.3e-6) for every fp32assert_closeintest_autotp_training.py. That covers 17 checks, including both row-parallel logits checks, and matches the 19 fp32 checks in the file that already use the default. The half-precision tolerances inrun_tp_layer_fwd_bwdare unchanged.The default is enough for what these tests check:
Evidence (2x H200)
[35-3-False-0]and[35-3-True-0]fail with1 / 670mismatched and1.25e-06 (up to 1e-06 allowed).Testing
Hardware: 2x NVIDIA H200, torch 2.12.0+cu130, Python 3.12.
pytest tests/unit/v1/autotp/test_autotp_training.py -k "TestRowParallelOutputHeadTraining or TestTiedRowParallelOutputHeadTraining": 8 passed.pytest tests/unit/v1/autotp/test_autotp_training.py -m sequential -k "TestTiedEmbeddingAliasesAndFallback or TestTiedVocabParallelLMHead": 30 passed.pre-commit run --files tests/unit/v1/autotp/test_autotp_training.py: passed.No L40S is available locally. This PR's merge-queue run selects this test file, so it will check the fix on Modal's L40S runners unless the run falls back to AWS.