fix(update_weight): preserve grouped MoE expert axis during GLU rechunk#2193
Open
LLMShark wants to merge 1 commit into
Open
fix(update_weight): preserve grouped MoE expert axis during GLU rechunk#2193LLMShark wants to merge 1 commit into
LLMShark wants to merge 1 commit into
Conversation
619036c to
32090f9
Compare
32090f9 to
5aa699b
Compare
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.
Background
The GLU rechunking logic in
update_weight/common.pysplitslinear_fc1tensors alongdim=0after TP all-gather to restore the gate/up partition order.This is correct for:
linear_fc1.weighttensors.linear_fc1.biastensors.It is unsafe for grouped MoE tensors such as:
[num_experts, 2 * ffn, hidden].[num_experts, 2 * ffn].For grouped tensors,
dim=0is the expert axis. Applyingchunk(2, dim=0)would split the experts instead of the gate/up partitions and corrupt the gathered weights.Changes
Updated
slime/backends/megatron_utils/update_weight/common.py:_requires_glu_rechunk(name, tensor)predicate.linear_fc1.weighttensors.linear_fc1.biastensors.all_gather_param()and asynchronousall_gather_params_async()use the same predicate.This prevents the synchronous and asynchronous weight-update paths from diverging while preserving the existing dense and per-expert GLU behavior.
Tests
Added
tests/test_grouped_moe_glu_rechunk.py, covering:linear_fc1.weightstill requires GLU rechunking.linear_fc1.biasstill requires GLU rechunking.linear_fc1.weightdoes not get rechunked.linear_fc1.biasdoes not get rechunked.linear_fc2is unaffected by GLU rechunking.The test is included in the CPU CI matrix.
Validation
git diff --checkpassed.test_grouped_moe_glu_rechunk.py.