Files
foxhunt/crates
jgrusewski 13084f7746 feat(rl): MARGIN adaptive from clip-rate + remove MAX_WIN cap
rdgzl follow-up — chain hypothesis test:
  clip rate stayed at 25-40% across windows (target ~5%)
  win rate oscillated 27-47% with no clear trend
  positive-tail distribution: p50=1.85 p90=10.1 p99=76.9 max=2230
  MAX_WIN=20 hit ceiling in EVERY window (load-bearing cap)
  static MARGIN=1.5 couldn't chase the tail

Two interventions in one commit:

(1) MARGIN is now adaptive in rl_reward_clamp_controller.cu via a
    Schulman bounded-step on clip-rate EMA vs target:
      clip_indicator = (pos_max > current_WIN && pos_max > 0) ? 1 : 0
      clip_rate_ema  = (1-α) * prev + α * indicator   (α=0.05)
      if clip_rate_ema > target × 1.5 → MARGIN *= 1.2 (up to MAX_MARGIN=5)
      if clip_rate_ema < target / 1.5 → MARGIN /= 1.2 (down to MIN_MARGIN=1)
    Target clip rate seeded at 0.05 — accept 5% tail outliers, capture
    the rest. Two new ISV slots (482 clip-rate EMA, 483 target).

(2) MAX_WIN cap REMOVED — the hardcoded ceiling defeated the purpose
    of adaptation. Safety reasoning: WIN = MARGIN × pos_max_ema with
    MARGIN ∈ [1, 5] and pos_max_ema bounded by reward_scale × raw_PnL
    (both finite). MIN_WIN=1.0 floor retained.

Diag exposes clip_rate_ema + reward_clamp_clip_rate_target so the
adaptation loop is observable in the JSONL.

KNOWN DOWNSTREAM CEILING: bellman_target_projection.cu hardcodes C51
atom span at V_MIN=-1.0, V_MAX=+1.0. Any Bellman target outside this
range is categorically clipped regardless of our reward clamp. So
lifting WIN > 1.0 helps V regression + PPO advantage (which see real
magnitude) but Q's distributional learning is structurally capped at
V_MAX=1.0. A separate intervention to lift C51 V_MAX would be needed
to unlock Q's atom-distribution learning beyond +1.0.

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