pub fn flash_attention2_forward<T: Triton, D: Float, const HEAD_DIM: i32>(
q_ptr: T::Pointer<D>,
k_ptr: T::Pointer<D>,
v_ptr: T::Pointer<D>,
o_ptr: T::Pointer<D>,
l_ptr: T::Pointer<D>,
n_ctx_q: i32,
n_ctx_k: i32,
softmax_scale: f32,
neg_inf: f32,
)Expand description
Flash Attention 2 forward pass.
Inputs (all [BH, N_CTX, HEAD_DIM] row-major, where BH = BATCH * N_HEADS):
q_ptr, k_ptr, v_ptr
Outputs:
o_ptr — attention output [BH, N_CTX_Q, HEAD_DIM]
l_ptr — log-sum-exp [BH, N_CTX_Q] (saved for backward)
Grid: (N_CTX_Q, BH, 1) — one CTA per (batch_head, q_row) pair.