IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).

Python module

max.nn.legacy.state_space

Python wrappers for the state_space Mojo kernel package.

The module layout mirrors max/kernels/src/state_space/. All ops here are registered as graph-compiler builtins, so no custom_extensions plumbing is needed. The legacy Mamba-1 eager wrappers intentionally stay in the Mamba architecture (their sole consumer) to keep max.nn.legacy from depending on max.functional.

Submodulesโ€‹

max.nn.legacy.state_space.kimi_deltaPython wrapper for the KDA (Kimi Delta Attention) recurrence op.

Classesโ€‹

GatedDeltaReplayInputsOne layer's per-token inputs to the two state kernels.

Functionsโ€‹

causal_conv1d_varlen_fwdApplies a slot-indexed varlen causal depthwise conv1d.
gated_delta_conv1d_fwdApplies the causal conv1d pass.
gated_delta_conv1d_verify_fwdRuns gated_delta_conv1d_fwd() in a speculative verify graph.
gated_delta_recurrence_fwdApplies the gated delta recurrence pass.
gated_delta_recurrence_verify_ring_fwdRuns the recurrence over a speculative verify window into a ring.
gated_delta_state_foldApplies a verify's accepted ring records to the state pool.
gated_group_rmsnormFuses the gated group-RMSNorm into a single dispatch.
kda_chunkRuns the KDA chunk-parallel prefill recurrence, mutating state_pool.
kda_chunk_is_registeredReports whether the current graph's kernel library has kda_chunk.
kda_chunk_supports_head_dimsReports whether kda_chunk is compiled for this head-dim pair.
kda_decodeRuns the KDA recurrence, mutating state_pool in place.
mamba2_replay_foldCommits each request's accepted verify rows to every Mamba-2 layer.
mamba2_ssd_chunk_scan_varlen_fwd_inplacePerforms the Mamba-2 SSD chunked-scan forward.
short_conv_ringReturns x + conv(x) over a ragged batch.
verify_width_operandReturns the operand the speculative state ops read the verify width from.