Skip to main content

Module helpers

Module helpers 

Source
Expand description

Shared helpers used by both Mamba3::forward and Mamba3::step. They isolate three blocks that previously appeared in both methods at different ranks:

  1. Trapezoidal discretisation: dt, α, β, γ, da.
  2. QK-norm + GQA expansion + per-(head, mimo-rank) bias on B / C.
  3. MIMO V construction: broadcast-multiply x by mimo_x_hmp.

Each helper is generic over the rank D of the data tensors so a single definition serves both the sequence-aware (forward) and single-token (step) code paths.

Structs§

TrapezoidCoeffs
Output of trapezoidal_coefficients.

Functions§

build_v_with_mimo
Build the MIMO value tensor v = x ⊙ mimo_x with broadcasting.
qk_norm_expand_bias
QK-Norm → GQA-expand groups→heads → add per-(head, mimo-rank) bias.
trapezoidal_coefficients
Compute the trapezoidal discretisation coefficients from the raw (data-dependent) projections. See the top-of-mamba3.rs docs for the formulas.