eb0e4b6328561cdaad83c00c4992ff89ebb4c27f
Eliminates ALL per-step allocations from the training hot path — foundation for CUDA Graph capture (next commit). Before this commit, each step_batched call allocated: Mamba2 forward: input_2d view, x, a_proj, b_proj, h_s2, h_enriched_seq Mamba2 backward: d_a_per_channel/d_b_per_channel/d_w_c/d_h_s2 (#2 covered) d_a_proj_flat, d_b_proj_flat, dw_c LinearGrads.{dw,db,dx} × 3 projections (cuBLAS internal) d_x_from_a + d_x_from_b + d_x (elementwise add) dw_out, db_out (zero-init shells) Trainer wrapper: window_tensor, h_enriched_seq_t, grad_h_enriched_seq_t, grad_h_enriched_seq ~20-25 cudaMalloc / GpuTensor::zeros calls per step × 2000 steps/epoch = 40-50K allocations per epoch. This commit adds zero-alloc `_into` variants throughout the chain: ml-core/cuda_autograd/linear.rs: OwnedGpuLinear::forward_with_slices_into OwnedGpuLinear::backward_with_slices_into reduce_sum_axis0_into ml-core/cuda_autograd/elementwise.rs + gpu_tensor.rs: ElementwiseKernels::binary_into GpuTensor::add_into ml-alpha/mamba2_block.rs: Mamba2BlockForwardScratch (pre-allocated forward cache) Mamba2BackwardGradsBuffers (pre-allocated backward outputs) Mamba2Block::forward_train_seq_into (zero-alloc forward) Mamba2Block::backward_from_h_enriched_seq_full_into (zero-alloc backward) Mamba2AdamW::step_from_buffers (reads grads_buffers directly) ml-alpha/trainer/perception.rs: PerceptionTrainer pre-allocates: window_tensor_d, h_enriched_seq_t_d, grad_h_enriched_seq_t_d, grad_h_enriched_seq_d, mamba2_fwd_scratch, mamba2_grads_buffers step_batched + evaluate_batched fully wired through _into variants Original `forward_with_slices` / `backward_with_slices` / `binary` / `add` / `backward_from_h_enriched_seq` paths preserved unchanged — Phase E.3 ml/examples callers unaffected. The captured-graph commit (next) only needs to wrap this zero-alloc training step in cuGraph capture/replay; no further refactoring of buffer management. 77 ml-alpha tests pass. Synthetic overfit converges identically (0.29 → 0.0007 in 250 steps) — gradients are bit-identical to the allocating path. 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%