pub struct Mamba3DoubleSsdCache {
pub ssm_bhpr: Tensor<4>,
pub k_state_bmhr: Tensor<4>,
pub v_state_bhp: Tensor<3>,
pub rotation: RotationState,
}Expand description
The mutable state carried between decoding steps for a single Mamba-3 layer.
All tensors are updated at every call to crate::mamba3::mamba3::Mamba3::step.
Fields§
§ssm_bhpr: Tensor<4>SSM hidden state hₜ.
Updated via the (double-ssd) trapezoidal recurrence:
hₜ = αₜ hₜ₋₁ + βₜ (sumₘ Kₜ₋₁[m] ⊗ (Vₜ₋₁ * mimo_x[m])) + γₜ (sumₘ Bₜ[m] ⊗ (xₜ * mimo_x[m]))
Shape: [batch, nheads, per_head_dim, state_rank]
k_state_bmhr: Tensor<4>Previous token’s B per mimo rank = Bₜ₋₁[m].
Used to reconstruct the β term: β * sum_r Bₜ₋₁[m] ⊗ (xₜ₋₁ * mimo_x[m]).
For SISO (mimo_rank=1) this is shape [batch, 1, nheads, state_rank].
Shape: [batch, mimo_rank, nheads, state_rank]
v_state_bhp: Tensor<3>Previous token’s x = xₜ₋₁.
Combined with k_state_bmhr and mimo_x to produce the β term.
Shape: [batch, nheads, per_head_dim]
rotation: RotationStateCumulative data-dependent rotation up to the current position
(RotationState): the abelian RoPE angle for
Complex2D (each step
cum_angleₜ = cum_angleₜ₋₁ + Δₜ · tanh(θₜ) · π), or the cumulative unit
quaternion for Quaternion4D.
Starts at the identity for fresh sequences; continued across calls for streaming.
Implementations§
Source§impl Mamba3DoubleSsdCache
impl Mamba3DoubleSsdCache
Sourcepub fn sanity(&self)
pub fn sanity(&self)
Run the NaN/Inf guards on every cached tensor.
Trait Implementations§
Source§impl AutodiffModule for Mamba3DoubleSsdCache
impl AutodiffModule for Mamba3DoubleSsdCache
Source§impl Clone for Mamba3DoubleSsdCache
impl Clone for Mamba3DoubleSsdCache
Source§impl Debug for Mamba3DoubleSsdCache
impl Debug for Mamba3DoubleSsdCache
Source§impl Display for Mamba3DoubleSsdCache
impl Display for Mamba3DoubleSsdCache
Source§impl From<Mamba3DoubleSsdCache> for Mamba3Cache
impl From<Mamba3DoubleSsdCache> for Mamba3Cache
Source§fn from(cache: Mamba3DoubleSsdCache) -> Self
fn from(cache: Mamba3DoubleSsdCache) -> Self
Source§impl From<Mamba3DoubleSsdCache> for Mamba3SingleSsdCache
impl From<Mamba3DoubleSsdCache> for Mamba3SingleSsdCache
Source§fn from(cache: Mamba3DoubleSsdCache) -> Self
fn from(cache: Mamba3DoubleSsdCache) -> Self
Source§impl From<Mamba3SingleSsdCache> for Mamba3DoubleSsdCache
impl From<Mamba3SingleSsdCache> for Mamba3DoubleSsdCache
Source§fn from(cache: Mamba3SingleSsdCache) -> Self
fn from(cache: Mamba3SingleSsdCache) -> Self
Source§impl Module for Mamba3DoubleSsdCache
impl Module for Mamba3DoubleSsdCache
Source§fn num_params(&self) -> usize
fn num_params(&self) -> usize
Source§fn visit<Visitor: ModuleVisitor>(&self, visitor: &mut Visitor)
fn visit<Visitor: ModuleVisitor>(&self, visitor: &mut Visitor)
Source§fn map<Mapper: ModuleMapper>(self, mapper: &mut Mapper) -> Self
fn map<Mapper: ModuleMapper>(self, mapper: &mut Mapper) -> Self
Source§fn collect_devices(&self, devices: Devices) -> Devices
fn collect_devices(&self, devices: Devices) -> Devices
Source§fn to_device(self, device: &Device) -> Self
fn to_device(self, device: &Device) -> Self
Source§fn fork(self, device: &Device) -> Self
fn fork(self, device: &Device) -> Self
§fn devices(&self) -> Vec<Device>
fn devices(&self) -> Vec<Device>
§fn freeze_group(self, group: ParamGroup) -> Self
fn freeze_group(self, group: ParamGroup) -> Self
require_grad to false for every parameter in the given group, leaving the rest
of the module untouched. Read more§fn unfreeze_group(self, group: ParamGroup) -> Self
fn unfreeze_group(self, group: ParamGroup) -> Self
require_grad to true for every parameter in the given group, leaving the rest
of the module untouched. Read more§fn train(self) -> Selfwhere
Self: AutodiffModule,
fn train(self) -> Selfwhere
Self: AutodiffModule,
§fn quantize_weights(self, quantizer: &mut Quantizer) -> Self
fn quantize_weights(self, quantizer: &mut Quantizer) -> Self
§fn quantize_weights_group(
self,
quantizer: &mut Quantizer,
group: ParamGroup,
) -> Self
fn quantize_weights_group( self, quantizer: &mut Quantizer, group: ParamGroup, ) -> Self
§fn apply_reparameterization<R>(self, reparameterizer: R) -> Selfwhere
Self: Sized,
R: Reparameterizer,
fn apply_reparameterization<R>(self, reparameterizer: R) -> Selfwhere
Self: Sized,
R: Reparameterizer,
Reparameterizer]. Read more§fn apply_lora(self, lora: Lora) -> Selfwhere
Self: Sized,
fn apply_lora(self, lora: Lora) -> Selfwhere
Self: Sized,
§fn apply_qlora(self, qlora: QLora) -> Selfwhere
Self: Sized,
fn apply_qlora(self, qlora: QLora) -> Selfwhere
Self: Sized,
§fn into_record(self) -> ModuleRecordwhere
Self: Sized,
fn into_record(self) -> ModuleRecordwhere
Self: Sized,
ModuleRecord. Read more§fn into_record_group(self, group: ParamGroup) -> ModuleRecordwhere
Self: Sized,
fn into_record_group(self, group: ParamGroup) -> ModuleRecordwhere
Self: Sized,
§fn try_load_record(self, record: ModuleRecord) -> Result<Self, RecordError>where
Self: Sized,
fn try_load_record(self, record: ModuleRecord) -> Result<Self, RecordError>where
Self: Sized,
ModuleRecord to this module, returning the loaded
module. Read more§fn load_record(self, record: ModuleRecord) -> Selfwhere
Self: Sized,
fn load_record(self, record: ModuleRecord) -> Selfwhere
Self: Sized,
ModuleRecord to this module, consuming and returning
it. Read more