cb80b74ce94e7a7417e5ca93937422480d4a3928
Phase 3b builds on Phase 3a (2e4c7ebf6). Adds the α infrastructure to the trainer: 2 new CUBIN statics + 7 new struct fields (W weight + Adam moments + grad accumulator + 3 kernel handles), and the new() constructor's alloc + kernel-load block. α kernels are loaded but NEVER launched yet. Phase 3b is functionally equivalent to Phase 3a at runtime — the loaded kernels are dead code until the captured-graph integration (Phase 3c) lands. Architectural finding deferred to Phase 3c ────────────────────────────────────────── The trainer's dueling head doesn't have a separate Q_dir buffer. The `mag_concat_qdir` kernel (gpu_dqn_trainer.rs:9884) computes Q_dir INTERNALLY from on_v_logits_buf + on_b_logits_buf (V + A dueling combine: Q[a] = V + (A[a] - mean(A)) per atom), then immediately concatenates the result with h_s2 in one fused pass. There's no intermediate buffer between "Q_dir computed" and "Q_dir consumed" where α could inject as a parallel skip connection. Two options for α integration (Phase 3c will pick): 1. Modify mag_concat_qdir to take W_aux + state_121 args and apply the α bias to its internal Q_dir computation before concat. Invasive — changes a load-bearing kernel. 2. Add a NEW α-precompute kernel: write Q_dir into a dedicated buffer (V + A combine), then mag_concat_qdir reads from that buffer instead of doing the combine inline. Refactors the dueling head's forward — cleaner separation, bigger change. Phase 3b commits the α infrastructure so Phase 3c can focus solely on the captured-graph integration design choice without also needing to allocate buffers + load kernels. Files ───── - crates/ml/src/cuda_pipeline/gpu_dqn_trainer.rs: + pub(crate) static SP22_AUX_TO_Q_DIR_BIAS_CUBIN + pub(crate) static SP22_AUX_TO_Q_DIR_BIAS_BWD_CUBIN + 7 struct fields: w_aux_to_q_dir, adam_m_w_aux, adam_v_w_aux, dw_aux_buf, aux_to_q_dir_bias_kernel, aux_to_q_dir_bias_backward_dw_kernel, aux_to_q_dir_bias_backward_dstate_kernel + new() block: alloc 4 zero-init f32 buffers (b0_size=4) for W + Adam moments + grad accumulator; load 2 cubins, 3 function handles. + Struct construction list extended with 7 new fields. - docs/dqn-wire-up-audit.md: Phase 3b entry documenting the architectural finding + Phase 3c scope. Verification ──────────── - cargo check -p ml --features cuda: 0 errors, 21 pre-existing warnings (Phase 2/3a baseline parity). - nvcc cubins unchanged (kernels built in Phase A). - Runtime equivalent to Phase 3a: α kernels never launched. Phase 3c scope (remaining for full α activation) ──────────────────────────────────────────────── - Pick option 1 or 2 for mag_concat_qdir integration. - Wire α forward in training captured forward graph (Step 7). - Wire α backward kernels in captured backward graph (Step 8). - Wire α Adam-step update (Step 9). - C1: α forward in collector's rollout-time captured graph. - D1-D7: A2 eval-side aux trunk + α + state-gather wiring. - B6: SP11 controller extension for non-zero scale_β. - B7/B10/B11: HEALTH_DIAG telemetry extensions. - E + F: verification gates + atomic Phase F commit + smoke + verdict. Estimated remaining: ~20-30 hr engineering + ~37 min smoke wall-clock. Refs ──── - docs/plans/2026-05-12-sp22-h6-phase3-alpha-beta.md (spec) - docs/plans/2026-05-13-sp22-h6-phase3-alpha-beta-runbook.md (runbook) -464bc5f7a(Phase A foundation) -2e4c7ebf6(Phase 3a — 7-component contract + β producer) - pearl_no_partial_refactor (Phase 3b is additive struct fields) 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%