Skip to content

feat(convert): add official Unsloth MXFP and NVFP4 maps for Qwen3.5/3.6 - #96

Merged
Brooooooklyn merged 1 commit into
mainfrom
agent/qwen35-unsloth-fp-recipes
Jul 12, 2026
Merged

Brooooooklyn merged 1 commit into
mainfrom
agent/qwen35-unsloth-fp-recipes

Conversation

@Brooooooklyn

@Brooooooklyn Brooooooklyn commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add the official Unsloth float-class maps for verified Qwen3.5/Qwen3.6 hybrid checkpoints
  • translate the Apple path from NVFP4/FP8 to MXFP4/MXFP8 while retaining NVFP4 for the DGX path
  • share the family/shape-gated selector across SafeTensors and GGUF conversion
  • preserve legacy Dynamic 2.0 behavior for plain affine and non-Qwen/ambiguous inputs
  • document both commands and report pre-conversion selection as pending backend family/shape verification

Recipe maps

  • --q-recipe unsloth --q-mxfp: early FFNs use MXFP4 4/32
  • --q-recipe unsloth --q-mode nvfp4: early FFNs use NVFP4 4/16
  • both: final eight FFNs, attention q/k/v/o, GDN qkv/z/out, and lm_head use MXFP8 8/32
  • both: embeddings, routers, GDN a/b, vision, MTP, norms, and recurrent parameters remain BF16
  • AWQ imatrix pre-scaling is unchanged

This follows the official Unsloth Qwen3.6 NVFP4 class map, substituting MXFP4/MXFP8 only for the Apple-oriented path.

Root cause

The previous --q-mxfp path mechanically upgraded legacy Dynamic 2.0 affine decisions, leaving several sensitive classes as 5/6/8-bit affine instead of applying the official float-class map. The existing DGX path similarly promoted only legacy 4-bit decisions to NVFP4. Both entry points also needed an explicit Qwen family-and-shape gate so Qwen-specific MXFP heads could not be emitted for incompatible model families.

Validation

  • cargo test -p mlx-core --lib convert::tests — 141 passed, 1 ignored
  • GGUF recipe tests — 8 passed
  • CLI conversion tests — 14 passed
  • cargo clippy -p mlx-core --lib -- -D warnings
  • cargo fmt --check
  • git diff --check

Local generated artifacts (not committed):

  • Qwen3.5 35B-A3B MoE MXFP: 192 MXFP4 + 179 MXFP8 tensors; load and one-token smoke passed
  • Qwen3.6 27B NVIDIA: 193 MXFP4 + 208 MXFP8 + 96 affine8 tensors; load and one-token smoke passed
  • Qwen3.6 27B DGX: 168 NVFP4 + 233 MXFP8 tensors; load and one-token smoke passed

Note

Medium Risk
Changes quantization outputs for Unsloth + --q-mxfp/nvfp4 on Qwen hybrids; gating limits blast radius, but wrong gate logic could mis-quantize or leave sensitive layers in unexpected formats.

Overview
Adds official Unsloth float-class quantization for verified Qwen3.5/Qwen3.6 hybrid checkpoints when using --q-recipe unsloth with either --q-mxfp (early FFNs → MXFP4, high classes → MXFP8) or --q-mode nvfp4 (early FFNs → NVFP4 4/16, same MXFP8/BF16 split). This replaces the prior path that only mechanically upgraded legacy Dynamic 2.0 affine decisions.

Gating: Activation requires matching config family, requested model type, and hybrid tensor shape (full attention + GDN keys). Non-Qwen, mismatched, or plain affine Unsloth inputs still use Dynamic 2.0 plus apply_mxfp_upgrade / apply_nvfp4_upgrade.

Scope: The new predicate covers layer-depth rules (final eight FFNs MXFP8), MoE/shared experts, lm_head MXFP8, and BF16 exclusions (embeddings, routers, GDN a/b, vision, MTP). The same selector is wired in SafeTensors (convert.rs) and GGUF (is_qwen35_hybrid_gguf).

CLI/docs: Help and convert logs describe the official maps as requested until the backend verifies family/shape; tests cover messaging and flag forwarding.

Reviewed by Cursor Bugbot for commit 5d75264. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai

coderabbitai Bot commented Jul 12, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e98cb8f6-fa11-491b-a923-85e1aab0324d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/qwen35-unsloth-fp-recipes

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Brooooooklyn
Brooooooklyn marked this pull request as ready for review July 12, 2026 12:05
@cursor

cursor Bot commented Jul 12, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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_7e5322ae-da02-4df7-a546-ac5ccd675756)

@Brooooooklyn
Brooooooklyn merged commit 5602f12 into main Jul 12, 2026
7 checks passed
@Brooooooklyn
Brooooooklyn deleted the agent/qwen35-unsloth-fp-recipes branch July 12, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant