Skip to main content

SSM - API Specification

Version: v1.0.0 | Status: Active | Last Updated: March 2026

1. Overview​

The ssm module provides a from-scratch implementation of State Space Models, specifically the Mamba selective SSM architecture. An alternative to Transformers for sequence modelling with linear-time complexity.

2. Core Components​

2.1 Classes​

ClassDescription
MambaBlockFull Mamba block with selective SSM, gating, and residual connection
SelectiveSSMCore selective state-space model with input-dependent dynamics

2.2 Functions​

FunctionSignatureDescription
mamba_forward(x, ssm_params) -> ndarrayRun a forward pass through the Mamba SSM

3. Usage Example​

from codomyrmex.ssm import MambaBlock
import numpy as np

block = MambaBlock(d_model=256, d_state=16, d_conv=4)
x = np.random.randn(1, 128, 256) # (batch, seq_len, d_model)
output = block(x)
print(output.shape) # (1, 128, 256)

4. Navigation​