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>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -541,7 +541,7 @@ impl FusedTrainingCtx {
|
||||
num_heads: 4,
|
||||
batch_size,
|
||||
};
|
||||
let gpu_attention = match GpuAttention::new(stream.clone(), attn_config) {
|
||||
let gpu_attention = match GpuAttention::new(Arc::clone(trainer.shared_cublas()), attn_config) {
|
||||
Ok(attn) => {
|
||||
info!(
|
||||
hidden_dim = shared_h2,
|
||||
|
||||
Reference in New Issue
Block a user