Skip to content

fix(fusion): Preserve scaled NVFP4 projections - #705

Merged
davidkoski merged 1 commit into
ml-explore:mainfrom
achembarpu:fix/scaled-nvfp4-projection-fusion
Oct 16, 2026
Merged

davidkoski merged 1 commit into
ml-explore:mainfrom
achembarpu:fix/scaled-nvfp4-projection-fusion

Conversation

@achembarpu

Copy link
Copy Markdown
Contributor

Fusion preparation currently drops QuantizedLinear.globalScale from the fused projection and its checkpoint views. A scaled NVFP4 projection can therefore change output and lose its global_scale checkpoint key after preparation.

Reject projections with a global scale until the fused representation can preserve it. The original modules keep their output and checkpoint data. The regression covers a scaled first projection and a scaled later projection through the existing Qwen3.5 consumer; it fails on unchanged upstream and passes with only this guard.

Validation: the new regression and existing Qwen3.5 fusion tests passed with normal package/plugin validation. Formatting uses CI's swift-format 603.0.0 and pre-commit run --all-files.

AI usage: Codex assisted with source investigation, implementation, regression tests, and local validation.

  • I have read CONTRIBUTING.md.
  • I have read this description in full, approve it as my own, and confirm it accurately describes the changes.

Reject projections with global scales during fusion preparation. The current fused projection and checkpoint view constructors do not retain those scalars, so keep the original modules and parameters.

@davidkoski davidkoski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix looks good, thank you!

@davidkoski
davidkoski merged commit 1dc19ef into ml-explore:main Oct 16, 2026
4 checks passed
@achembarpu
achembarpu deleted the fix/scaled-nvfp4-projection-fusion branch October 16, 2026 16:50
wballard added a commit to swissarmyhammer/mlx-swift-lm-old that referenced this pull request Oct 23, 2026
Apply the upstream commits 6e338e5..d02948b as a 3-way patch. CLAUDE.md is
excluded.

- 1dc19ef fix(fusion): Preserve scaled NVFP4 projections (ml-explore#705)
- 11b2eda Add Mellum 2.1 support (ml-explore#697)
- 48114ee Read transformers 5 keys in LFM2-VL configs (ml-explore#695)
- bb0d5b0 fix loratrain for tiny prompts (ml-explore#683)
- d02948b Generate JSON properties in the schema's declared order (ml-explore#718)

No conflicts. Mellum makes only KV and sliding-window caches, so the
post-merge ArraysCache.advance checks do not apply.

Tests: MLXLMTests 874 XCTest and 1717 Swift Testing tests pass.
MLXGuidedGenerationTests 70, MLXFoundationModelsTests 374, CXGrammarTests 7,
MLXHuggingFaceMacrosTests 5 pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
spokvulcan added a commit to spokvulcan/mlx-swift-lm that referenced this pull request Oct 27, 2026
Upstream ml-explore#705 keeps a projection with an NVFP4 global scale out of the
fused projections, and tests it with QuantizedLinear(globalScale:). The
pinned spokvulcan/mlx-swift (0.31.6 base) has no global scale on
QuantizedLinear, so no projection can carry one: this reverts the guard
and its test. Fork-only; drops when the pin reaches mlx-swift 0.32.
ximyro pushed a commit to ximyro/mlx-swift-lm that referenced this pull request Nov 4, 2026
Brings in ml-explore#622 (exact prefix rewinds in rotating KV caches), ml-explore#619 (streaming
detokenizers), ml-explore#698, ml-explore#699, ml-explore#700, ml-explore#701, ml-explore#705, ml-explore#697 and ml-explore#695.

Conflicts: AttentionUtils.swift keeps TurboKV telemetry next to upstream's
SharedAttentionKVCache; KVCache.swift takes upstream's serialization and
rotating-cache view/trim while keeping the fork's TurboQuant state, public
cache fields and temporallyOrdered.

Follow-ups for upstream behavior the fork had changed: the Qwen2VL audio
placeholder no longer indexes content.count - 1 when a tool-call message has no
text part, and Gemma4MessageGenerator uses content parts for every non-system
role.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.

3 participants