Conversation
`MoECheckpointIO._model_sharder` is a copy of
`HybridParallelCheckpointIO._model_sharder` without the
`to_unpadded_tensor` step, so `booster.save_model(..., shard=True)` with
`MoeHybridParallelPlugin` writes padded parameters. With tensor parallelism,
`VocabParallelEmbedding1D` pads the vocab to a multiple of
`make_vocab_size_divisible_by * tp_size`, so the saved embedding has the
padded vocab size and cannot be loaded by transformers:
size mismatch for weight: copying a param with shape torch.Size([1024, 8])
from checkpoint, the shape in current model is torch.Size([1000, 8]).
This affects any MoE model whose vocab is not a multiple of 64 * tp_size,
e.g. Qwen3 (151936). The existing test uses Mixtral's default vocab (32000),
which is never padded, and tp_size=1.
Unpad the parameters like HybridParallelCheckpointIO does, and run the MoE
checkpoint test with a padded vocab and tp_size=2 as well.
11 tasks
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.
📌 Checklist before creating the PR
[doc/gemini/tensor/...]: A concise descriptionpip install pre-commit && pre-commit install(ran the pinned hooks manually instead: black 24.10.0--line-length=120, isort 5.13.2--profile black, autoflake 2.3.1, all clean)🚨 Issue number
No existing issue; found while adding Qwen3-MoE support. Described below.
📝 What does this PR do?
booster.save_model(..., shard=True)withMoeHybridParallelPluginwrites padded parameters. With tensor parallelism,VocabParallelEmbedding1Dpads the vocab to a multiple ofmake_vocab_size_divisible_by * tp_size, so the saved embedding has the padded vocab size and transformers cannot load the checkpoint:Cause.
MoECheckpointIO._model_sharderis a copy ofHybridParallelCheckpointIO._model_sharderwithout theto_unpadded_tensorstep. (The unsharded path goes throughmodel.state_dict(), which already unpads.)This affects every MoE model whose vocab is not a multiple of
64 * tp_size, e.g. Qwen3 / Qwen3-MoE (151936). The existing test uses Mixtral's default vocab (32000), which is never padded, andtp_size=1.Fix. Unpad like
HybridParallelCheckpointIOdoes.Test.
tests/test_moe/test_moe_checkpoint.pynow uses a vocab of 1000 and runs with{pp 2, ep 2, tp 1}(as before) and{pp 2, ep 1, tp 2}.Results (4x H200, torch 2.5.1+cu124)
test_moe_checkpoint.pysize mismatch for weight: [1024, 8] vs [1000, 8]💥 Checklist before requesting a review
⭐️ Do you enjoy contributing to Colossal-AI?