Repository navigation
fix(patches): support conv-shaped LoHa factors - #10048
Merged
Pfannkuchensack merged 3 commits intoOct 28, 2026
Merged
Conversation
Flatten non-Tucker LoHa factor pairs before multiplication so Conv2d patches can be reconstructed and reshaped to the target weight.
Pfannkuchensack
approved these changes
Oct 27, 2026
Pfannkuchensack
left a comment
Member
There was a problem hiding this comment.
Thanks, this is the fix #10017 asked for. Checked:
- Repro from #10017. The conv-shaped factor pair (
hada_w*_a [8, 2, 1, 1],hada_w*_b [2, 4, 3, 3]) built throughany_lora_layer_from_state_dictnow patches a[8, 4, 3, 3]weight instead of failing inget_weight. - Other layouts. Linear factors and LyCORIS' already-flattened conv factors (
[out, rank]/[rank, in*kh*kw]) pass through the reshapes unchanged,_rank()still readsw1_b.shape[0], and the existingget_parametersreshape restores the conv shape. The Tucker path is untouched. - Tests. The new test passes; with
main'sloha_layer.pyswapped in it fails.tests/backend/patches: 279 passed, 2 skipped.
Pfannkuchensack
enabled auto-merge (squash)
October 28, 2026 00:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Non-Tucker LoHa factors were multiplied without flattening, which fails for Conv2d factors such as
[out, rank, 1, 1]and[rank, in, kernel_h, kernel_w].This change flattens each factor pair to 2D before matrix multiplication. The resulting patch is then reshaped to the original Conv2d weight shape by the existing parameter reconstruction path.
Linear LoHa behavior and the Tucker decomposition path are unchanged.
Related Issues / Discussions
Closes #10017
QA Instructions
Added a CPU tensor regression test using Conv2d-shaped LoHa factors:
w*_a:[8, 2, 1, 1]w*_b:[2, 4, 3, 3][8, 4, 3, 3]and matches the independently calculated expected values.Checks performed:
1 passedgit diff --check: passedThe focused regression was run with real CPU Torch tensors. The complete repository test suite was not run because the locked test-environment dependency synchronization did not complete locally.
Review
No remaining material findings were identified.
The implementation was also checked against linear and Conv2d-style factor shapes. The reshape operations preserve dtype and device placement and do not change the Tucker path.
Remaining limitation: validation was performed on CPU with focused tensor tests; full-suite and GPU integration testing were not available locally.
Checklist
What's Newcopy (if doing a release after this PR) — N/ANeed help on this PR? Tag
@codesmith-botwith what you need.