perf(magi): avoid TE padding for magi - #3757
Merged
Merged
Conversation
HuiyingLi
force-pushed
the
huiyingl/perf/magi-qwen3-packed-cp
branch
from
August 30, 2026 08:05
eff2347 to
69b1ab8
Compare
Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
HuiyingLi
force-pushed
the
huiyingl/perf/magi-qwen3-packed-cp
branch
from
August 30, 2026 08:09
69b1ab8 to
bf999ba
Compare
Contributor
Author
|
/ok to test bf999ba |
Contributor
Author
|
/claude review |
Contributor
|
LGTM |
HuiyingLi
marked this pull request as ready for review
August 30, 2026 08:36
akoumpa
approved these changes
Aug 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do ?
Avoid Transformer Engine-specific per-document CP padding when the attention backend owns context-parallel dispatch, including the custom Magi backend. Add a two-layer Qwen3-MoE exact-geometry recipe that exercises packed THD CP with the production attention, router, expert, and dispatcher dimensions.
TE block-diagonal THD CP requires each packed document to be aligned to
2 * cp_size. Magi builds and dispatches its own arbitrary-mask layout, so retaining that TE-only alignment wastes attention work and reduces the useful label tokens that fit in a pack.packing_cp_size=1changes only dataset packing alignment. Runtimedistributed.cp_sizeremains CP8 or CP16.Changelog
qwen3_moe_2layer_magi_packed_cp8_32k.yaml, preserving Qwen3-30B-A3B head, expert, router, vocabulary, DeepEP, TE-expert, activation-checkpointing, backward, and optimizer paths while reducing depth to two layers for a practical gate.Validation
ruff format --check nemo_automodel/recipes/llm/train_ft.py tests/unit_tests/recipes/test_train_ft.pyruff check nemo_automodel/recipes/llm/train_ft.py tests/unit_tests/recipes/test_train_ft.pypython tools/lint_example_yamls.py examples/llm_finetune/qwen/qwen3_moe_2layer_magi_packed_cp8_32k.yamlpython -m pytest tests/unit_tests/recipes/test_train_ft.py -q— 96 passed, 7 skippedW&B workspace: https://wandb.ai/Nemo-automodel/magi
Before your PR is "Ready for review"
Pre checks:
Additional Information
mainat3ddef9b1.