Skip to main content

AtomLinearImage

Struct AtomLinearImage 

Source
pub struct AtomLinearImage {
    pub atom_idx: usize,
    pub t_bar: f64,
    pub b0: Array1<f64>,
    pub b1: Array1<f64>,
    pub row_codes: Option<Array1<f64>>,
    pub v: Option<Array1<f64>>,
}
Expand description

The fitted straight sub-model γ̃(t) = b₀ + (t − t̄)·b₁ of one d = 1 atom: the exact assignment-mass-weighted least-squares line fit to the atom’s leave-this-atom-out RESPONSE residual y_resp over its assigned rows (the curved family’s nested Θ = 0 sub-model on common data, #1202). Carried on a verdict that selects LINEAR so the collapsed reconstruction can replace the curved decoded row with this straight image at any coordinate WITHOUT re-entering the (broken, #1051) outer fit — the coefficients are already realized inside the adjudication.

Fields§

§atom_idx: usize

The atom’s slot index in the dictionary (so the collapsed assembly knows which atom’s decoded row to substitute).

§t_bar: f64

The mass-weighted coordinate mean the line is centered on.

§b0: Array1<f64>

Per-output-channel centered intercept b₀ = γ̄ at (length p).

§b1: Array1<f64>

Per-output-channel slope b₁ (length p).

§row_codes: Option<Array1<f64>>

#1026 collapse-rescue per-row coordinates. None for the ordinary path: the line is evaluated at the atom’s OWN realized coordinate t. Some(u) only when the atom’s circle codes had collapsed to a single point (s_tt ≈ 0) so its own coordinate carries no spread — then the line is fit against, and reconstruct evaluates it at, these FRESH per-row codes uᵢ (the projection of the leave-this-atom-out residual onto its top mass-weighted output direction). This is what lets a circle atom that the joint fit drove into the degenerate “chord-through-the-arc” fixed point still reconstruct its residual’s best linear direction — recovering the linear-tail reach the hybrid-split was designed to deliver — instead of a constant (its collapsed curve), which is the real-OLMo rank-1 co-collapse (held-out EV ≈ 0.13 vs the linear ceiling ≈ 0.74). Length n (one per reconstructed row); unassigned rows are gated to zero by a_k anyway.

TRAIN-ONLY CAVEAT (#1777): these are the TRAIN rows’ codes. They are only meaningful for the exact rows the split was fit on; a held-out row has no entry here and used to fall back to the atom’s own (collapsed) coordinate own_t — a DIFFERENT, degraded model out of sample. Prefer Self::v: projecting a held-out row’s leave-this-atom-out residual onto v recovers that row’s coordinate by the SAME math the train codes were built with, so train and OOS use one model. row_codes is retained for back-compat and as the exact cached train projection.

§v: Option<Array1<f64>>

#1777 collapse-rescue projection DIRECTION v (length p, unit norm), the top mass-weighted output direction of the atom’s leave-this-atom-out residual. Some exactly when this is a collapse-rescued image (paired with row_codes); None for the ordinary straight-image path (which decodes at the atom’s own coordinate). This is the SERIALIZABLE quantity the FFI must persist so an OOS term can recompute any row’s coordinate as uᵢ = ⟨y_i − Σ_{j≠k} f_j(x_i), v⟩ — identical to the train code row_codes[i] on a train row, and the correct held-out coordinate on an OOS row (see Self::coordinate_from_residual). Length must equal b0/b1.

Implementations§

Source§

impl AtomLinearImage

Source

pub fn fill_row(&self, t: f64, out: &mut [f64])

Evaluate the straight sub-model b₀ + (t − t̄)·b₁ into out (length p).

Source

pub fn coordinate_for_row(&self, row: usize, own_t: f64) -> f64

The coordinate at which row row should evaluate this image: the collapse-rescue fresh code uᵢ when present (#1026), else the atom’s own realized coordinate own_t passed by the caller.

TRAIN-ONLY: row_codes is indexed by TRAIN row, so this is correct only for the rows the split was fit on. Out of sample use Self::coordinate_from_residual (target-aware, model-identical to train).

Source

pub fn coordinate_from_residual(&self, resid: &[f64]) -> Option<f64>

#1777 — the collapse-rescue coordinate of a row from ITS OWN leave-this-atom-out residual resid = y_i − Σ_{j≠k} f_j(x_i) (length p), namely uᵢ = ⟨resid, v⟩. Some(uᵢ) exactly when this is a collapse-rescued image (v is set); None for the ordinary straight-image path (which has no projection direction and decodes at the atom’s own coordinate).

This is the SAME math [build_collapse_rescue_linear_image] used to build the train row_codes (row_codes[i] = ⟨target_resid[i], v⟩), so on a TRAIN row it reproduces row_codes[i] exactly, and on a HELD-OUT row it yields that row’s correct coordinate — train and OOS share one model. Returns None if resid’s length disagrees with v.

Source

pub fn is_collapse_rescued(&self) -> bool

Whether this image is a #1777 collapse-rescued image (carries a projection direction v and per-row train codes) rather than an ordinary straight image evaluated at the atom’s own coordinate.

Trait Implementations§

Source§

impl Clone for AtomLinearImage

Source§

fn clone(&self) -> AtomLinearImage

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 AtomLinearImage

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