Skip to content

LoRA: add in F32 when the backend rejects the mixed F16 / F32 add (cherry-pick of leejet#2383) - #109

Merged
danielhanchen merged 1 commit into
masterfrom
r16-lora-metal-f32-add
Dec 1, 2026
Merged

danielhanchen merged 1 commit into
masterfrom
r16-lora-metal-f32-add

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Cherry-pick of leejet#2383 (20e2b79). Merging a LoRA into F16 weights with --lora-apply-mode immediately on Metal aborted, because Metal rejects the mixed F16 + F32 ADD. When the backend rejects that op, the merge now casts the weight to F32, adds the delta and copies the result back to F16. Backends that support the mixed add are unchanged.

Tested on macOS 15 (GitHub runner, Metal), SD 1.5 F16 GGUF + LCM LoRA, immediately mode

before after
Metal exit 134: "buffer (MTL0) that cannot run the operation (ADD)" renders, 834/834 LoRA tensors applied, PSNR 46.7 dB vs CPU
CPU renders byte-identical to before

The default auto mode applies LoRAs at runtime when weights are quantized, so Q4_K_M models never took this path. It is reached with F16 GGUFs (Z-Image-Turbo, FLUX.2 klein and Qwen-Image-2.1 all ship one).

Not tested

Real Apple Silicon hardware (the runner exposes a paravirtual Metal device), and an F16 Z-Image GGUF with a Z-Image LoRA.

@danielhanchen danielhanchen self-assigned this Dec 1, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-01T17:31:44.004181Z 4c40ae4 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 4c40ae478c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit f22ff38 into master Dec 1, 2026
8 checks passed
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.

2 participants