Repository navigation
cuda: FWHT kernels for block widths above 2048 (to prism) - #153
Merged
Merged
Conversation
The register kernel keeps N/warp_size floats per thread, so it runs out of registers long before the arithmetic runs out: at N=4096 that is 128 floats per thread, which spills. The switch therefore stopped at 2048 and returned false for anything larger, and the whole op fell back. The fallback is not free. On an L40S, the two f32 cases at block 4096 fail the existing backend-op tolerance through the fallback path: MUL_MAT_HADAMARD(blk=4096,width=4096,n_tokens=7) ERR 1.37e-07 > 1.00e-07 MUL_MAT_HADAMARD(blk=4096,width=8192,n_tokens=3) ERR 1.34e-07 > 1.00e-07 Add a shared-memory path for the widths the register kernel cannot reach: one row per block, the row staged in shared memory, all log2(N) butterfly stages run there, same sign convention and same scale-and-signs-on-load as the register path. 16 KiB of shared at 4096 and 32 KiB at 8192, both inside the 48 KiB default, so no opt-in carveout is needed. Blocks up to 2048 keep the existing register kernel untouched. Adds backend-op coverage at 512, 2048, 4096 and 8192 (the previous FWHT cases only exercised 1024). On an L40S: 24/26 before, 26/26 after, and the two cases that flip are exactly the block-4096 f32 ones above, which also confirms the new kernel is what runs rather than the test passing through a CPU fallback.
imaami
pushed a commit
to imaami/llama.cpp
that referenced
this pull request
Oct 13, 2026
Load explicit sign vectors inside the F16/F32 transform and select block-per-row kernels for wide decode shapes. Keep the shared-memory fallback and its dispatch controls. Exclude 8192-wide shared-memory instantiations on MUSA. Source: PrismML-Eng#121 Source: PrismML-Eng#153 Source: PrismML-Eng#166 Source commits (PrismML-Eng/llama.cpp): 9146baa 14d8bb5 db4c6ee 2f2ddf0 ddc5ed9 fe88d0c f37f047 610ddad e76b304 4edee06 c49590b 2e85ea4 e71a350 e9e4ea3 34c9b5c 8362c89 deb4dfd 52ad701 e0c828b 6f1c690 1bc46a8 b6f1bb5 Co-authored-by: Pasha Khosravi <[email protected]> Assisted-by: GitHub Copilot Assisted-by: OpenAI Codex Ported and rebased by Codex.
imaami
pushed a commit
to imaami/llama.cpp
that referenced
this pull request
Oct 13, 2026
Load explicit sign vectors inside the F16/F32 transform and select block-per-row kernels for wide decode shapes. Keep the shared-memory fallback and its dispatch controls. Exclude 8192-wide shared-memory instantiations on MUSA. Source: PrismML-Eng#121 Source: PrismML-Eng#153 Source: PrismML-Eng#166 Source commits (PrismML-Eng/llama.cpp): 9146baa 14d8bb5 db4c6ee 2f2ddf0 ddc5ed9 fe88d0c f37f047 610ddad e76b304 4edee06 c49590b 2e85ea4 e71a350 e9e4ea3 34c9b5c 8362c89 deb4dfd 52ad701 e0c828b 6f1c690 1bc46a8 b6f1bb5 Co-authored-by: Pasha Khosravi <[email protected]> Assisted-by: GitHub Copilot Assisted-by: OpenAI Codex Ported and rebased by Codex.
imaami
pushed a commit
to imaami/llama.cpp
that referenced
this pull request
Nov 2, 2026
Load explicit sign vectors inside the F16/F32 transform and select block-per-row kernels for wide decode shapes. Keep the shared-memory fallback and its dispatch controls. Exclude 8192-wide shared-memory instantiations on MUSA. Source: PrismML-Eng#121 Source: PrismML-Eng#153 Source: PrismML-Eng#166 Source commits (PrismML-Eng/llama.cpp): 9146baa 14d8bb5 db4c6ee 2f2ddf0 ddc5ed9 fe88d0c f37f047 610ddad e76b304 4edee06 c49590b 2e85ea4 e71a350 e9e4ea3 34c9b5c 8362c89 deb4dfd 52ad701 e0c828b 6f1c690 1bc46a8 b6f1bb5 Co-authored-by: Pasha Khosravi <[email protected]> Assisted-by: GitHub Copilot Assisted-by: OpenAI Codex Ported and rebased by Codex.
imaami
pushed a commit
to imaami/llama.cpp
that referenced
this pull request
Nov 24, 2026
Load explicit sign vectors inside the F16/F32 transform and select block-per-row kernels for wide decode shapes. Keep the shared-memory fallback and its dispatch controls. Exclude 8192-wide shared-memory instantiations on MUSA. Source: PrismML-Eng#121 Source: PrismML-Eng#153 Source: PrismML-Eng#166 Source commits (PrismML-Eng/llama.cpp): 9146baa 14d8bb5 db4c6ee 2f2ddf0 ddc5ed9 fe88d0c f37f047 610ddad e76b304 4edee06 c49590b 2e85ea4 e71a350 e9e4ea3 34c9b5c 8362c89 deb4dfd 52ad701 e0c828b 6f1c690 1bc46a8 b6f1bb5 Co-authored-by: Pasha Khosravi <[email protected]> Assisted-by: GitHub Copilot Assisted-by: OpenAI Codex Ported and rebased by Codex.
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.
Cherry-pick of #152 (merged into
prism-v7) ontoprism, commit kept as authored.prism-v7is historical; the release branch isprism.Adds the shared-memory CUDA FWHT path for block widths 4096 and 8192 (the register kernel stops at 2048) and backend-op coverage for 512, 2048, 4096 and 8192. This is what the 9B preview model needs: its Hadamard block is 4096 and it has been running the GEMM fallback on CUDA. Metal still caps at 2048 (separate change).
Merge with Rebase and merge to keep the single commit.