-
Notifications
You must be signed in to change notification settings - Fork 251
Fix TEGroupedLinear quantization for expert parallelism (EP > 1) #833
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: realAsma <[email protected]>
Signed-off-by: realAsma <[email protected]>
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
📝 WalkthroughWalkthroughThe changes refactor Mixture-of-Experts (MoE) calibration handling in PyTorch quantization across three modules. They add explicit MoE calibration validation and local expert amax synchronization in model_calib.py, remove the specialized _QuantMoELayer class from megatron.py, and improve argument parsing robustness in transformer_engine.py's grouped linear quantization path for varying input configurations. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #833 +/- ##
==========================================
- Coverage 73.82% 73.34% -0.49%
==========================================
Files 193 193
Lines 19745 19913 +168
==========================================
+ Hits 14577 14605 +28
- Misses 5168 5308 +140 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: James Shen <[email protected]>
0deb9b6 to
a85f04e
Compare
| weights_and_biases = args[-2 * num_gemms :] | ||
| weights, biases = weights_and_biases[:num_gemms], weights_and_biases[num_gemms:] | ||
| non_tensor_args = args[idx + 1] | ||
| num_gemms = len(non_tensor_args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| num_gemms = len(non_tensor_args) | |
| num_gemms = len(non_tensor_args[0]) |
What does this PR do?
Type of change: Bug fix
Overview:
Fix
te_grouped_quantized_linear_fnargument parsing for TEGroupedLinear quantization when parallelism configuration results in fewer local experts per GPU.Problem
When running MoE models with TEGroupedLinear quantization using high expert parallelism, the forward pass fails with:
AttributeError: 'tuple' object has no attribute 'numel'
Root Cause
The original code assumed
len(args) >= 2 * num_gemms + idx + 2. This assumption holds when there are many local experts per GPU, but fails when experts are highly distributed.Taking Qwen3-30B-A3B (with
num_gemms=21, threshold=44) as an example:len(args)pp=2, tp=4, ep=4tp=8, ep=8The bug triggers whenever
len(args) < threshold, regardless of which script is running:When
len(args) < threshold:args[-2*num_gemms:]wraps around and captures ALL elements instead of just the last onesargs[idx+1:-2*num_gemms]becomes empty, losing criticalnon_tensor_argsnon_tensor_argstuple gets incorrectly treated as a weight tensorUsage
With this fix, you can use any parallelism configuration:
Testing
Before your PR is "Ready for review"
Additional Information
Summary by CodeRabbit
Bug Fixes
Improvements
✏️ Tip: You can customize this high-level summary in your review settings.