jgrusewski 8aef59f735 fix(dqn): H10 — stable argmax tie-break at eval per Track 1 triage + Task 2.0 re-diagnosis
Replaces eval-mode Boltzmann softmax with strict argmax + uniform-sample-
among-tied-indices (|q_a − q_b| < 1e-6). Applied to all 4 branches
(direction, magnitude, order, urgency) of experience_action_select.
Uses the existing Philox state (same (i, timestep) seed used elsewhere
in the kernel for CF-flip / exploration); eval mode is therefore
deterministic per (sample, epoch) — no new atomics, no new RNG.

Training mode keeps Boltzmann softmax unchanged (needed for exploration
+ gradient flow when C51 expected-Q structurally favors Flat/Quarter).

Root-cause re-diagnosis (commit 7e78bf4f8 + 41b0c559c): Task 2.0
instrumentation + bug fixes revealed Track 1 H4 was a measurement
artefact produced by two silent bugs in per_branch_grad_norms. Real
mag/dir gradient ratio is 50-400× (magnitude over-fed, NOT starved).
The genuine observable problem is H10 — argmax tie-break at eval,
which is what this commit closes.

Why the previous eval-mode Boltzmann collapsed: with Q-range ≪ tau
floor (0.01), softmax was effectively uniform at eval, but cumulative
sampling with a single Philox draw deterministically picked the first
index over every tied bin — hence eval_dist [eq=1.000 eh=0.000 ef=0.000]
across all 20 baseline epochs despite training-mode ent_mag ≈ 0.99.
Strict argmax honours the learned preference where it exists, tie-break
only applies on genuine ties < 1e-6.

Results from 20-epoch smoke (magnitude_distribution):

  Baseline (HEAD pre-fix):
    training dist [dist_q=0.577 dist_h=0.166 dist_f=0.257]
    eval     dist [eq=1.000 eh=0.000 ef=0.000]

  Post-fix (this commit):
    training dist [dist_q=0.577 dist_h=0.166 dist_f=0.257]  (unchanged — eval-only path)
    eval     dist [eq=0.580 eh=0.420 ef=0.000]

  eh + ef = 0.420 ≥ 0.30 regression gate → PASS.

Training-mode distribution is bit-identical as expected: the fix
only touches the eval_mode == 1 branch of experience_action_select.

Regression assertion in magnitude_distribution smoke requires
eh + ef ≥ 0.30 (the production threshold from Task 2.9 §2.9 gate).

Closes Track 1 H10 CONFIRMED verdict. With H4 REJECTED by Task 2.0's
real data, H10 is now Phase 2's primary fix. If future training
regresses this ratio, the fallback is the "delete magnitude branch"
path (H9 spec §5.1 proposed fix — 108 → 36 action space).
2026-04-22 11:24:41 +02:00

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
No description provided
Readme 849 MiB
Languages
Rust 88.2%
Cuda 7.7%
Python 1.3%
Shell 1.1%
PLpgSQL 0.8%
Other 0.8%