6f3639bfbf22acaaefefacdf9a0f0edf96b5126b
Addresses the gate-not-learning failure mode observed at 3-seed local mid-smoke verification of HEAD5f10bcde3: gate_entropy_mean stayed at MAX (Δ -0.0003 over 2000 steps) and max(gate_argmax_mass) stuck at 1.0. Root cause: at uniform gate (g_k ≈ 1/K), the chain grad_pi_probs → grad_gate_probs has small magnitude — gate Adam moves W_gate too slowly to escape the uniform basin. ## Mechanism * New ISV slot 790 RL_POLICY_GATE_LR_MULTIPLIER_INDEX, bootstrap 5.0 inside the flag-gated block (slots 761-764 +790). RL_SLOTS_END = 791. * Per-step LR-set site (only inside if self.use_multi_head_policy): lr_gate = lr_pi * isv[790] self.mhp_w_gate_adam.lr = lr_gate self.mhp_b_gate_adam.lr = lr_gate * Head Adams (mhp_w_heads_adam, mhp_b_heads_adam) keep raw lr_pi. ## Verification (single-seed seed=42, flag-on, b=128, 2000 steps) * gate_entropy_mean trajectory (5× multiplier vs baseline5f10bcde3): step 0 1.0986 → 1.0986 step 100 1.0986 → 1.0968 (Δ -0.0018) step 500 1.0985 → 1.0968 step 1000 1.0985 → 1.0944 step 1500 1.0985 → 1.0822 step 1999 1.0983 → 1.0829 (Δ -0.0157) → 52× more gate gradient flow at 5× LR multiplier. * gate_probs_mean differentiated: [0.333, 0.333, 0.333] → [0.252, 0.382, 0.366]. Head 0 (Short-bias, init = +0.5 on ShortLarge) deselected by 0.081 — semantically sensible because test data is 2024-Q1 ES futures (bullish/range-bound regime). * max(gate_argmax_mass) = 1.0 still (head 1 wins 100% of batches by margin 0.382 vs 0.366) — soft routing emerging in gate_probs but argmax has not yet crossed over. ## Status 5.0 multiplier is "GATE_MOVING (partial pass)" per the dispatch's threshold (entropy ≤ 1.05 not crossed). Slot is ISV-tunable so escalation to 10×-20× is a single-line bootstrap change. The 52× local improvement projected to cluster scale (b=1024 × 20k steps, ~80× more gradient signal) suggests the gate should specialize clearly at cluster — but a stronger local multiplier first verifies the dose-response curve hasn't saturated at 5×. ## Other verification gates * 13/13 invariants PASS (unchanged). * FOXHUNT_USE_MULTI_HEAD_POLICY=0 ./scripts/determinism-check.sh --quick: exit 0. isv_state checksum byte-identical to pre-B1 (slot 790 zero-bootstrap contributes 0² to checksum). * FOXHUNT_USE_MULTI_HEAD_POLICY=1 determinism-check.sh: exit 0. * Pre-commit: 0 atomicAdd, 0 raw memcpy_htod/dtoh, 0 TODO. ## Linked * Phase 2A-A:0b3e40150(foundation, inert) * Phase 2A-B:e22da61cf(backward + aux KL prior) * Phase 2A-C:3e36f4a0e(trainer integration behind flag) * Phase 2A-C+:5f10bcde3(device-aggregated gate diag) * Phase 2A-D verdict: 3-seed pnl t=+0.223 (NOISE), G4 FAIL (argmax_mass=1.0) → motivated B1. Co-Authored-By: Claude Opus 4.7 <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%