Skip to main content

SaeRowLayout

Struct SaeRowLayout 

Source
pub struct SaeRowLayout {
    pub active_atoms: Vec<Vec<usize>>,
    pub coord_starts: Vec<Vec<usize>>,
    pub coord_offsets_full: Vec<usize>,
    pub coord_dims: Vec<usize>,
}
Expand description

Per-row active-set layout for sparse SAE assignment (any mode).

When the assignment is sparse — structurally (JumpReLU gate) or effectively (softmax / IBP-MAP at large K, where the assignment mass concentrates on a small support) — only a subset of K atoms are active per observation. The Arrow-Schur row block for observation i has dim q_active_i = |active_atoms_i| + Σ_{k ∈ active_i} d_k rather than q = assignment_dim + Σ_k d_k. This struct records which atoms are active per row and maps compressed block positions back to full-q positions so that apply_newton_step can unpack the compact delta_t from the solve.

For JumpReLU the active set is exactly the gated support (a_{n,k} ≠ 0), so the compact solve is identity to the dense solve. For IBP-MAP the active set is the union of a top-k_active_cap truncation and a magnitude cutoff on a_{n,k}; this is only enabled when K is large enough that the dense (m_total · p)² data Gram would not fit the host / device working-set budget, and the dropped atoms carry O(a_{n,k}²) curvature that is negligible by construction of the cutoff.

#1408: SOFTMAX engages this compact layout when an explicit top_k (softmax_active_cap) and/or the in-core memory budget bounds the active set — the AssignmentMode::Softmax arm of assemble_arrow_schur consults crate::manifold::SaeManifoldTerm::softmax_active_plan and, on Some((cap, cutoff)), builds the active set via Self::from_dense_weights. The full-K dense softmax layout is retained only when neither lever engages (no top_k, in-budget K). Folding softmax top_k into the compact solve required writing the active×active Gershgorin Loewner majorizer sub-block (#1419; the softmax entropy curvature is indefinite, so its raw diagonal cannot be used) AND contracting that SAME majorizer over the compact logit slots in the logdet ρ-trace (assignment_log_strength_hessian_trace) and the θ-adjoint, so value, log|H|, and Γ differentiate one operator on the compact support. That coordinated change is landed and FD-certified; the FFI’s after-the-fit top-k projection is then a no-op at the optimum.

Fields§

§active_atoms: Vec<Vec<usize>>

active_atoms[row] — sorted indices of active atoms for that row.

§coord_starts: Vec<Vec<usize>>

For row i, active atom active_atoms[i][j] has its coord block starting at compressed position coord_starts[i][j].

§coord_offsets_full: Vec<usize>

Full-q coordinate offset for atom k (length k_atoms).

§coord_dims: Vec<usize>

Per-atom coordinate dimensions, indexed by atom index.

Implementations§

Source§

impl SaeRowLayout

Source

pub fn row_q_active(&self, row: usize) -> usize

Per-row compressed dim.

Source

pub fn expand_row(&self, row: usize, delta_t_row: &[f64], out: &mut [f64])

Expand a compact delta_t row slice back into full-q, zeros for inactive.

Trait Implementations§

Source§

impl Clone for SaeRowLayout

Source§

fn clone(&self) -> SaeRowLayout

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SaeRowLayout

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

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

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V