Files
foxhunt/crates/ml-alpha/examples
jgrusewski 644fbe0348 fix(rl): ISV-driven K-loop divisor + max ceiling (slot 450, 451)
f2ggr confirmed K-loop wiring works mechanically but K=8 firing on
22 % of steps over-trained at b_size=1: KL excursions to 12.44
(vs prior 3.4e-4), policy overshoot, reward/trade -$0.585 → -$0.723.

Per `feedback_isv_for_adaptive_bounds` the K-loop config must live
in ISV, not as hardcoded values in the trainer. Two new slots:

  RL_K_LOOP_DIVISOR_INDEX (450) — divides n_rollout_steps to get K
                                  Default 2048 (matches ROLLOUT_BOOTSTRAP
                                  so K=1 at controller bootstrap)
  RL_K_LOOP_MAX_INDEX     (451) — clamp ceiling on K
                                  Default 4 (was hardcoded 8; halved
                                  to prevent gradient overtraining)

K computation in step_with_lobsim now reads both from ISV:
  K = clamp(isv[404] / isv[450], 1, isv[451])

Halves worst-case overtraining while preserving the controller
cascade activation (KL above noise floor, ε actively adapting,
ratio_clamp firing). Distribution shifts from K=8 @ 22% → K=4 @ 22%
(half the gradient updates in the high-noise case).

## Wiring

`rl_streaming_clamp_init.cu` extended to seed 5 ISV-resident design
constants (was 3): adv_var_clamp, td_kurt_clamp, adv_var_target,
k_loop_divisor, k_loop_max. Still one kernel call, no HtoD.

## Diag bake-in

JSONL `k_updates` field replaced with `k_loop` block:
  k_loop.k_updates  — actual K used this step
  k_loop.divisor    — current divisor (reads isv[450])
  k_loop.max        — current max (reads isv[451])

Post-hoc analysis can verify the K-computation by independently
recomputing K from isv[404] / k_loop.divisor.

## Slot allocation

RL_SLOTS_END: 450 → 452 (+2 new config slots).

## Test updates

G1 + G3 skip slots 450, 451 in sentinel-zero loop and assert seeded
values (2048.0 + 4.0) separately.

## Verified gates (local sm_86)

  G1 isv_bootstrap   
  G3 controllers     
  G4 target_update   
  integrated_smoke   

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 00:23:38 +02:00
..