Files
foxhunt/crates
jgrusewski f388a4a9ce feat: rewrite Attention to batched cuBLAS GEMMs
Replace per-sample CUDA kernels (multihead_feature_attention forward,
attention_backward_kernel + tiled weight_grad_reduce) with 12 cached
cublasLtMatmul descriptors for Q/K/V/O projections.

Forward: 4 cuBLAS GEMMs + bias_add + attn_sdp_fwd cubin + attn_layer_norm_fwd cubin
Backward: 8 cuBLAS GEMMs (4 dW + 4 dX) + attn_sdp_bwd + attn_layer_norm_bwd cubins
         + 4 bias_grad_reduce kernels

Eliminates: d_params_per_sample tiling buffer (was 26MB at B=16384),
per-sample backward kernel, weight_grad_reduce kernel, forward_kernel,
backward_kernel, saved_qkv buffer.

Adds: 15 intermediate D*B buffers for projection/gradient flow, SDP scores,
LayerNorm save state. Constructor takes Arc<SharedCublasHandle> instead of
Arc<CudaStream>. CUBLAS_COMPUTE_32F_FAST_TF32. Zero atomicAdd.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-18 00:02:34 +02:00
..