Repository navigation
[OMNIML-6061] Keep the expert-parallel GPU test's routing clear of near-ties - #3198
Conversation
On two RTX 6000 Ada GPUs, the backward test failed in layer 1 only, with the same numbers on transformers 5.9.0 and 5.18.0 and on main's own replicated path: one of 64 tokens took a different pair of experts in the sharded model than in the whole model. The tiny model's random router leaves near ties (a third-best score within 0.0002 of the second), and the GPU's bf16 rounding flips one. A token routed elsewhere sends its gradient to other weights, which no tolerance should absorb. The tiny model now routes each token by a code its embedding carries, so every token's top two scores clear the third by over 2 in both layers. Before the gradient comparisons, the backward and QAT tests check that the sharded and whole models route every token alike, and a flip fails as "routing differs" with its count. The 3e-2 bound is unchanged. Test only. Signed-off-by: Shengliang Xu <shengliangx@nvidia.com>
|
/ok to test 1425b0b |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3198 +/- ##
==========================================
+ Coverage 72.18% 80.41% +8.23%
==========================================
Files 677 677
Lines 78443 78443
==========================================
+ Hits 56621 63082 +6461
+ Misses 21822 15361 -6461
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
meenchen
left a comment
There was a problem hiding this comment.
Bot review (gpt-6.1-sol) — DM the bot to share feedback.
LGTM; the fixture change removes unstable routing without loosening assertions, and the justified test edit needs human sign-off.
Needs action:
- Sign off on the fixture adjustment in
tests/gpu/torch/utils/test_expert_parallel_load.py: real expert dispatch and router backpropagation remain exercised, with existing logits, calibration, and gradient bounds unchanged.
No action needed:
- Routing checks preserve global expert IDs, remove hooks in
finally, and gather mismatches before any rank starts backward. - Static review only; GPU runs and numerical probes were not reproduced. Guidance used: supplied
mainbaseline; its commit SHA was unavailable.
|
What does this PR do?
Type of change: Bug fix (test only)
tests/gpu/torch/utils/test_expert_parallel_load.pycompares a model loaded expert-parallel with the same model loaded whole: its logits, its gradients, and its quantized-training gradients. On two RTX 6000 Ada GPUs, the backward and QAT comparisons failed in layer 1 only, with gradients off by 3-16% (reported in #2742's review). The failure was the test's, not the load's:This PR changes the test only:
tgoes to expertt % 8and one more its id picks. Every token's top two scores now clear the third by over 2 in both layers, and the top expert's weight stays at 0.45-0.62, so gradients still flow through the router.routing differs: layer L sends N of M tokens to other experts than the whole model, not as the gradient errors it causes.Usage
N/A: a test-only change.
Testing
The router's margin, from a CPU probe of the tiny model on the test's batches:
The GPU test file on 2 RTX 6000 Ada GPUs, with torch 2.11.0 (CUDA 13.0, NCCL 2.28.9), on transformers 5.9.0 and 5.18.0 alike:
-k denserouting differs: layer 1 sends 1 of 32 tokens to other experts than the whole modelBefore your PR is "Ready for review"
Make sure you read and follow Contributor guidelines and your commits are signed (
git commit -s -S).Make sure you read and follow the Security Best Practices (e.g. avoiding hardcoded
trust_remote_code=True,torch.load(..., weights_only=False),pickle, etc.).CONTRIBUTING.md: N/AAdditional Information
A follow-up to #2742, whose review asked about the Ada failures. Part of expert-parallel PTQ for Hugging Face MoE models.
Summary by CodeRabbit