Skip to content

[main] [4/5] Qwen3.5 support: Interleaved MRoPE layout#4755

Open
wplf wants to merge 2 commits into
NVIDIA:mainfrom
wplf:feat/mrope-interleaved-layout-main
Open

[main] [4/5] Qwen3.5 support: Interleaved MRoPE layout#4755
wplf wants to merge 2 commits into
NVIDIA:mainfrom
wplf:feat/mrope-interleaved-layout-main

Conversation

@wplf

@wplf wplf commented May 12, 2026

Copy link
Copy Markdown
Member

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.

  • New TransformerConfig.mrope_interleaved: bool = False.
  • New MultimodalRotaryEmbedding(interleaved_mrope=...) argument.
  • New helper _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).
  • GPTModel passes config.mrope_interleaved through to the embedding.

Why

MultimodalRotaryEmbedding currently produces the section-based T/H/W cycling used by Qwen2-VL. Qwen3.5-VL (and the matching HuggingFace Qwen3VLTextRotaryEmbedding.apply_interleaved_mrope) use a different layout where:

  • T freqs occupy stride-3 positions {0, 3, 6, ...}
  • H freqs occupy {1, 4, 7, ...}
  • W freqs occupy {2, 5, 8, ...}

Both layouts are now supported; the flag picks between them.

Risk

mrope_interleaved defaults to False, so existing Qwen2-VL / GPT users see no behavior change.

Notes

Mirror of #4750 (same patch, targeting main instead of dev).

🤖 Generated with Claude Code

@wplf wplf added the Run tests label May 12, 2026
@copy-pr-bot

copy-pr-bot Bot commented May 12, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

`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>
@wplf wplf force-pushed the feat/mrope-interleaved-layout-main branch from 8d3995f to 5414abf Compare May 13, 2026 10:24
…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>
@wplf wplf marked this pull request as ready for review June 4, 2026 11:07
@wplf wplf requested review from a team as code owners June 4, 2026 11:07
@wplf

wplf commented Jun 4, 2026

Copy link
Copy Markdown
Member Author

/ok to test 6e4e781

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants