Struct Mamba2Cache Copy item path Source pub struct Mamba2Cache<B: Backend> {
pub conv_bvk: Tensor<B, 3>,
pub ssm_bhpr: Tensor<B, 4>,
}Expand description The mutable state carried between decoding steps for a single Mamba-2
layer.
Both tensors are updated in-place (via Burn’s functional clone) at every
call to [crate::mamba2::Mamba2::step].
Convolution rolling window.
Stores the last conv_kernel pre-activation feature vectors fed into
the depthwise Conv1d. At each step, the oldest column is discarded and
the new token’s projection is appended (a left-shift followed by an
insert into the rightmost column), maintaining strict causality.
Shape: [batch, conv_dim, conv_kernel]
conv_dim = d_inner + 2 · ngroups · state_rank
conv_kernel is typically 4
SSM hidden state hₜ.
This is the O(P·N) compressed summary of all tokens seen so far.
Updated via hₜ = Āₜ hₜ₋₁ + B̄ₜ xₜ at each decoding step.
The tensor is indexed as [batch, nheads, per_head_dim, state_rank]
(i.e. [B, H, P, N] in the paper’s notation), which is the transpose
of the mathematical hₜ ∈ ℝ^{N×P} but equivalent in content.
Shape: [batch, nheads, per_head_dim, state_rank]
Inner module without auto-differentiation.
Returns the same module, but on the inner backend without auto-differentiation.
Wraps an inner module back into an auto-diff module.
Performs copy-assignment from
source.
Read more Formats the value using the given formatter.
Read more Formats the value using the given formatter.
Read more The module with auto-differentiation.
Type to save and load the module.
Load the module state from a record.
Convert the module into a record containing the state.
Get the number of parameters the module has, including all of its sub-modules.
Visit each tensor parameter in the module with a
visitor .
Map each tensor parameter in the module with a
mapper .
Return all the devices found in the underneath module tree added to the given vector
without duplicates.
Move the module and all of its sub-modules to the given device.
Read more Fork the module and all of its sub-modules to the given device.
Read more Return all the devices found in the underneath module tree without duplicates.
Each tensor in the module tree will not require grad.
Read more Move the module and all of its sub-modules to the autodiff backend.
Read more Quantize the weights of the module.
Formats the module with provided display settings.
Read more Custom display settings for the module.
Read more Attributes of the module used for display purposes.
Read more Gets the number of the parameters of the module.
Immutably borrows from an owned value.
Read more Mutably borrows from an owned value.
Read more 🔬 This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from
self to
dest.
Read more Returns the argument unchanged.
Calls U::from(self).
That is, this conversion is whatever the implementation of
From <T> for U chooses to do.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning.
Read more Uses borrowed data to replace owned data, usually by cloning.
Read more Converts the given value to a
String.
Read more The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.