Repository navigation
fix: apply YaRN rope scaling in the Qwen3.5 MTP drafter layer - #3491
Merged
Merged
Conversation
The Qwen 3.5 MTP drafter rotated with plain rope_theta even when its rope_parameters declared YaRN, so on YaRN checkpoints it drafted from a different position encoding than the target verifies with. Output stayed exact, but acceptance dropped. Qwen35MtpAttention now accepts an optional YaRN table and attention factor and rotates with fast_rope_with_freqs. The rotary-lane scaling is shared with Qwen3NextAttention through mlxcel_core::rope_lanes. The body of Qwen35Config::yarn is now the free function qwen35_yarn, and drafter_loader::load_drafter loads qwen3_5_mtp through core and then installs the table that function builds. The CLI, the server drafter slot and speculative_bench all get it, along with the --yarn-* knobs. A block that names yarn but cannot build a table fails the drafter load with the target's message. Configs without YaRN behave as before. Validated with fmt, clippy on mlxcel-core and mlxcel, and the focused drafter, qwen3_5, qwen3_next and rope_utils tests. A greedy MTP run on qwen3.8-27b produced identical output before and after. Closes #3479
inureyes
marked this pull request as ready for review
November 27, 2026 05:39
5 of 6 tasks
1 task done
inureyes
added a commit
that referenced
this pull request
Nov 28, 2026
## Summary
Adds the bilingual technical reports that were skipped when these three PRs merged on 2026-11-27:
- `TECHNICAL_REPORTS/3489-jiff-1x-strftime-now-20261127.{en,ko}.md` (#3489, jiff 1.0.3 and the `strftime_now` format and zone)
- `TECHNICAL_REPORTS/3490-vision-resize-frame-parity-20261127.{en,ko}.md` (#3490, resize and frame-sampling parity)
- `TECHNICAL_REPORTS/3491-qwen35-mtp-drafter-yarn-20261127.{en,ko}.md` (#3491, YaRN in the Qwen 3.5 MTP drafter)
Each report records the decisions the PR encodes (for example why ERNIE follows the checkpoint's `processing_ernie4_5_vl.py` rather than transformers or mlx-vlm, and why the drafter YaRN table is installed by the binary crate's loader) and what remains unverified.
## Test plan
Docs only. Remote CI was cancelled by maintainer decision.
- [x] Facts cross-checked against the merged diffs, PR bodies and the local validation output
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
The Qwen 3.5 MTP drafter rotated with plain
rope_thetaeven when itsrope_parametersdeclared YaRN, so on YaRN checkpoints it drafted from a different position encoding than the target verifies with. Output stayed exact (the target verifies every token), but acceptance dropped. The drafter now gets the same YaRN table and attention factor as the target.mlxcel-core:Qwen35MtpAttentiontakes an optional YaRN table and attention factor (set_yarn_rope). When one is set, it rotates withfast_rope_with_freqsand scales only the rotary lanes. The lane scaling moved intomlxcel_core::rope_lanes::scale_rotary_lanes, andQwen3NextAttentionnow calls that same function instead of keeping its own copy.Qwen35MtpDraftModelgainedset_yarn_rope,yarn_ropeandconfig, and the drafter text config now readsmax_position_embeddings.Qwen35Config::yarnis now the free functionqwen35_yarn(rope_parameters, rope_dims, rope_theta, max_position_embeddings), anddrafter_loader::load_drafterhandlesqwen3_5_mtpitself. It loads the drafter through core and installs the table from that function, so the CLI, the server drafter slot andspeculative_benchall pick it up, along with the--yarn-*knobs. A block that namesyarnbut cannot build a table fails the drafter load with the target's message. Configs without YaRN behave as before.Test plan
Remote CI was cancelled by maintainer decision. Validation was local only (M3 Ultra, Metal):
cargo fmt --all -- --checkcargo clippy -p mlxcel-core --lib --tests --features metal,accelerate -- -D warningscargo clippy -p mlxcel --lib --tests --features metal,accelerate -- -D warningscargo test -p mlxcel-core --lib --profile test-fast --features metal,accelerate drafter::qwen3_5_mtp rope_lanes: 26 passed, existingtests.rscases unchangedcargo test -p mlxcel --lib --profile test-fast --features metal,acceleratefiltered toqwen3_5,qwen3_next,rope_utilsanddrafter_loader: qwen3_5 62 passed (includes the 6 newqwen3_5_mtp_yarn_tests), qwen3_next 23, rope_utils 36, drafter_loader 3, all greenqwen3.8-27b-4bitwithqwen3.8-27b-mtp-4bit(a non-YaRN checkpoint), 64 tokens, before and after: identical text and identical acceptance (rounds=28, accepted=35/56, rate 0.625)There is no local YaRN Qwen 3.5 checkpoint, so the acceptance gain on YaRN checkpoints was not measured. The new tests cover it instead: the drafter's table equals the target's bit for bit on the SenseNova YaRN config, and the loader installs that table.
Closes #3479