Repository navigation
Conversation
…port Backport the checkpoint-oriented changes from InternLM#2285. Build frozen Dense MTP from the shared MTP config and shard it separately so the existing load, rollout publication, and HF export paths can retain the tensors. Dense training continues to use the backbone loss. Reject multiple independent Qwen3.5 MTP layers because HF uses shared projection and norm keys. Keep the legacy MoE MTPConfig import working. Source commit f2bb6979afbb2f26f543ebd32d9a544f5ce50260
Collaborator
Author
|
The Dense MTP patch is now Layer 10 of the same-repository Mini-Agent stack. Closing this fork PR in favor of #2390. |
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.
Summary
Build Dense MTP when the model is configured with
MTPConfig(num_layers=1, frozen=True). For a composed Qwen3.5 model, set it on the text config. Frozen MTP parameters participate in HF loading, FSDP sharding, rollout weight publication, and HF export. The Dense training step uses the backbone loss.Qwen3.5 uses one shared set of projection and norm keys in its HF MTP layout. A CPU reproduction of the source patch loaded two independent projection values as
[2, 2]after saving[1, 2]. The build now rejects more than one independent physical MTP layer. A single physical layer can still be shared across multiple logical depths.Thanks to @matrix72c and the contributors credited in #2285. This PR backports its Dense construction and frozen checkpoint support from
cccbab1677ee815f39641d25862ddac7fc0a926b. The wider work in #2285 covers trainable MTP and model onboarding, and #2369 covers Qwen3.8-27B onboarding and chat templates. This PR exposes an explicit opt-in on the existing Dense configs.Changed files
xtuner/v1/model/base.pymtp_configavailable to Dense throughTransformerConfig.xtuner/v1/model/dense/dense.pyxtuner/v1/model/dense/qwen3_5_text.pyxtuner/v1/model/moe/moe.pyMTPConfigimport available while inheriting the shared field.tests/model/test_frozen_dense_mtp.pyVerification
Ran with
CUDA_VISIBLE_DEVICES=''inpt29_glm2using Python 3.12.13, PyTorch 2.9.1, and Transformers 5.17.0.test_frozen_dense_mtp.pyandtest_mtp_local_future_embeddings.pypassed 69 tests and skipped 46 CUDA cases. This includes CPU shape and key checks against the 15 MTP tensors in the Qwen3.5-9B checkpoint. The skipped cases cover the CUDA HF round-trip, CUDA FSDP optimizer step and publication, CUDA future embeddings, and two-device NCCL sequence parallelism.upstream/mainatd0aead542cbf0c35c47092b40c40a4663e60224din GLM5.2 explicit DSA, GLM5.3 init/precision, and Qwen3 VL value-head tests. The additional skips cover the GLM MTP, checkpoint and sequence-parallel cases, and the MoE grad sync and ExpertTP cases.mtp_num_hidden_layers=1. The check supplied no-ops for PyTorch accelerator profiling and synchronization calls on CPU.ruff check,ruff format --check, andgit diff --checkpassed. The applicable pre-commit style hooks and mypy passed. The repository-widepydantic-extra-checkreached a CUDA-only RMSNorm import and failed the same way on the upstream baseline.f2bb6979afbb2f26f543ebd32d9a544f5ce50260reports 23 passing historical tests including CUDA HF I/O and an FSDP optimizer update. The verification above was CPU-only.