L40S 15-epoch repro #2 (train-multi-seed-kdkdv) revealed train_loss exploded 1000-2000× in fold 1 (3.1 → 318k-694k) while val Sharpe stayed healthy and CLIMBING (73 → 114). Train/val disconnect = pure measurement bug, not real instability. Mechanism: reset_for_fold() zeroed cached_iqr/cached_median at every fold boundary. The `if cached_iqr > 0.0` guard at fused_training.rs:1220 then forced fold N+1's first epoch to the Welford GPU path. Welford running stats inherited from fold N, combined with fold N+1's slightly different reward distribution post-S&P + adversarial regime, produced normalized rewards far outside C51 atom support [-50, 50] — categorical loss readings 10^5x inflated. On rare timing-sensitive paths the near-zero divide overflowed to Inf → NaN (the run-1 flagged=[2=on_b_logits, 3=mse_loss, 6=grad_buf, 7=save_current_lp, 8=save_projected] diagnostic — what we caught was downstream of THIS root cause). The diagnostic infrastructure from756b1ef31+32e5375acworked perfectly: its precise signal of "on_v_logits clean, on_b_logits NaN, but loss is also NaN, params clean pre-forward" surfaced the train/val disconnect that pointed at the reward normalization bug. Fix A (carry-forward, fused_training.rs:919-922): Stop resetting cached_iqr / cached_median at fold boundary. Carry fold N's final-epoch median/IQR forward as fold N+1's epoch-1 default. Same instrument, similar reward distribution between adjacent walk-forward folds, so the carry is safe and gets replaced by fresh stats at the end of fold N+1's epoch 1. prev_popart_var still resets (sole consumer is tau-change detection; a fresh fold counts as a change point regardless). Fix B (permanent floor, dqn_utility_kernels.cu:1657): Raise iqr fmaxf floor 1e-6 → 1e-4. With iqr=1e-6 a trade-exit reward of 5.0 normalizes to 5e6 (vs post-fix 5e4) — much harder to hit fp32 overflow. Defensive bound for genuinely-pathological iqr paths (e.g. genuinely degenerate data quantiles), not a tuned knob — Invariant 1 carve-out for numerical-stability bounds. Per pearl_blend_formulas_must_have_permanent_floor.md (the same recipe that resolved Kelly cap warmup + var_scale collapse before). Resolves task #84 ("Fold-boundary state reset gap causes fold 1 grad explosion").
ml
10-model ML ensemble for the Foxhunt HFT system, built on Candle v0.9.1.
Models
- DQN (Rainbow) — deep Q-network with prioritized replay, dueling heads, noisy nets
- PPO — proximal policy optimization with GAE, LSTM policies, clip-higher
- TFT — temporal fusion transformer for multi-horizon forecasting
- Mamba2 — state space model for sequence prediction
- Liquid Networks — biologically inspired networks for non-stationary data
- TLOB — transformer-based limit order book analysis
- KAN — Kolmogorov-Arnold networks
- xLSTM — extended LSTM architecture
- TGGN — temporal graph neural network
- Diffusion — diffusion-based generative model
Key Modules
ensemble— model ensemble coordination and confidence aggregationhyperopt— PSO-based hyperparameter optimization with per-model adapterstrainers— unified training loops (DQN, PPO, supervised)inference—InferenceAdaptertrait for predictioncheckpoint— model checkpointing and restorationevaluation— walk-forward evaluation pipeline
Usage
use ml::dqn::DQN;
use ml::ppo::PpoTrainer;