Repository navigation
fix(convert): keep recipe-pinned o_proj/out_proj/in_proj_a/b 8-bit affine under --q-mxfp - #89
Conversation
…fine under --q-mxfp The unsloth / qwen3_5 recipes pin four attention/GDN projections (self_attn.o_proj, linear_attn.out_proj, linear_attn.in_proj_a, linear_attn.in_proj_b) to 8-bit affine so AR (M=1) and MTP-verify (M>=2) both route through the M-invariant qmv kernel for T=0 MTP<->AR bit-exactness, and 8-bit affine keeps the worst-KLD out_proj near bf16. apply_mxfp_upgrade previously upgraded any non-excluded 8-bit affine Custom decision to mxfp8, silently degrading these four keys under --q-recipe unsloth --q-mxfp --q-bits 4 (mxfp8's E8M0 scales have ~10x the round-trip error of affine 8-bit). Add is_bitexact_affine_proj and guard the upgrade so the recipe's decision (and any Skip for MTP-layer keys) is preserved. The nvfp4 path is unaffected (no 8-bit arm). Co-Authored-By: Claude Opus 4.8 <[email protected]>
…under --q-mxfp; fix stale bf16 table Co-Authored-By: Claude Opus 4.8 <[email protected]>
…cisions
apply_mxfp_upgrade wraps every recipe, not just qwen3_5/unsloth. The
is_bitexact_affine_proj guard returned the original decision for
o_proj/out_proj/in_proj_a/in_proj_b unconditionally, so generic mixed_*
recipes (which assign these keys low-bit decisions, e.g. mixed_4_6 ->
4-bit affine o_proj) no longer upgraded them to mxfp4 under --q-mxfp.
Gate the guard on the pinned Custom{bits:8, mode:"affine"} decision so
mixed_* low-bit decisions still promote; Skip falls through to the main
match. Adds a regression test.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_72184bc5-6b92-4c48-9596-7336bee776f1) |
…#93) ## What CI's rolling `stable` toolchain bumped to **rustc/clippy 1.97.0 (2026-07-07)**, which added the **"redundant reference in `format!` argument"** lint. That trips the existing `cargo clippy --all-targets -- -D warnings` gate on a pre-existing line in `crates/mlx-core/src/tools/mod.rs`: ```rust error: Some(format!("Tool call missing name: {}", &raw_content)), // &raw_content is now flagged ``` This is what turned the **Rust Lint → Clippy** job red on `main` (first failure on #89, then the #90 merge — run `29022183758`). The code itself dates back to #64; nothing on #90 touched it — a toolchain bump surfaced it. ## Fix Inline the captured identifier: ```rust error: Some(format!("Tool call missing name: {raw_content}")), ``` `raw_content` is still moved into the struct field on the next line, so behavior is unchanged. ## Verification Reproduced the CI toolchain locally (`rustup update stable` → clippy `0.1.97 (2d8144b788 2026-07-07)`) and ran the exact gate: ``` cargo clippy -p mlx-core --all-targets -- -D warnings Finished `dev` profile in 2m 34s # exit 0, no redundant-reference error ``` Only remaining output is the pre-existing `block v0.1.6` future-incompat note (present on all green runs; not a `-D warnings` failure). 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > One-line formatting change in an error message path; no logic or API changes. > > **Overview** > Unblocks **Rust Lint → Clippy** on CI after **clippy 0.1.97** started enforcing the redundant-reference-in-`format!` lint under `-D warnings`. > > In `ToolCallResult::missing_name`, the error string now uses inline capture (`{raw_content}`) instead of `{}", &raw_content`. The message and move semantics are unchanged. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 44cc4cd. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Problem
apply_mxfp_upgradeupgraded the four recipe-pinned attention/GDN projections —self_attn.o_proj,linear_attn.out_proj,linear_attn.in_proj_a,linear_attn.in_proj_b— from 8-bit affine to mxfp8 under--q-recipe … --q-mxfp.The
unsloth/qwen3_5recipes deliberately pin these to 8-bit affine so AR (M=1) and MTP-verify (M≥2) both route through the M-invariantqmvkernel (T=0 MTP↔AR bit-exactness), and 8-bit affine specifically keeps the worst-KLDout_proj(~6.0) near bf16. mxfp8's coarse E8M0 scales have ~10× the round-trip error of affine 8-bit, so the upgrade regressed exactly those tensors. The recipe author guarded against the nvfp4 path but not mxfp, and the CLI help already claimed "o_proj/out_proj at 8-bit affine" — contradicting the code.Fix
is_bitexact_affine_projguard inapply_mxfp_upgrade, gated on the pinnedCustom{bits:8, mode:"affine"}decision, so those keys keep 8-bit affine — symmetric withapply_nvfp4_upgrade, mirroring the existing router-gate / affine-only exclusions. Scoped toapply_mxfp_upgrade; the uniform/no-recipe path is unchanged.mixed_*recipes — which give these keys low bits (e.g.mixed_4_6→ 4-bit affineo_proj) — still upgrade to mxfp4.Skip(MTP layers) is preserved via the main match.quantMxfpdoc across all 6 copies (2 Rust structs + 4.d.ctsblocks), fixed the stalebf16row incli/README.md, reworded the--q-mxfphelp + qualified the run banner, addedfeed_forward.gateto the router-gate list, and corrected stale router-gate comments inconvert.rs/persistence.rs/sparse_moe.rsagainst a verified control-flow trace (decision → emission → load-time resolution).Tests
apply_mxfp_upgrade_preserves_bitexact_affine_projections(pinned → stays affine; MTPSkippreserved) andapply_mxfp_upgrade_promotes_non_pinned_low_bit_projections(mixed_* low-bit → mxfp4).yarn typecheck,cargo clippy -D warnings,cargo fmt --checkall clean.Follow-ups (non-blocking, out of scope of this gap)
--q-modedoc drift:README.md:133/docs/cli.md:83say "affine or mxfp8"; the CLI acceptsaffine/mxfp4/mxfp8/nvfp4/sym8(GGUF: 4 modes) — note the GGUF-vs-SafeTensors mode-support nuance.compute_moe_defaults' mxfp8default_gate_plqbranch is unreachable for convert-produced checkpoints (now documented) — candidate loader cleanup.🤖 Generated with Claude Code
Note
Medium Risk
Changes quantization decisions for
--q-recipe unsloth|qwen3_5 --q-mxfpcheckpoints (affects model quality and MTP parity); logic is well-tested but convert output differs from before.Overview
Fixes
--q-mxfpincorrectly promotingunsloth/qwen3_5recipe pins —self_attn.o_proj,linear_attn.out_proj,in_proj_a,in_proj_b— from 8-bit affine to mxfp8, which hurt MTP↔AR bit-exactness and quality on high-KLD layers.apply_mxfp_upgradenow usesis_bitexact_affine_proj: only when the inner recipe already returnedCustom { bits: 8, mode: "affine" }those keys skip the mxfp8 upgrade;mixed_*low-bit decisions on the same keys still upgrade to mxfp4. MoE router gates are forced to 8-bit affine for non-Skipdecisions but preserve an explicitSkip(aligned with nvfp4).quantMxfpdocs, CLI--q-mxfphelp, README recipe table, and MoE gate comments are brought in line with this behavior; two unit tests cover pinned vs mixed-recipe paths.Reviewed by Cursor Bugbot for commit 395b8f0. Bugbot is set up for automated code reviews on this repo. Configure here.