Skip to content

fix(qwen3): apply configured RoPE scaling - #1398

Merged
inureyes merged 10 commits into
mainfrom
fix/issue-1388-qwen3-rope-scaling
Aug 24, 2026
Merged

inureyes merged 10 commits into
mainfrom
fix/issue-1388-qwen3-rope-scaling

Conversation

@inureyes

@inureyes inureyes commented Aug 24, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Resolve Qwen3 and Qwen3-MoE rope_scaling once per model and propagate linear position scales or Llama 3 frequency tables to every attention layer.
  • Keep linear scaling on the fused Q/K-normalization decode path, route frequency-table schemes through the graph path, and apply the same plan to dense batched decoding.
  • Preserve the plan through direct block construction, pipeline stages, and tensor-parallel rank-local models.
  • Make malformed or unsupported shared RoPE schemes observable through a checkpoint-keyed, once-per-model-and-scheme warning instead of a silent unscaled decode.
  • Retain the existing test boundary: large checkpoint qualification uses weights already present on local accelerator hardware, while hosted CI remains limited to ordinary and small-fixture coverage.

Validation

  • cargo fmt --all -- --check
  • cargo test -p mlxcel --profile test-fast --lib qwen3 -- --nocapture on integrated latest main (110 passed, 20 existing hardware/large-model tests ignored)
  • Focused fused/graph RoPE scale, malformed-scheme warning, batched, direct-loader, pipeline-parallel, and tensor-parallel tests
  • cargo clippy -p mlxcel --all-targets -- -D warnings
  • CUDA release build on NVIDIA GB10: MLX_CUDA_ARCHITECTURES=121 cargo build --release --features cuda --bin mlxcel
  • Existing local models/mlx/qwen3-4b-4bit: PR and latest main matched for 128 greedy tokens
  • Existing local models/mlx/qwen3-30b-a3b-4bit: PR and latest main matched for 128 greedy tokens
  • Injected linear factor 8 into a temporary hard-linked view of the local 4B checkpoint; a 3,009-token prompt matched mlx-lm 0.31.3 on the graph RoPE path (The quick. The quick brown fox.), while latest main diverged because it ignored the block
  • Temporary large-checkpoint Actions run cancelled and workflow removed; no 4B/30B download is part of the final CI change

Notes

The dense implementation follows upstream mlx-lm's scaling_config path. Qwen3-MoE intentionally applies the same config even though current mlx-lm still constructs a plain RoPE module there, matching the issue's documented compatibility decision.

The default fused decode path shares the graph path's scale and passes direct numerical parity tests. Cross-runtime generated text can diverge after a shared prefix through the issue's documented f16 reduction-order jitter, so the real-model oracle comparison also selected the graph path used by upstream.

Bilingual qualification details are recorded in TECHNICAL_REPORTS/1398-qwen3-rope-scaling-20260824.{en,ko}.md.

Closes #1388

Resolve the parsed rope_scaling block once and propagate linear scales or frequency tables through dense, MoE, batched, tensor-parallel, and pipeline construction paths. Frequency-table schemes bypass the fused launcher, while linear scaling remains fused and is checked against the graph implementation.

Add focused constructor, scaling, batched, warning-deduplication, distributed, and fused-kernel regression coverage.

Refs #1388
@inureyes inureyes added status:review Under review type:bug Bug fixes, error corrections, or issue resolutions priority:low Low priority area:models Model architectures, weights, loading, metadata area:inference Generation, sampling, decoding (incl. speculative, DRY) modeltype:text Text-only language model labels Aug 24, 2026
Record checkpoint labels in the direct, pipeline, tensor-parallel, and MiniCPM-o Qwen3 loaders so warning deduplication cannot silence a later model that declares the same unsupported RoPE scheme.

Preserve the diagnostic label through tensor-parallel argument cloning and cover dense and MoE label selection in focused tests.

Refs #1388
Add a branch-scoped Apple Silicon workflow that compares the issue-specified Qwen3 checkpoints against origin/main and validates an injected 2201-token linear-scaling config against pinned mlx-lm.

This workflow is temporary validation instrumentation and will be removed after its hosted run reaches a terminal result.

Refs #1388
@inureyes
inureyes merged commit 1213723 into main Aug 24, 2026
13 checks passed
@inureyes
inureyes deleted the fix/issue-1388-qwen3-rope-scaling branch August 24, 2026 15:02
@inureyes inureyes self-assigned this Aug 24, 2026
@inureyes inureyes added status:done Completed and removed status:review Under review labels Sep 6, 2026
be-free-snowboy pushed a commit to freestylejs/snowbrain-mlxcel that referenced this pull request Oct 27, 2026
* fix(qwen3): apply configured RoPE scaling

Resolve the parsed rope_scaling block once and propagate linear scales or frequency tables through dense, MoE, batched, tensor-parallel, and pipeline construction paths. Frequency-table schemes bypass the fused launcher, while linear scaling remains fused and is checked against the graph implementation.

Add focused constructor, scaling, batched, warning-deduplication, distributed, and fused-kernel regression coverage.

Refs lablup#1388

* fix(qwen3): key RoPE warnings by checkpoint

Record checkpoint labels in the direct, pipeline, tensor-parallel, and MiniCPM-o Qwen3 loaders so warning deduplication cannot silence a later model that declares the same unsupported RoPE scheme.

Preserve the diagnostic label through tensor-parallel argument cloning and cover dense and MoE label selection in focused tests.

Refs lablup#1388

* ci(qwen3): run one-off real-model validation

Add a branch-scoped Apple Silicon workflow that compares the issue-specified Qwen3 checkpoints against origin/main and validates an injected 2201-token linear-scaling config against pinned mlx-lm.

This workflow is temporary validation instrumentation and will be removed after its hosted run reaches a terminal result.

Refs lablup#1388

* fix(ci): parse Qwen3 generation output

* fix(ci): pin Qwen3 validation Python

* fix(ci): provision validation Python with uv

* fix(ci): allow full Qwen3 MoE validation

* chore(ci): remove one-off Qwen3 validation

* docs(qwen3): record RoPE scaling validation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:inference Generation, sampling, decoding (incl. speculative, DRY) area:models Model architectures, weights, loading, metadata modeltype:text Text-only language model priority:low Low priority status:done Completed type:bug Bug fixes, error corrections, or issue resolutions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(qwen3): rope_scaling is parsed and never applied on the Qwen3 and Qwen3-MoE RoPE paths

1 participant