Expand description
Shared kernels and outer-evaluation infrastructure for the marginal-slope family of GAMs (BMS, survival, latent survival).
§Outer-row subsampling
At large scale (n ≥ tens of thousands) the outer rho-gradient is
a sum-over-rows trace whose per-row cost is dominated by the cubic
cell-moment kernel. The pieces here — AutoOuterSubsampleOptions,
auto_outer_score_subsample, maybe_install_auto_outer_subsample,
and build_outer_score_subsample — implement a stratified
Horvitz–Thompson estimator that replaces the full row sum with an
unbiased sample, gated by
crate::custom_family::BlockwiseFitOptions::auto_outer_subsample
and enabled by default for large marginal-slope fits.
maybe_install_auto_outer_subsample is the entry point family
impls call: it consults the per-family phase counter and the
per-family last-ρ mutex (used to detect distinct outer steps),
installs a stratified mask for the first
BMS_AUTO_SUBSAMPLE_PHASE1_BUDGET (or family analog) outer
evaluations, and reverts to full data afterward so the BFGS/ARC
convergence target outer_tol is reached on exact gradients
rather than chasing the stochastic noise floor.
This subsampling is complementary to the trace-estimator tier
system documented at the top of solver::reml::reml_outer_engine (exact /
Hutchinson multi-target / Hutch++ single-target). They operate on
orthogonal axes — the trace estimators reduce work within the
Hessian structure for a fixed row set; subsampling reduces the row
set itself for the family-specific row-trace path.
Structs§
- Auto
OuterK Choice - Outcome of
AutoOuterSubsampleOptions::target_k_detailed: the chosenK, the underlying noise-only choice, the work-budget cap, and which constraint won. - Auto
Outer Subsample Options - Configuration for the automatic outer-score subsampler.
- Marginal
Slope Exact Newton PsiWorkspace - Generic exact-Newton joint-ψ workspace shared by the marginal-slope
families. Owns the σ-auxiliary dispatch skeleton and delegates every
family-specific operation to its
MarginalSlopePsiFamilyimpl.
Enums§
- Auto
Outer CapReason - Reason the auto schedule chose the reported
K. Used by the[family auto-subsample]log line so operators can tell whether the noise model, the work budget, theMIN_K_FLOOR, ornitself determined the subsample size. - Outer
RowIter - Row-index iteration choice for outer-only score/gradient passes.
Constants§
- AUTO_
OUTER_ MIN_ K_ FLOOR - Absolute floor on
Kchosen by the auto schedule. Even when the work budget would driveKto a handful of rows the stratified mask cannot usefully shrink belowMIN_K_FLOORwithout collapsing entire deciles ofz-strata. Set so the resulting gradient noise (~3 %) is still usable for BFGS Phase 1 progress when the family is very expensive. - AUTO_
OUTER_ WORK_ BUDGET - Half-billion outer-derivative work units per evaluation. Picked so the
rigid survival marginal-slope pilot Newton cycle (which previously ran
~57 min at n≈2e5 with
K=19_661) finishes in a minute or two on commodity hardware onceKis capped by this budget.
Traits§
- Marginal
Slope PsiFamily - Family-specific ψ-calculus hooks for the shared exact-Newton joint-ψ workspace.
Functions§
- add_
scaled_ coeff4 - auto_
outer_ score_ subsample - Build a stratified outer-score subsample automatically from problem
characteristics. Returns
Nonefor problems too small to benefit (the caller should fall back to the full-data path). - bail_
if_ cached_ beta_ non_ finite - Canonical non-finite guard on a cached inner
beta. - build_
outer_ score_ subsample - Build a deterministic stratified row subsample of size ≥
kfrom(z, stratum_secondary). - eval_
coeff4_ at - feasible_
step_ fraction - Shared monotonicity line-search safeguard for time-block linear inequality
constraints
A·beta >= b. - make_
beta_ seed_ validator - Canonical inner-cache
beta_seedvalidator passed to the generic outer-engine (optimize_spatial_length_scale_exact_joint). - maybe_
install_ auto_ outer_ subsample - Two-phase auto-subsample guard shared across marginal-slope families.
- outer_
row_ indices - Choose the row-iteration strategy for an outer-only pass. When
opts.outer_score_subsampleisSome, returns the subsample mask; otherwise returns the full range0..n. - outer_
row_ weights_ by_ index - Dense-by-row HT weights of length
n. Masked rows carry their HT weight; unmasked rows default to 1.0 so that callers who index by row regardless of subsampling still get a valid scalar (the consumer is expected to iterate only overouter_row_indices). - outer_
weighted_ rows - Per-row HT-weighted iteration: returns one
WeightedOuterRowper retained row when a subsample is active; otherwise returns(index, weight = 1.0, stratum = 0)for every row in0..n. - probit_
frailty_ scale - scale_
coeff4