Files
foxhunt/crates/ml
jgrusewski 1790a31b66 feat(sp21): T3.1+T3.2 ISV defrost — wr_ema + hold_pct_ema (atomic)
SP21 Tier-3 foundation: defrost two production-frozen ISV slots that
pinned at 0 across every observed training epoch (d7bj7, xmd6b). Both
bugs in the same aggregator kernel, same structural shape: per-step
binary majority-vote indicators feeding fractional EMAs.

T3.1 — WR_EMA defrost (sp20_aggregate_inputs_kernel.cu):
  - was: is_win_out = (2 * wins_count >= closed_count) ? 1 : 0
         binary "majority won this step" indicator
  - now: win_fraction_out = (float)wins_count / (float)closed_count
         fractional in [0, 1]
  - With actual val WR≈0.46, the binary signal was 0 most of the time,
    pinning WR_EMA at 0 across 30+ epochs in xmd6b. EMA now converges
    to population win rate.

T3.2 — HOLD_PCT_EMA defrost (same kernel, same pattern):
  - was: action_is_hold_out = (hold_count * 2 > n_envs) ? 1 : 0
         strict-majority indicator
  - now: hold_fraction_out = (float)hold_count / (float)n_envs
  - Cascade: HOLD_COST_SCALE controller compared hold_pct_ema=0 to
    tgt±0.05, always saw < lower, ramped × 0.95 → clamped at floor
    0.01 (the hold_cost_scale=0.0100 observation in d7bj7 logs).
    T3.5 expected to cascade-fix in next training run.
  - HOLD_REWARD_EMA gate preserves strict-majority semantic via
    hold_fraction > 0.5f test in the consumer kernel.

Atomic across struct fields, kernel logic, Rust mirror, byte
serialization, doc tables, and 4 test files (per
feedback_no_partial_refactor):
  - sp20_aggregate_inputs_kernel.cu (struct + 2 computations)
  - sp20_emas_compute_kernel.cu (struct + reader + gate)
  - sp20_aggregate_inputs.rs (doc table)
  - sp20_emas_compute.rs (Rust struct + serialize + 3 tests)
  - sp20_aggregate_inputs_test.rs (reader sig + 4 test assertions)
  - sp20_emas_compute_test.rs (5 struct literal updates)
  - sp20_phase1_4_wireup_test.rs (HOLD_PCT_EMA expected 0.625)

Verification:
  - cargo check -p ml --tests: passes (warnings only)
  - cargo test -p ml --lib sp20_emas: 6/6 unit tests pass

Pearl candidate: binary-majority aggregator over a fractional
underlying signal cannot serve as input to a fractional-target EMA.
The previous fix (commit 64bbbe418) addressed the per-bar vs segment
predicate at the producer site, but didn't notice the aggregator's
binarization step still collapsed the fraction to {0, 1}. Two bugs
in series, both now resolved.

Plan reference: docs/plans/2026-05-10-sp21-train-eval-coherence-isv-defrost.md
Tiers 3.3-3.6 remaining; T3.5 expected to cascade-fix.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-10 20:13:13 +02:00
..

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 aggregation
  • hyperopt — PSO-based hyperparameter optimization with per-model adapters
  • trainers — unified training loops (DQN, PPO, supervised)
  • inferenceInferenceAdapter trait for prediction
  • checkpoint — model checkpointing and restoration
  • evaluation — walk-forward evaluation pipeline

Usage

use ml::dqn::DQN;
use ml::ppo::PpoTrainer;