fix(converter): lay out fused MLA a_proj for inference TP - #117
Merged
chaokunyang merged 1 commit intoAug 19, 2026
Merged
Conversation
…allelism SGLang consumes the fused MLA a_proj per tensor-parallel rank as [q_i ; kv_i], and AWEX chunks the writer-side tensor on dim 0. A plain cat([q_all, kv_all]) therefore hands rank i a slice straddling q and kv. Both layouts have the same shape, so the mismatch corrupts attention silently: generations stay structurally intact and keep emitting EOS while the content degrades to token soup, and the train/inference logprob divergence grows with every transfer. Restore the interleaved packing for the train attention-TP case and keep the plain concatenation when there is no train attention TP, where the parameter reaches every rank uncut and has to match SGLang's own load_weights layout.
Le8r0nJames
marked this pull request as ready for review
August 17, 2026 09:09
chaokunyang
approved these changes
Aug 19, 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?
Fixes silent weight corruption when converting the fused MLA
a_projfromMegatron-Core to SGLang with inference tensor parallelism.
SGLang consumes the fused MLA parameter on each inference TP rank as
[q_i; kv_i]. AWEX applies generic TP chunking along dimension 0, but theconverter previously produced the full tensor as
[q_all; kv_all]. Chunkingthat layout does not give each rank its corresponding Q and KV shards.
The incorrect and correct layouts have the same shape, so the transfer can
complete without an error while silently corrupting attention weights. This
causes post-update generations and train/inference log-probabilities to
degrade.
This PR:
[q_0; kv_0; q_1; kv_1; ...]beforeinference TP chunking;
[q; kv]concatenation when training attention TP isdisabled and the tensor is delivered uncut;
invalid inputs.
Validation:
ruff format --check awex/converter/mcore_converter.py awex/tests/test_fused_mla_a_proj_layout.pyruff check awex/converter/mcore_converter.py awex/tests/test_fused_mla_a_proj_layout.pypytest -v awex/tests/test_fused_mla_a_proj_layout.pyRelated issues
N/A
Does this PR introduce any user-facing change?