Files
foxhunt/crates/ml/tests
jgrusewski cb6a89714b sp7(controller): activation flag + Welford-α to escape bootstrap trap
Fixes the SP7 controller dormancy discovered in smoke-test-8556k:
per-branch budgets stuck at exactly bootstrap constants because the
kernel's cold_start_basis numerically equaled the consumer's bootstrap
fallback, AND the Wiener-α was clamped at ALPHA_FLOOR=1e-4 from step 1.

Architectural change:
- 8 new ISV slots LB_{CQL,C51}_ACTIVE_BASE per (head × branch).
  Activation flag is monotonic per fold, FoldReset on boundary.
- Kernel only sets active=1 when grads are populated AND on subsequent
  active-state computation; cold-start branch leaves active=0 (fresh
  branch) or holds prior budget steady (transient grad gate).
- Consumer dispatches on activation: bootstrap when active<0.5,
  controller verbatim when active>=0.5. No more spurious bootstrap
  when controller writes legitimate small values.
- Welford-α hybrid (max of 1/max(1,epoch_idx_in_fold) and Wiener-α)
  gives full update on first active step, falls off as 1/N until
  Wiener takes over with meaningful variance estimates. EPOCH_IDX_INDEX
  is the existing per-fold-reset counter (no new tuned constants).

State reset registry: 2 new sp7_lb_*_active FoldReset entries +
matching dispatch arms in reset_named_state. Contract test
(every_fold_and_soft_reset_entry_has_dispatch_arm) gates compile.

GPU unit test sp7_loss_balance_controller_activation_flag_transitions
exercises 3 transitions (cold start → both flags 0; active → both
flags 1 with controller-computed budget != bootstrap; transient grad-
gate → flags hold at 1, prior budget held verbatim). Passes on local
RTX 3050 Ti.

Audit doc: Fix 31 sub-bullet describing the activation-flag fix.
Memory pearl out-of-tree (controller will dispatch separately).

Touched:
  crates/ml/src/cuda_pipeline/sp5_isv_slots.rs
  crates/ml/src/cuda_pipeline/loss_balance_controller_kernel.cu
  crates/ml/src/cuda_pipeline/gpu_dqn_trainer.rs
  crates/ml/src/trainers/dqn/fused_training.rs
  crates/ml/src/trainers/dqn/state_reset_registry.rs
  crates/ml/src/trainers/dqn/trainer/training_loop.rs
  crates/ml/tests/sp5_producer_unit_tests.rs
  docs/dqn-wire-up-audit.md

Cargo check workspace clean. Cargo test ml --lib clean (incl. contract
test + 6 sp5_isv_slots tests). 16 pre-existing failures unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 11:34:21 +02:00
..