Repository navigation
CUDA: fuse the short convolution chain with its state store and residual - #411
danielhanchen wants to merge 1 commit into
Conversation
One kernel per sequence and channel for CONCAT(past, transpose(cur)), the conv state store (CPY of the tail, or the rollback SET_ROWS with its ARANGE/SCALE/CAST slot order), SSM_CONV, the optional dynamic taps (CONT, then MUL and ADD per lag), ADD(cur, out) and SCALE. Up to 32 tokens per sequence; longer ubatches keep the separate kernels. The arithmetic follows the separate kernels: the conv taps are contracted in tap order like ssm_conv_f32, every MUL and ADD rounds on its own, and the scale is contracted like scale_f32. Inputs are kept in registers, so the output may alias cur. Kill switch: GGML_CUDA_DISABLE_SHORT_CONV_FUSION=1. Test: CONV_CHAIN_FUSE.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Tested #411, #412 and #414 together on AMD: R9700 (gfx1201, RDNA4), ROCm 7.2.4, Inkling-2-Mini UD-Q4_K_M, q8_0 KV. The three PRs are cherry-picked on top of #386 + #406. The only conflict was in Tests: Speed (tg128 45.1 and pp512 1612 with all fusions on; without the three PRs tg128 37.9, pp512 1515):
Output vs the same build without the three PRs (wikitext-2, -c 512, one fusion enabled at a time; the A/A floor here is KLD 0, max 6e-5):
So on HIP the depth mix and row-norm fusions are bit-exact. The short-conv fusion (#411) and the tanh fusion (#412) are not: the difference is rounding-level for this looped model, but not zero. For the short conv, a bit-exact HIP version is possible. In the version I dropped from #406, the kernel kept the unfused accumulation order ( |
…residual (unslothai#411, commit 7e633d6) Merge --no-ff du commit épinglé par unsloth (scripts/unsloth/pr-set.json). Couche 2, liste A (banc/notes/couche2-unsloth-liste-2026-11-24.md côté notes). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QBjnvFeJ4P7Jp71oC6pzWf
Pin for the prebuilt: upstream b12602 (418fe97) plus this one commit. Base branch base/upstream-418fe97b5.
What it changes
Inkling 2 runs a causal short convolution on k, v, the attention output and the FFN output of every layer: CONCAT(past, transpose(cur)), the conv state store (a CPY of the tail, or the DSpark rollback SET_ROWS with its ARANGE / SCALE / CAST slot order), SSM_CONV, optional dynamic taps (CONT, then MUL and ADD per lag), ADD(cur, out) and SCALE. That is up to 16 kernels per conv, 4 convs per layer visit. The matcher in ggml-cuda.cu runs the chain as one kernel per sequence and channel (conv-chain.cu) with the rounding of the separate ops:
Up to 32 tokens per sequence (decode, batched decode, speculative verify); longer ubatches keep the separate kernels. GGML_CUDA_DISABLE_SHORT_CONV_FUSION=1 turns it off. test-backend-ops gets CONV_CHAIN_FUSE (44 cases: 1-32 tokens, 1-4 sequences, with and without dynamic taps, CPY and rollback SET_ROWS stores, prefill unfused).
Evidence (B200, one exclusive card, load-gated runs)
Other NVIDIA GPUs (Colab T4, L4, A100-40GB, RTX PRO 6000 Blackwell Server; one card each, built from b12628 plus #399 plus the decode pins)
Needs the node order of the Inkling 2 graph from the #386 fold (inputs expanded before the conv, the conv result right after it); without it the matcher declines and nothing changes.