nemo_automodel.components.models.gemma4_moe.sdpa_fp32
nemo_automodel.components.models.gemma4_moe.sdpa_fp32
fp32 SDPA attention for Gemma4 (fix for #2208: fused bf16 SDPA NaNs on Hopper).
Module Contents
Functions
API
Install sdpa_fp32_attention_forward as the process-wide "sdpa" implementation.
Run SDPA in FP32 and cast the output back to the query dtype.
Parameters:
module
Attention module holding scaling and causal-mask settings.
query
Tensor of shape [batch, query_heads, queries, head_dim].
key
Tensor of shape [batch, kv_heads, keys, head_dim].
value
Tensor with key’s layout.
attention_mask
Optional mask broadcastable to [batch, query_heads, queries, keys].
**kwargs
Arguments forwarded to the Hugging Face SDPA implementation.
Returns: torch.Tensor
Attention output [batch, queries, query_heads, head_dim] in query’s