Class MiniMaxAttention
java.lang.Object
smile.llm.model.minimax.MiniMaxAttention
- All Implemented Interfaces:
Attention
MiniMax-M3 grouped-query attention: per-head Gemma QK norm, partial RoPE, no output gate.
On MSA layers the index projections (index_q_proj, index_k_proj and their
norms) are registered so the checkpoint loads, but this reference implementation attends over
the full causal history (dense). With topk_blocks covering every visible block, MSA
selects all blocks and equals dense attention, so short prompts are exact; block selection
lands in the sparse-attention phase.
Uses the torch-native SDPA kernel over the paged KV pool; mixed positions are supported for single-token decode through a per-row additive mask.
-
Constructor Details
-
MiniMaxAttention
Constructor.- Parameters:
args- model hyperparameters.layerId- decoder layer index (also the KV pool layer).
-
-
Method Details
-
module
Description copied from interface:AttentionReturns pytorch module. -
forward
Description copied from interface:AttentionForward pass through the attention module. -
forward
Forward pass.- Parameters:
x- hidden states[B, S, D].positions- KV write position per row; forS > 1all rows must share one position.cos- RoPE cosines[S, R](prefill) or per-row[B, 1, R](decode).sin- RoPE sines with the same layout.mask- causal mask[S, startPos + S]forS > 1; ignored for decode.- Returns:
- attention output
[B, S, D].
-