Files
foxhunt/crates/ml
jgrusewski 875f263ec9 feat(bf16): f32 backward dX scratch + bf16 staging — eliminates dX truncation
Backward pass dX computation now uses f32 scratch buffers with bf16
staging for the backward chain. Pattern: f32 GemmEx → relu_mask (f32) →
f32→bf16 cast → next layer reads bf16 dY.

Changes:
- 6 bw_d_h_* scratch buffers: CudaSlice<half::bf16> → CudaSlice<f32>
- New bw_dy_bf16_staging: shared bf16 buffer for layer transitions
- backward_fc_layer dX: gemmex_bf16 → gemmex_bf16_acc_f32 (f32 output)
- launch_dx_only: gemmex_bf16 → gemmex_bf16_acc_f32 (f32 with beta)
- relu_mask_kernel: reads/writes f32 (no bf16 clamp needed)
- f32_to_bf16_cast_kernel: ±500 clamp at type boundary (in backward_kernels.cu)
- cast_dx_to_staging: f32 scratch → bf16 staging per layer
- IQN/ensemble backward: bf16→f32 cast for dX input, f32→bf16 for dY output
- bw_d_h_s2_as_bf16(): attention backward receives bf16 via staging

Hyperparameters updated for f32 Adam:
- learning_rate: 1e-5 → 1e-4 (updates must exceed bf16 shadow step ~1e-3)
- adam_epsilon: 1e-3 → 1e-8 (standard Adam, bf16 workaround no longer needed)
- grad_norm NaN skip kept as defense-in-depth (source still under investigation)

895/895 unit + 359/359 ml-dqn tests pass.
7-11/11 smoke tests (intermittent NaN from unknown source — NOT backward dX).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 12:17:04 +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;