a894eca98fc506544788d2934ca7a8c38c314afa
The IQN readiness gauge on `GpuDqnTrainer` is a streaming improvement fraction `(iqn_loss_initial - iqn_loss_ema) / iqn_loss_initial` (gpu_dqn_trainer.rs:5805-5818). `iqn_loss_initial` is captured once on the first `update_iqn_readiness` call where it is still ~0 and never resets — across folds it stays pinned to the fold-0 epoch-1 IQN loss. The pinned device-mapped readiness slot is read by `c51_loss_kernel` as the CVaR α and by IQN gradient-weight gating, so a stale anchor either pins readiness near 1 (over-confident, full IQN gradient weight on a still-recovering head) or near 0 (under-weighting a converged head). Fix: - New `pub fn reset_iqn_readiness_state` on `GpuDqnTrainer` zeroes the three coupled scalars (iqn_loss_initial / iqn_loss_ema / iqn_readiness) and writes 0.0 through the device-mapped pinned host slot — no HtoD copy, the mapping propagates the host write directly. - New `pub(crate) fn reset_iqn_readiness_state` wrapper on `FusedTrainingCtx` mirrors the existing `reset_eval_v_range_state` pattern. - Three new `FoldReset` registry entries (`isv_iqn_loss_initial`, `isv_iqn_loss_ema`, `isv_iqn_readiness`) dispatch through one match arm in `reset_named_state` (training_loop.rs). `update_iqn_readiness` already handles `iqn_loss_initial < 1e-12` as the bootstrap branch, so the new fold's first batch is recaptured as the anchor on the first call after reset, by design. Per `feedback_no_partial_refactor.md` — same fold-boundary state-migration contract, all three coupled scalars migrate together. This commit completes the 3-fix sequence (Fix 1 IQN target sync, Fix 2 aux Adam states, Fix 3 IQN readiness) closing the fold-boundary contract gap surfaced by the audit. Bug signature being resolved: F0 ep5 Q=+0.79 (healthy) F1 ep1 Q=+0.82 (boundary fine; c51_alpha warmup blends IQN low) F1 ep2 Q=+2.23 (drift starts — IQN online↔target gap widens) F1 ep3 Q=+4.05 F1 ep4 Q=+10.66 (geometric ~2.3×/epoch) F1 ep5 NaN at step 5 (fp32 overflow past atom support) Fix 1 (IQN target sync) is the load-bearing fix for the geometric drift itself; Fix 2 prevents first-epoch Adam-step overshoot in seven aux optimizers; Fix 3 closes the gauge-staleness path. cargo check -p ml --lib clean at 13 warnings (workspace baseline). cargo test -p ml --lib --no-run clean. All three existing `state_reset_registry::tests` pass without modification. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Foxhunt
Production HFT trading system in Rust.
Architecture
The workspace contains 32 crates organized as follows:
Core Libraries (16)
| Crate | Purpose |
|---|---|
trading_engine |
Order processing, FIX 4.4, IB TWS, SIMD, RDTSC timing |
risk |
VaR, Kelly, circuit breakers, kill switches, compliance |
risk-data |
Risk data types and shared structures |
trading-data |
Trading data types |
ml |
DQN Rainbow, PPO, TFT, Mamba2, ensemble inference |
ml-data |
ML data types and feature definitions |
data |
Market data ingestion and storage |
backtesting |
Replay engine, strategy tester |
adaptive-strategy |
Ensemble execution, microstructure analysis |
common |
Shared types, resilience, error handling |
storage |
S3 and local model storage |
model_loader |
Model serialization and loading |
market-data |
Market data feed handlers |
database |
PostgreSQL access layer (SQLx) |
config |
Configuration management |
tli |
CLI commands and tooling |
Services (8)
| Service | Purpose |
|---|---|
backtesting_service |
gRPC backtesting service |
broker_gateway_service |
FIX routing, broker connectivity |
trading_service |
Core trading operations |
ml_training_service |
Model training orchestration |
data_acquisition_service |
Market data acquisition |
trading_agent_service |
Autonomous trading agents |
api_gateway |
gRPC API gateway with auth |
web-gateway |
Axum REST + WebSocket gateway |
Frontend
web-dashboard/ -- React 19 + TypeScript + Vite + TradingView charts.
Building
# Check compilation (no PostgreSQL required)
SQLX_OFFLINE=true cargo check --workspace
# Run tests for a specific crate
SQLX_OFFLINE=true cargo test -p <crate> --lib
# Clippy
SQLX_OFFLINE=true cargo clippy --workspace
ML Models
Four production model architectures on Candle v0.9.1 with CUDA:
- DQN Rainbow -- Deep Q-Network with prioritized replay, dueling heads, noisy nets
- PPO -- Proximal Policy Optimization with GAE and LSTM policies
- TFT -- Temporal Fusion Transformer for multi-horizon forecasting
- Mamba2 -- State space model for sequence prediction
Each model has a standalone trainer and a UnifiedTrainable adapter for the hyperopt pipeline.
Infrastructure
- Git: Gitea at
git.fxhnt.ai(Tailscale-only), Scaleway DEV1-S - Observability: OpenTelemetry OTLP (env
OTEL_EXPORTER_OTLP_ENDPOINT) - Database: PostgreSQL with SQLx offline mode for CI
License
Proprietary. All rights reserved.
Description
Languages
Rust
88.2%
Cuda
7.7%
Python
1.3%
Shell
1.1%
PLpgSQL
0.8%
Other
0.8%