Skip to content

lora : support prism.hadamard folded weights - #30910

Merged
ggerganov merged 2 commits into
ggml-org:masterfrom
vieduy:lora-hadamard-folded
Oct 22, 2026
Merged

ggerganov merged 2 commits into
ggml-org:masterfrom
vieduy:lora-hadamard-folded

Conversation

@vieduy

@vieduy vieduy commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Overview

This PR fixes an issue where models like Ternary-Bonsai-2 failed with a refusal error (targets a prism.hadamard folded weight, which is not supported) when initializing LoRA adapters, allowing LoRA to be used on prism.hadamard folded weights.

The refusal was the safe choice because the LoRA would read the rotated input and compute B*(A*(H*(Dx))) instead of BAx . Solution: the LoRA branch gets the original input (cur) and only the base weight gets the rotated input -> the adapter computes BA*x as trained (same approach as PrismML's prism branch (build_lora_mm)).

Changes:

  • src/llama-adapter.cpp: remove the refusal
  • src/llama-graph.cpp: feed the LoRA the original input

Fixes #30909

Additional information

Model: prism-ml/Ternary-Bonsai-2-2B-gguf (Ternary-Bonsai-2-2B-Q2_0.gguf)

KLD, 16x512 tokens, all 150 rotated weights:

Run KLD Same top token
zero adapter vs base 0.000000 99.975%
adapter vs base 0.049 90.6%
merged ADH vs adapter (patched) 0.000001 99.975%
unrotated merge vs adapter 0.090 87.5%

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: YES. Claude Code was used to help develop and test the fix. I reviewed every line and take full responsibility for the changes.

@vieduy
vieduy requested review from CISC and ggerganov as code owners October 21, 2026 04:02
@github-actions github-actions Bot added the testing Everything test related label Oct 21, 2026

@CISC CISC left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test fails to build, but not sure we should keep it anyway, @ggerganov?

@ggerganov

Copy link
Copy Markdown
Member

The test seems to much for relatively niche application. Better to remove it and if needed we can add tests in the future.

@vieduy

vieduy commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

@ggerganov @CISC I just removed the test. Thanks for your reviews!

@CISC CISC added merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge. and removed testing Everything test related labels Oct 21, 2026
@ggerganov
ggerganov merged commit 0682a57 into ggml-org:master Oct 22, 2026
20 checks passed
voidstackloop added a commit to voidstackloop/llama.cpp that referenced this pull request Oct 22, 2026
Conflict in build_lora_mm_id: master's Hadamard change (ggml-org#30910: the folded
weight reads the transformed input, the LoRA delta reads cur) applied to the
PR's host-ids and cache-slot branches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
auRose94 pushed a commit to auRose94/llama.cpp that referenced this pull request Oct 28, 2026
* lora : support prism.hadamard folded weights

* tests : remove LoRA test from test-llama-archs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: LoRA adapters on prism.hadamard folded weights

4 participants