pub struct PsaFa2Backward<D: Float> {
pub name: &'static str,
pub id: String,
pub head_dim: i32,
pub kernel_source: String,
pub entry_point_source: String,
pub source: String,
/* private fields */
}Expand description
Combined PSA Flash Attention 2 backward pass.
Each CTA handles one (n, bh) pair and computes both dQ_n (by iterating
over all K rows) and dK_n / dV_n (by iterating over all Q rows).
This is valid in PSA because N_CTX_Q == N_CTX_K == N (self-attention).
Atomicity: dq_ptr and dk_ptr are written with atomic_add because
both FA2_lo and FA2_hi backward passes contribute to shared sections 0 and 1
of the d_packed buffer. dv_ptr uses a regular store (each FA2 call owns
an exclusive V section so no overlap exists).
Grid: (N, BH, 1) — same shape as the FA2 forward pass.
Fields§
§name: &'static strThe kernel function’s name (e.g. "flash_attention2_forward").
id: StringUnique kernel identifier: fn_name + dtype(s) + const values joined by “__”.
head_dim: i32Compile-time kernel constant, from the annotated fn’s const generics.
kernel_source: StringThe original kernel function source.
entry_point_source: StringThe Rust source of the generated C-ABI entry-point wrapper function.
source: StringCombined source (kernel_source + "\n\n" + entry_point_source); used by the Kernel trait.
Implementations§
Trait Implementations§
Source§impl<D: Float> Kernel for PsaFa2Backward<D>
impl<D: Float> Kernel for PsaFa2Backward<D>
Source§type Args<'__a> = (*mut D, *mut D, *mut D, *mut D, *mut D, *mut D, *mut D, *mut D, *mut D, i32, f32)
type Args<'__a> = (*mut D, *mut D, *mut D, *mut D, *mut D, *mut D, *mut D, *mut D, *mut D, i32, f32)
Source§fn kernel_source(&self) -> &str
fn kernel_source(&self) -> &str
Source§fn entry_point_source(&self) -> &str
fn entry_point_source(&self) -> &str
§fn entry_point_name(&self) -> String
fn entry_point_name(&self) -> String
"{name}_entry_point".