nemo_automodel.components.attention.ffpa_attention
nemo_automodel.components.attention.ffpa_attention
FFPA attention bindings for HF ALL_ATTENTION_FUNCTIONS / ALL_MASK_ATTENTION_FUNCTIONS.
Routes head_dim=512 bf16/fp16 layers through the CuTeDSL FFPA kernel,
sliding-window (flex BlockMask) layers through FlexAttention, and falls back
to SDPA (or eager for softcap) for other unsupported configurations.
Module Contents
Functions
Data
API
FFPA CuTeDSL dense backward using the caller-supplied out/lse.
Returns (dq, dk, dv) all in [B, H, N, D] SDPA layout (dK/dV reduced to
Hkv for GQA). Exposed as an explicit call (not the package’s autograd) so
the ring backward can feed the globally merged out/lse, not a chunk-local one.
FFPA CuTeDSL dense forward on [B, H, N, D] SDPA-layout tensors.
Returns (out[B, Hq, Nq, D], lse[B, Hq, Nq] fp32); handles GQA and causal/non-causal
internally. Exposed (not via the autograd ffpa_attn_func) so the ring gets the
per-chunk lse for its online-softmax merge.
FFPA CuTeDSL varlen backward using the caller-supplied out/lse. Returns (dq, dk, dv).
Exposed as an explicit op call (not the package’s varlen autograd) because the ring backward feeds the globally merged out/lse, not a chunk-local one.
FFPA CuTeDSL varlen forward on packed THD inputs. Returns (out[T,Hq,D], lse[Hq,T]).
Wraps _varlen_fwd_cute with the fixed no-window/no-softcap/no-pack-gqa sentinels.
Whether the FFPA CuTeDSL varlen ops are importable and registered.
True for a flex BlockMask — the marker that a layer should run on FlexAttention.
HF attention-interface forward backed by torch.ops.ffpa_attn._fwd_cute.
Mask factory for ALL_MASK_ATTENTION_FUNCTIONS["ffpa"].
Register "ffpa" in HF attention/mask registries. Idempotent.
Validate FFPA preconditions, then register the HF "ffpa" backend.
The "ffpa" backend calls the FFPA op directly, bypassing both the ring-CP
SDPA swap and packed-sequence masking; for CP or packing use
attn_implementation="sdpa" + text_config.cp_full_attn_backend="ffpa" instead.