Skip to content

fix(adapters): refuse LoRA on microscaled layers (mxfp4/mxfp8/nvfp4) naming the mode, until the fork fix is pinned (#746) - #760

Merged
goodmai merged 1 commit into
mainfrom
fix/746-microscaled-lora-refusal
Nov 24, 2026
Merged

goodmai merged 1 commit into
mainfrom
fix/746-microscaled-lora-refusal

Conversation

@goodmai

@goodmai goodmai commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Part of #746: the basalt-side refusal. The fork fix is ready, but its pin waits for #739.

Defect

The fork's QLoRALinear.callAsFunction calls super.callAsFunction(x.asType(scales.dtype)). On mxfp4, mxfp8 and nvfp4 the scales are uint8, so the base quantized matmul gets an integer input, not only the LoRA branch. An adapter on such a layer loads without error and gives garbage. QDoRALinear, PHMLinear and OFTLinear do not have the cast.

Fix in basalt

  • MLXInferenceEngine.microscaledLoRARefusal(_:path:) names the layer, its mode and its scale dtype, and cites [P2] adapters: LoRA on mxfp4/mxfp8/nvfp4 bases computes in uint8 (QLoRALinear casts to scales.dtype) #746.
  • It is checked wherever a LoRA layer is made:
    • PEFT and mlx-lm adapter directories, --adapter and adapter_apply, through checkShapes in attachContainer;
    • rank-1 adapter_apply;
    • PHM-applicator LoRA;
    • lab LoRA training, which skips such layers with a warning. DoRA is unaffected.
  • Affine-quantized layers still take LoRA as before.

Fork fix, not pinned here

goodmai/mlx-swift-lm branch basalt-746-qlora-microscaled, commit 5dd1b94, on top of the current pin e9feb1e. It keeps the input float when the scales are not.

Package.swift is not bumped in this PR. Another session's #733 and #739 hold the fork pin. Once they land, the pin moves to a commit that has this fix, the refusal comes out, and the parity test from #746 is added: mxfp4 .qwen35 against W + s·B·A on the dequantized weights.

Tests

MicroscaledLoRARefusalTests on tiny .qwen35, with the PEFT target layers quantized:

  • mxfp4: a PEFT adapter and a rank-1 adapter_apply are both refused naming mxfp4 and #746, and no LoRA layer is left behind.
  • affine 4-bit: the same adapter attaches to every target.

Adapter suites run locally: PEFT, PHM, LabGate, LabTrain, AdapterApply and the new suite. 29 tests, all pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_012cicguZMN3jhNGmf5327oh

…) naming the mode, until the fork's QLoRALinear stops casting its input to uint8 scales (#746)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012cicguZMN3jhNGmf5327oh
@goodmai
goodmai merged commit 20ea1cf into main Nov 24, 2026
8 checks passed
goodmai added a commit that referenced this pull request Nov 24, 2026
…in the fork's QLoRALinear fix (063d9e1), drop the #760 refusal, and test parity against W + s·B·A on the dequantized weights (#746) (#763)

Claude-Session: https://claude.ai/code/session_012cicguZMN3jhNGmf5327oh

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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