Files
foxhunt/docs
jgrusewski eca26a1feb fix(dqn-v2): P4T6/P5T5 — ISV-driven aux next-bar label-scale EMA + normalize-before-MSE
Defends the aux next-bar regression head against underlying-data scale.
Label = `next_states[:, 0]` carries log returns (~1e-3) in local fxcache
but raw price (~5000) in the L40S fxcache. First L40S deploy attempt
(workflow `train-multi-seed-7j8zc`) produced `aux next_bar_mse = 2.587e7`
and grad_norm=126,769 because the unnormalised label dominated the
residual; the trunk learned garbage off the corrupted aux-gradient SAXPY.

Per `feedback_adaptive_not_tuned.md` + `feedback_isv_for_adaptive_bounds.md`:
runtime-adaptive ISV-driven EMA normalisation, NOT a tuned constant.

Changes:
- New ISV slot `AUX_LABEL_SCALE_EMA_INDEX=117`; ISV_TOTAL_DIM 117→118.
  FoldReset → 1.0 (multiplicative identity, NOT 0.0). Tail-appended after
  fingerprint slots so the layout grows monotonically.
- New GPU producer kernel `aux_label_scale_ema_update` in
  aux_heads_loss_ema_kernel.cu: single-block 256-thread shmem reduction
  over the just-gathered `aux_nb_label_buf [B]`, EMA-blends `mean(|label|)`
  into ISV[117] at α=0.05.
- `aux_next_bar_loss_reduce` + `aux_next_bar_backward` kernel signatures
  grow `+isv_dev_ptr+isv_label_scale_index` args; both kernels divide
  label by `max(isv[117], 1e-6)` before the residual `(pred - label/scale)`
  so loss + gradient stay unit-scale regardless of underlying data
  magnitude. Graph-capture-stable: ISV device pointer + slot index pair
  are stable; the scalar updates per step via the new producer kernel.
- `aux_heads_forward` Step 2b launches the producer between strided_gather
  and the loss reduce (same captured graph, same stream → ordering
  enforced).
- `aux_heads_backward` reads ISV[117] via the same device pointer.
- HEALTH_DIAG aux line gains `label_scale={:.3e}` 4th field for
  observability.
- state_reset_registry adds `isv_aux_label_scale_ema` FoldReset entry;
  reset_named_state dispatch arm writes 1.0 (not 0.0).
- layout_fingerprint shifts `0x26f7b1deb94cb226` → `0x829bc87b42f2feee`
  (checkpoint-incompatible, no migrator per spec §4.A.2).

Validation:
- cargo check --workspace clean at 11 warnings (workspace baseline preserved).
- multi_fold_convergence smoke (RTX 3050 Ti, 591s): 1 passed.
  - Fold 0: Best Sharpe = -9.7831 (matches seed=42 historical baseline -9.78).
  - Fold 1: Best Sharpe = 65.3679 (within seed-noise of historical 65.96).
  - Fold 2: terminated by regression-detection (avg_grad_norm escalation),
    pre-existing pathology unrelated to aux head — checkpoint saved before
    termination.
- HEALTH_DIAG aux line shows `label_scale=3.59e-2` to `4.35e-2` (matches
  expected log-return mean-abs magnitude); `next_bar_mse=6.29e-2` to
  `4.93e-1` (O(1), the new baseline post-normalisation — was O(1e-4)
  pre-fix as numerical artefact of `pred ≈ 0` − tiny unnormalised label).
  Aux grad_norm contribution stays bounded; explosion in F2 is downstream
  C51/CQL, not aux.

Spec-aligned: aux head still regresses on `next_states[:, 0]` per spec
§4.E.6; the fix is the normalisation, not the source.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-26 15:14:21 +02:00
..