Repository navigation
cuda: out_prod dequantizes a 2D weight in row blocks — the output head's backward holds one block (dd109d3c, second cut) - #4
Merged
joelteply merged 1 commit intoSep 26, 2026
Conversation
…d's backward holds one block, never W in F32 The first cut (a0c6294) dequantized the whole src0 per op: for a 27B's output head (5120 x 152k) that is ~3.1 GB of F32 beside the resident model. out_prod sums over src0's rows (ne01), so a 2D weight is now dequantized 256 MiB of F32 at a time and the GEMMs accumulate (beta 0 for the first block, 1 after); batched and broadcast shapes keep the whole-copy path. Three new test-backend-ops cases at k = 600000 rows (three blocks; Q4_K in both src1 orientations, Q8_0) against the CPU backend. Measured on an RTX 5090 (CUDA 13.2, Windows): test-backend-ops test -b CUDA0 -o OUT_PROD: 234/234 passed, 0 FAIL, 0 refused. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc
Author
|
APPROVED at
The three new cases pin exactly the multi-block accumulation (k = 600000, three blocks at m = 256), in both src1 orientations at Q4_K plus Q8_0, against CPU: the only way a wrong offset or a missing beta = 1 shows up. 234/234 on the 5090 is the gate met. Speed stays the S3 gate's question; the fused dequant-in-GEMM route is the follow-on if the per-block Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com |
joelteply
merged commit Sep 26, 2026
42a35ff
into
feat/props-weight-residency
14 of 29 checks passed
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.
What
Second cut on the quantized-
src0out_prod(after #3): for a 2D weight (ne02 == ne03 == 1, 2D dst) the dequantized transient is a row block of at most 256 MiB of F32, not the wholeW.out_prodsums oversrc0's rows (ne01), so each block is dequantized through the same F32 converter and its GEMM accumulates intodst(beta = 0for the first block,1after). Batched and broadcast shapes keep the whole-copy path from #3.Why now (Cormac on #3): the largest frozen matmul in a LoRA backward is the output head,
out_prod(W_out, grad^T)withW_out = n_embd × n_vocab— ~3.1 GB of F32 for a 27B beside the resident model. Blocked, it is one 256 MiB buffer.Measured (RTX 5090, CUDA 13.2, Windows, this branch)
test-backend-ops test -b CUDA0 -o OUT_PRODagainst the CPU backend:Backend CUDA0: OK)k = 600000rows atm = 256(three blocks): Q4_Ktrans_b0 and 1, Q8_0 — all OK🤖 Generated with Claude Code
https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc