1e35324bf49ca08e8cdb944ff4d7fc32b639a984
HOT sites: - L2992 hindsight bar_indices: was `alloc + memcpy_htod(total i32s)` on every collect_experiences_gpu when hindsight_fraction > 0. Added persistent `bar_indices_pinned: MappedI32Buffer` (capacity = alloc_episodes * alloc_timesteps * 2) allocated at constructor. Per-call host writes go through host_ptr; relabel kernel reads via dev_ptr u64. - L3186 feature_mask: was alloc + memcpy_htod each epoch at t==0. Promoted `feature_mask_buf` to `Option<MappedF32Buffer>`. Reallocates only when mask size changes; CPU writes via host_ptr, state_gather reads via dev_ptr. - L3816 update_per_sample_support: per_sample_support_buf is read-only by the kernel — promoted to MappedF32Buffer (kernel args now dev_ptr u64). per-epoch tile fill becomes a direct host_ptr write. WARM sites: - L3097 episode_starts upload: episode_starts_buf is GPU-mutated by domain_rand_episode_starts so must remain CudaSlice. Stage via MappedI32Buffer + memcpy_dtod_async through new helper `upload_host_to_cuda_i32_via_pinned`. - L2009 upload_expert_actions: promoted expert_actions_gpu from Option<CudaSlice<i32>> to Option<MappedI32Buffer>. Direct host_ptr write replaces alloc + memcpy_htod. COLD sites: - L1076,3848 portfolio_states init/reset (GPU-mutated): use upload_host_to_cuda_f32_via_pinned (mapped-pinned staging + DtoD). - L1093 epoch_state init (GPU-mutated): replace clone_htod_f32 with explicit alloc_zeros + upload_host_to_cuda_f32_via_pinned. - L1341 saboteur_base init (GPU-mutated): use the same helper. - L2784 trade_stats_buf pre-reduction zero: replaced htod_f32 of an all-zeros vec with stream.memset_zeros — fully GPU-side, no PCIe. Imports: added DevicePtrMut for memcpy_dtod_async pointer extraction. Per `feedback_no_partial_refactor.md`, every consumer of the migrated buffers is updated in this commit: - per_sample_support_buf kernel args at L3426 (compute_expected_q) and L3546 (quantile_q_select) now consume dev_ptr u64. - feature_mask_buf accessor at L3195 reads via .dev_ptr. - expert_actions_gpu field type change is contained (no external consumers in this crate). cargo check -p ml --lib: 11 warnings (unchanged from prior commit on this branch; 2 below 13-warning baseline because two unrelated trivial warnings disappeared as a side-effect of the refactor). 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%