Repository navigation
feat(quant): nvfp4 per-expert global_scale on QuantizedSwitchLinear, streaming, Inkling sanitize, X-ray, and converter (#677 Gap 2) - #739
Merged
Conversation
This was referenced Nov 23, 2026
goodmai
force-pushed
the
feat/677-gap1-config-traps
branch
from
November 24, 2026 09:44
735030d to
343d5dd
Compare
Owner
Author
|
Rebased on main 9403f42 (after #733 and #759) at the owner's request.
Note, not blocking: |
goodmai
force-pushed
the
feat/677-gap2-nvfp4-global-scale
branch
from
November 24, 2026 10:48
12a4db4 to
3bdce92
Compare
…streaming, Inkling sanitize, X-ray, and converter (#677 Gap 2)
goodmai
force-pushed
the
feat/677-gap2-nvfp4-global-scale
branch
from
November 24, 2026 10:50
3bdce92 to
77de6eb
Compare
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
Part of #677 (Gap 2, stacked on #733). Adds per-expert
nvfp4global_scale(F32 [E]) support across the fork, switch builders, expert streaming, Inkling 2 checkpoint sanitize, X-ray tensor inspection, and the universal converter — unblockingmlx-community/Inkling-2-Mini-oQ4e-mtp(#650), MiniMax-M3.1-Flash, and #677 Gap 3 (ModelOpt NVFP4).Fork (
goodmai/mlx-swift-lm, branchbasalt-677-nvfp4-global-scale@f1a251a)QuantizedSwitchLinear: added@ParameterInfo(key: "global_scale") public var globalScale: MLXArray?, per-expert NVFP4 quantization init, direct-arrays init, refusal for non-nvfp4modes, andglobalScale: self.globalScalepassed toMLX.gatherQuantizedMM.Load.swift: createsglobalScaleplaceholders onQuantizedSwitchLinear/QuantizedLinearwhen checkpoint weights carry.global_scale, and refuses non-nvfp4modes with a clear error.Basalt
mlx-swift-lmpin tof1a251a1869fe2d70518e4b5a31bef0fe7e3d828.FlintModel.quantizeModulesMatchingPackedWeights: supports.nvfp4/.mxfp8and attachesglobal_scaleplaceholders on switch/dense layers (split intopackedQuantSpec+quantizedReplacement, largest CCN 14).Inkling2Checkpoint.swift: mapsexperts.w13|w2.global_scale→experts.gate_up_proj|down_proj.global_scale.StreamedSwitchLinear&ExpertStreamingLoader: keeps per-expertglobalScales: [Float]?onExpertLayoutand refreshes a per-slot copyslotGlobalScaleson each slot load (and direct read path), passingglobalScaletoMLX.gatherQuantizedMM.MLXInferenceEngine+XRayTensors.swift: slices per-expertglobal_scalefor 3D switch weights and scales byg[e] / 2688.WeightConverter.swift,WeightConverter+SINQ.swift,UniversalSourceReader.swift: lifts.global_scalerefusal, tracks.global_scaleas a companion tensor, decodes 3D per-expert NVFP4 canonically (dequant * g[e] / 2688), and detectsnvfp4+global.Tests/BasaltTests/NVFP4GlobalScaleSwitchTests.swift([P2] tests: shared tiny-model fixtures (Gemma 4, MoE routers) and a kernel admission rule #228, [P3] moe: R&D out-of-core MoE with 16 KB expert slots, a GPU expert cache and double-buffered SSD streaming #225): parity vs dense reference + chunked decode (1, 3, 7), streamed vs resident (1, 4, 8 slots), Inkling sanitize, and bit-for-bit converter canonical decode.Verification
swift build -Xswiftc -warnings-as-errors— PASSswift test --parallel --filter "NVFP4GlobalScaleSwitchTests"— 3/3 PASSswift scripts/check_no_new_comments.swift— PASSswift scripts/check_size_limits.swift --impact— PASS (largest CCN 14 → 14)swift scripts/check_concurrency_hatches.swift— PASS