pub struct SparseBlockKroneckerPenaltyOp {
pub p: usize,
pub dim_a: usize,
pub k: usize,
pub blocks: Vec<SparseGBlock>,
}Expand description
Block-sparse Kronecker penalty P = A ⊗ I_p where the left factor A
(dimension dim_a × dim_a in μ-space) is stored only on its non-empty
co-occurring atom-pair blocks rather than as a dense (dim_a × dim_a)
matrix.
This is the sparse-atom (K = 100K) replacement for wrapping the dense
data-fit Gauss-Newton Gram G (m_total × m_total) in a
KroneckerPenaltyOp: with per-row active sets of size k_active ≪ K,
only the (atom, atom') pairs that co-occur in some row contribute a
non-zero (m_i × m_j) block, so the storage and every matvec/diagonal
pass cost O(Σ_pairs m_i m_j · p) instead of O((m_total · p)²).
The β index of left-factor coordinate μ and output channel oc is
μ · p + oc (the same μ-major / oc-minor layout the dense
KroneckerPenaltyOp { factor_b: I_p } uses), so this op is a drop-in
structured replacement: with the full dense pair set it reproduces the
dense operator exactly.
Fields§
§p: usizeRight-factor identity dimension p (number of decoder output channels).
dim_a: usizeLeft-factor dimension dim_a in μ-space (= m_total).
k: usizeFull β dimension K = dim_a · p.
blocks: Vec<SparseGBlock>Non-empty (atom_i, atom_j) coupling blocks of A.
Trait Implementations§
Source§impl BetaPenaltyOp for SparseBlockKroneckerPenaltyOp
impl BetaPenaltyOp for SparseBlockKroneckerPenaltyOp
Source§fn matvec(&self, x: &[f64], y: &mut [f64])
fn matvec(&self, x: &[f64], y: &mut [f64])
y += P x — penalty Hessian-vector product (length K).Source§fn diagonal(&self, diag: &mut [f64])
fn diagonal(&self, diag: &mut [f64])
diag += diag(P) — diagonal entries used by Jacobi preconditioner.Source§fn block(
&self,
id: BetaBlockId,
offsets: &[Range<usize>],
out: &mut Array2<f64>,
)
fn block( &self, id: BetaBlockId, offsets: &[Range<usize>], out: &mut Array2<f64>, )
b×b dense penalty sub-block for block id into out
(row-major, block size b = offsets[id.0].len()).
Used by the block-Jacobi Schur preconditioner (#287).Source§fn to_dense(&self) -> Array2<f64>
fn to_dense(&self) -> Array2<f64>
K×K dense penalty matrix (needed by
Direct / SqrtBA modes that form the Schur complement explicitly).Source§fn row_abs_sums(&self) -> Array1<f64>
fn row_abs_sums(&self) -> Array1<f64>
out[r] = Σ_c |P[r,c]|, the row contribution
to the operator’s ∞-norm. The default folds to_dense(), which costs an
O(K²) materialization; structured operators override this to fold their
compact factors directly so the backward-error certificate’s
arrow_operator_infinity_norm never builds a dense K×K matrix on the
SAE LLM-border critical path (#1017). Overrides MUST agree bit-for-bit with
the to_dense() row sums (verified by the cross-check tests).Source§fn fingerprint(&self, hasher: &mut Fingerprinter)
fn fingerprint(&self, hasher: &mut Fingerprinter)
hasher for cache-validity
fingerprinting. Must change whenever matvec / to_dense would change,
so the factorization / evidence cache (cache_matches_system) is
invalidated when the β-block content changes. Implementations hash their
own compact defining data (e.g. Kronecker factors, block matrices)
rather than the full K×K dense form, which would defeat the structured
operator’s storage savings.Auto Trait Implementations§
impl Freeze for SparseBlockKroneckerPenaltyOp
impl RefUnwindSafe for SparseBlockKroneckerPenaltyOp
impl Send for SparseBlockKroneckerPenaltyOp
impl Sync for SparseBlockKroneckerPenaltyOp
impl Unpin for SparseBlockKroneckerPenaltyOp
impl UnsafeUnpin for SparseBlockKroneckerPenaltyOp
impl UnwindSafe for SparseBlockKroneckerPenaltyOp
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.