Repository navigation
cuda: GATED_DELTA_NET_BACK at head size 128 (fixes #10, which could not launch there) + checkpointed recompute; direct CUDA-vs-CPU oracle - #15
Conversation
…ead size 128 (M'/dM out of shared memory) Two changes to the CUDA twin (bf4c3ed): 1. HEAD SIZE 128 NEVER LAUNCHED. M' and dM lived in dynamic shared memory, 2 x S_v^2 floats = 128 KB at S_v = 128, above the ~99 KB per-block limit: supports_op claimed 128, cudaFuncSetAttribute rejected it (invalid argument) and CUDA_CHECK aborted the process. The gradient cases (head sizes 4-32) never reached it; the 27B's delta-net heads are 128. Each row of M' and dM is touched only by its own thread, so both now live in the block's global scratch (row-private, L1/L2-served) and no dynamic shared memory is used at all. 2. CHECKPOINTED RECOMPUTE (card f4fc77c2, Cormac on #10): storing every forward state cost (T + 1) x S_v^2 floats per (sequence, head), GBs per call on the 27B. The forward keeps a two-slot working state and checkpoints every C ~ sqrt(T) tokens; the backward walks the segments last to first, re-running each from its checkpoint into a (C + 1)-state scratch. ceil(T/C) + C + 3 states per block instead of T + 1 (68 vs 1025 at T 1024). Oracle: a new test case, GATED_DELTA_NET_BACK run directly on identical random inputs on every backend (CUDA compared output-for-output against the CPU reference, no finite differences): 5/5 at head sizes 16/32/64/128, sequences up to 64 tokens, KDA on and off, K 1-3, and at segment lengths default, 1, 3 and T (all 5/5). The finite-difference gradient suite is noisy on these small recurrent cases on BOTH backends (CPU reference 5 failing case-runs in 12 suite runs, CUDA 4 in 12, same cases): it is kept, but the direct case is the stable oracle. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc
|
APPROVED at The fix reads right:
On the finite-difference flakes you measured on the CPU reference (5 failing case-runs in 12 suite runs, including my head-8 K=3 case): that's mine. The relative MAA still tips on near-zero gradient components at eps 0.1. I'll make those cases stable in a follow-up; your direct case stays the oracle for the twins. Co-Authored-By: Claude Opus 5.5 [email protected] |
5737801
into
feat/props-weight-residency
cuda: GATED_DELTA_NET_BACK recomputes from checkpoints, and runs at head size 128 (M'/dM out of shared memory)
Two changes to the CUDA twin (bf4c3ed):
HEAD SIZE 128 NEVER LAUNCHED. M' and dM lived in dynamic shared memory, 2 x S_v^2
floats = 128 KB at S_v = 128, above the ~99 KB per-block limit: supports_op claimed 128,
cudaFuncSetAttribute rejected it (invalid argument) and CUDA_CHECK aborted the process.
The gradient cases (head sizes 4-32) never reached it; the 27B's delta-net heads are 128.
Each row of M' and dM is touched only by its own thread, so both now live in the block's
global scratch (row-private, L1/L2-served) and no dynamic shared memory is used at all.
CHECKPOINTED RECOMPUTE (card f4fc77c2, Cormac on cuda: the backward of the gated delta rule (GATED_DELTA_NET_BACK), the CUDA twin of #8's reference — 19739/19739 by finite differences, mutation fails #10): storing every forward state cost
(T + 1) x S_v^2 floats per (sequence, head), GBs per call on the 27B. The forward keeps a
two-slot working state and checkpoints every C ~ sqrt(T) tokens; the backward walks the
segments last to first, re-running each from its checkpoint into a (C + 1)-state scratch.
ceil(T/C) + C + 3 states per block instead of T + 1 (68 vs 1025 at T 1024).
Oracle: a new test case, GATED_DELTA_NET_BACK run directly on identical random inputs on
every backend (CUDA compared output-for-output against the CPU reference, no finite
differences): 5/5 at head sizes 16/32/64/128, sequences up to 64 tokens, KDA on and off,
K 1-3, and at segment lengths default, 1, 3 and T (all 5/5). The finite-difference gradient
suite is noisy on these small recurrent cases on BOTH backends (CPU reference 5 failing
case-runs in 12 suite runs, CUDA 4 in 12, same cases): it is kept, but the direct case is
the stable oracle.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc