Cascaded Online Self-Learning Residual Refiner
Cascaded Global Online Adaptive Filter (single-model RLS) and Clustered State-Dependent Self-Learning (libgric) on top of Fixed-Basis Block-EOF.
Overview & Role
Runs strictly as a bounded residual refiner cascaded on top of Fixed-Basis Block-EOF (u_total = u_EOF + delta_u_global + delta_u_cluster) inside cacao-fpsexec-cacaopc-selflearn. Layer 1 (SL/GLOBAL, Global Online Adaptive Filter) learns a single continuously updated per-mode RLS residual model shared across all operating states; Layer 2 (SL/CLUST, Clustered State-Dependent Self-Learning) uses online libgric clustering (K <= 12 state clusters) to track regime-dependent nonlinear optical-gain distortion (unmodulated PyWFS) and changing vibrations without forgetting prior regimes.
Every residual layer is guarded by an independent causal James-Stein shrinkage gate computed from rolling out-of-sample prediction error. On the 40 nm pure white-noise null test, both gates close to 0.00 / 0.00, leaking only 1.43 nm RMS DM noise (1.000x null amplification) — in stark contrast to standalone self-learning without Block-EOF, which degrades pure turbulence (33.5 vs 19.2 nm) and leaks 18.35 nm (1.10x noise amplification). Must remain in the fixed outer modal basis.
Compute Units / Entry Points: cacao-fpsexec-cacaopc-selflearnselflearn_core.clibgric
Verified Highlights:
- Unmodulated PyWFS residual: 16.16 -> 10.27 nm (-36.4% vs Fixed EOF); Combined OG+Vib stress: 33.46 -> 27.06 nm (-19.1%)
- Pure 40 nm white-noise null safety: 1.43 nm DM leakage (1.000x, Stein gates 0.00/0.00) vs 18.35 nm (1.10x) standalone
- Full decoupled RT CPU budget: 88.9 us @ 128 modes (17.8% of 2 kHz) and 113.9 us @ 256 modes (22.8%)
Option Variants (CODE/OPT)
| Option Code | Behavior & Usage | Main Flags |
|---|---|---|
SL/GLOBAL | Global Online Adaptive Filter (single-model K=1 RLS + causal Stein gate) cascaded on Block-EOF for fast tracking of global gain drift and shared dynamics. | --predictive --pf-mode |
SL/CLUST | Clustered State-Dependent Self-Learning (libgric K<=12 clusters + per-cluster RLS + causal Stein gates) cascaded on top of Global Online Adaptive Filter. | --predictive --pf-mode |
Dependencies & Calibration Chain
CLI Flags, Environment Variables & FPS Parameters
| Layer | Option (Links to Reference) | Default | Description |
|---|---|---|---|
| CLI Flag | --predictive | OFF | Enable PSOL predictive control on Stage 1 (AO3k) and Stage 2 (SCExAO) |
| CLI Flag | --pf-mode | ar | Predictive filter architecture: ar (diagonal) or eof (block cross-mode) |
| CACAO_* Env | CACAO_SELFLEARN_ENABLE | 0 | Cascade cacaopc-selflearn (Global + Clustered libgric RLS) downstream of applyEOFPF (0/1) |
| CACAO_* Env | CACAO_SELFLEARN_MODES | 128 | Maximum modal dimension tweaked by cacaopc-selflearn |
| CACAO_* Env | CACAO_SELFLEARN_KMAX | 16 | Maximum libgric cluster anchors maintained by cacaopc-selflearn |
| CACAO_* Env | CACAO_SELFLEARN_KEYMODE | 0 | GRIC state key mode (0=TT2_E2, 1=E1, 2=WFS_LO4, 3=TT2_DM2_E2, 4=REGIME) |
| CACAO_* Env | CACAO_SELFLEARN_QSHARED | 2 | Shared low-order cross-mode feature count in cacaopc-selflearn (0..8) |
| CACAO_* Env | CACAO_SELFLEARN_RLIM | 2.0 | GRIC cluster spawn radius in standardized key space |
| CACAO_* Env | CACAO_SELFLEARN_MAX_WFS_GAIN | 0.40 | Physical stability cap on learned WFS optical-gain weight |
| CACAO_* Env | CACAO_SELFLEARN_LAM0 | 20.0 | Level-0 global online RLS ridge regularization in cacaopc-selflearn |
| CACAO_* Env | CACAO_SELFLEARN_LAM1 | 200.0 | Level-1 per-cluster RLS shrinkage ridge in cacaopc-selflearn |
| CACAO_* Env | CACAO_SELFLEARN_MAX_TWEAK | 0.25 | Hard per-mode absolute tweak clamp [modal units] in cacaopc-selflearn |
| CACAO_* Env | CACAO_SELFLEARN_NWARMUP | 40 | Per-cluster shrinkage warmup frame count in cacaopc-selflearn |
| CACAO_* Env | CACAO_SELFLEARN_KEYWARMUP | 200 | Key standardization warmup frame count in cacaopc-selflearn |
| CACAO_* Env | CACAO_SELFLEARN_NL_MODE | 0 | Nonlinear PyWFS basis (0=linear, 1=+odd sat/OG/TT, 2=+shared WFS xtalk) |
| CACAO_* Env | CACAO_PF_MODE | ar | Predictive filter mode: 'ar' (diagonal AR) or 'eof' (block cross-mode EOF) |
| CACAO_* Env | CACAO_PF_BLOCKSIZE | 128 | Block-EOF coupled modal block size B |
| CACAO_* Env | CACAO_PF_ORDER | 8 | Predictive filter temporal tap lookback order P |
| FPS (cacao) | selflearn.inbasePF | — | optional external Stage-1 PF prediction stream |
| FPS (cacao) | selflearn.nl_mode | 0 | 0=linear phi, 1=+odd PyWFS NL terms, 2=+shared WFS xtalk |
| FPS (cacao) | selflearn.key_mode | 0 | 0=TT2_E2, 1=E1, 2=WFS_LO4, 3=TT2_DM2_E2, 4=REGIME, 5=EXT |
| FPS (cacao) | selflearn.NBmodeMax | 64 | max modal dimension tweaked |
| FPS (cacao) | selflearn.kmax | 16 | max GRIC cluster anchors (1..64) |
| FPS (cacao) | selflearn.rlim | 2.0 | GRIC cluster spawn radius in standardized key space |
| FPS (cacao) | selflearn.lam0 | 20.0 | Level-0 global RLS prior ridge |
| FPS (cacao) | selflearn.lam1 | 200.0 | Level-1 per-cluster RLS prior ridge |
| FPS (cacao) | selflearn.gamma0 | 0.998 | Level-0 RLS exponential forgetting factor |
| FPS (cacao) | selflearn.gamma1 | 0.995 | Level-1 RLS exponential forgetting factor |
| FPS (cacao) | selflearn.gate_eta | 0.995 | causal OOS Stein gate EMA decay |
| FPS (cacao) | selflearn.max_wfs_gain | 0.5 | physical stability cap on WFS weight |
| FPS (cacao) | selflearn.max_tweak | 0.25 | hard per-mode absolute tweak clamp [modal units] |
| FPS (cacao) | selflearn.shadow | OFF | shadow mode: learn & score OOS without applying tweak |
| FPS (cacao) | selflearn.enable_l0 | ON | apply Level-0 global online RLS correction |
| FPS (cacao) | selflearn.enable_l1 | ON | apply Level-1 GRIC cluster-specific correction |
| FPS (cacao) | selflearn.apply_gain | 1.0 | live scalar blend multiplier [0..1] on tweak |
| FPS (cacao) | selflearn.out.alpha_l0 | 0.0 | live causal OOS Stein gate for Level 0 [0..1] |
| FPS (cacao) | selflearn.out.alpha_l1 | 0.0 | live causal OOS Stein gate for Level 1 [0..1] |
Implementation, Tests & Related Reports
Source Files
- cacao:
AOloopControl_PredictiveControl/AOloopControl_PredictiveControl_selflearn.c - cacao:
AOloopControl_PredictiveControl/selflearn_core.c
Verification Tests
test_17_selflearn.pyOffline 7-regime + white-noise null + RT CPU benchmark
Related Staged Technical Reports
- Unified AO Real-Time Control Architecture: Taxonomy, Decoupled Synthesis, White-Noise Safety & Faint-Star Multi-Rate DM Control
- Implementation Plan: Unified AO Real-Time Control Architecture (milk, cacao, milk-mltools)
- Predictive Control Report: Per-Mode Diagonal AR(4..64) & Full Cross-Mode Block-EOF (VAR) Study