[main] [4/5] Qwen3.5 support: Interleaved MRoPE layout#4755
Open
wplf wants to merge 2 commits into
Open
Conversation
This was referenced May 12, 2026
`MultimodalRotaryEmbedding` already supports the original section-based
T/H/W cycling (Qwen2-VL style). Qwen3.5-VL and the HuggingFace
`Qwen3VLTextRotaryEmbedding.apply_interleaved_mrope` use a different
layout where H freqs occupy stride-3 positions {1,4,7,...} and W freqs
occupy {2,5,8,...}, with T at {0,3,6,...}.
Add a new `interleaved_mrope` flag on the embedding (default `False`,
preserves existing behavior) plus a `mrope_interleaved` config field on
`TransformerConfig`, and wire it through `GPTModel`.
Helper `_apply_interleaved_mrope` merges the per-channel outer-product
layout `(3, bs, seq_len, dim)` into the interleaved single-tensor
layout `(bs, seq_len, dim)`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: BestJuly <19769279+BestJuly@users.noreply.github.com>
8d3995f to
5414abf
Compare
…onfig entry Match the merged dev shadow PR NVIDIA#4750 exactly: - reflow torch.stack/torch.cat in MultimodalRotaryEmbedding.forward - add 'mrope_interleaved': False to test_hybrid_moe_model config dict Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Member
Author
|
/ok to test 6e4e781 |
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.
Qwen3.5 support series
This is part of a 5-PR series adding Qwen3.5-VL support, split for review clarity.
Main PRs (this series):
Dev PRs (corresponding mirrors):
Summary
Add the interleaved MRoPE layout used by Qwen3.5-VL, gated by a new config flag.
TransformerConfig.mrope_interleaved: bool = False.MultimodalRotaryEmbedding(interleaved_mrope=...)argument._apply_interleaved_mrope(freqs, mrope_section)that converts the per-channel outer-product layout(3, bs, seq_len, dim)into the interleaved single-tensor layout(bs, seq_len, dim).GPTModelpassesconfig.mrope_interleavedthrough to the embedding.Why
MultimodalRotaryEmbeddingcurrently produces the section-based T/H/W cycling used by Qwen2-VL. Qwen3.5-VL (and the matching HuggingFaceQwen3VLTextRotaryEmbedding.apply_interleaved_mrope) use a different layout where:{0, 3, 6, ...}{1, 4, 7, ...}{2, 5, 8, ...}Both layouts are now supported; the flag picks between them.
Risk
mrope_interleaveddefaults toFalse, so existing Qwen2-VL / GPT users see no behavior change.Notes
Mirror of #4750 (same patch, targeting
maininstead ofdev).🤖 Generated with Claude Code