Skip to main content

SelectiveSSMBD

Struct SelectiveSSMBD 

Source
pub struct SelectiveSSMBD { /* private fields */ }
Available on crate feature alloc only.
Expand description

Block-Diagonal Linear Recurrent Unit selective state space model.

Partitions d_in channels into n_blocks = d_in / block_size blocks, each with a dense block_size x block_size A matrix for within-block cross-channel state mixing. B, C, and Delta projections are shared across blocks (same structure as Mamba-1).

§Dimensions

  • d_in – input/output dimension (number of channels)
  • n_state – hidden state dimension per block-channel (N)
  • block_size – number of channels per block (m)
  • n_blocks – number of blocks (d_in / block_size)
  • Total hidden state size: n_blocks * n_state * block_size

§Weight Shapes

WeightShapePurpose
a_matricesn_blocks * m * mDense A per block (row-major, L1-normalized)
w_bN x d_inProjects input to state-input coupling
w_cN x d_inProjects input to state-output coupling
w_deltad_inProjects input to scalar step size
d_skipd_inSkip connection weights

§Example

use irithyll_core::ssm::selective_bd::SelectiveSSMBD;
use irithyll_core::ssm::SSMLayer;

let mut ssm = SelectiveSSMBD::new(4, 8, 2, 42);
let output = ssm.forward(&[1.0, 2.0, 3.0, 4.0]);
assert_eq!(output.len(), 4);

Implementations§

Source§

impl SelectiveSSMBD

Source

pub fn new(d_in: usize, n_state: usize, block_size: usize, seed: u64) -> Self

Create a new block-diagonal selective SSM with random weight initialization.

A matrices are initialized with S4D-Inv diagonal values and small random off-diagonal entries (scale 0.02), then row-wise L1-normalized. Projection weights are initialized from a small normal distribution (scale 0.1). Skip connections (D) are initialized to 1.0 for input passthrough.

§Arguments
  • d_in – input/output dimension (must be divisible by block_size)
  • n_state – hidden state dimension per block-channel (N)
  • block_size – number of channels per block (m)
  • seed – random seed for weight initialization
§Panics

Panics if d_in is not evenly divisible by block_size.

§Example
use irithyll_core::ssm::selective_bd::SelectiveSSMBD;

let ssm = SelectiveSSMBD::new(6, 8, 2, 42);
Source

pub fn d_in(&self) -> usize

Get the input/output dimension.

Source

pub fn n_state(&self) -> usize

Get the number of state dimensions per block-channel.

Source

pub fn block_size(&self) -> usize

Get the number of channels per block.

Source

pub fn n_blocks(&self) -> usize

Get the number of blocks.

Source

pub fn reinitialize_block(&mut self, b: usize, rng: &mut u64)

Surgically reinitialize a single block, preserving all other blocks.

Resets block b’s hidden state to zero, reinitializes its A matrix with S4D diagonal + small random off-diagonal values (then L1 row- normalizes), and resets the skip connections for the block’s channels to 1.0. All other blocks are left untouched.

§Arguments
  • b — block index to reinitialize (must be < n_blocks)
  • rng — mutable RNG state for generating fresh weights
§Panics

Panics if b >= n_blocks.

Trait Implementations§

Source§

impl SSMLayer for SelectiveSSMBD

Source§

fn forward(&mut self, input: &[f64]) -> Vec<f64>

Process one input timestep and return the output vector. Read more
Source§

fn state(&self) -> &[f64]

Get a reference to the current hidden state.
Source§

fn output_dim(&self) -> usize

Output dimension of this SSM layer.
Source§

fn reset(&mut self)

Reset hidden state to zeros, as if no data has been seen.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.