62ab8ed8505f8bdf318dd7941416ba1d0a5cef54
Pure plumbing: threads a new i32 column (aux_sign_labels) through every
layer of the replay path so B1 can wire the aux head's CrossEntropy
classification target without touching any aggregator or batch-shape
contract on its own. No consumer reads the column yet — all labels are
zero-initialized; smoke between B0 and B1 should be bit-identical to
parent 0ad5b6fa4 modulo allocator entropy.
Why split B0 from B1: original Layer B Commit 1 bundled replay plumbing
with the aux head contract change (1->2 dim, MSE->CE, slot 117 retire,
fingerprint bump). Four implementer subagents in a row hit
NEEDS_CONTEXT on brief-accuracy issues — too large for a single
dispatch. Split keeps B0 mechanical and isolates B1 for fresh
implementer with audit-derived brief.
Wiring (data flow):
1. scatter_insert_i32 kernel mirrors scatter_insert_u32 but preserves
-1 sentinels (u32 would alias to 4294967295). gather_i32_scalar at
#18c is symmetric.
2. ReplayKernels.scatter_insert_i32 field + ld() loader.
3. GpuReplayBuffer.aux_sign_labels: CudaSlice<i32> ring [capacity] +
sample_aux_sign_labels: CudaSlice<i32> per-batch gather dst.
4. insert_batch signature gains aux_sign: &CudaSlice<i32>. Body
scatter-launches alongside actions/rewards/dones using same
(ci, cpi, bsi) tuple.
5. sample_proportional Step 3c launches gather_i32_scalar from ring
into sample buffer. Both GpuBatchPtrs return paths set
aux_sign_labels_ptr to sample buffer raw_ptr.
6. GpuBatchPtrs.aux_sign_labels_ptr: u64 publicly exposed.
7. GpuExperienceBatch.aux_sign_labels field — collect_experiences_gpu
alloc_zeros total-sized i32 slice (B1 replaces with producer kernel).
8. Single production caller training_loop.rs:2032 threads through.
Audit-verified call site cardinality (per implementer 4 finding):
- 1 production insert_batch caller (training_loop.rs:2032)
- 1 in-file unit test caller (signature updated)
- 2 GpuBatchPtrs construction sites (both inside sample_proportional)
- 1 GpuExperienceBatch construction site (collect_experiences_gpu)
Implementer 4 caught the over-counted 4 sites claim from the original
brief — the 2 extras were doc-comment references to
insert_batch_with_episode_ids (no separate function exists).
Hard rules upheld:
- feedback_no_partial_refactor: every insert_batch consumer migrates
atomically (1 prod + 1 test, both updated)
- feedback_no_stubs: column carries real data through real kernels;
zero values are valid i32 that B1 overwrites with -1/0/1
- feedback_isv_for_adaptive_bounds: no new ISV slots; slot 117
AUX_LABEL_SCALE_EMA retirement deferred to B1 atomic
- feedback_no_atomicadd: no new producers/reductions
- feedback_cpu_is_read_only: alloc_zeros + scatter + gather all GPU
Build: cargo check --workspace clean in 21s.
Audit: docs/dqn-wire-up-audit.md SP13 Layer B B0 section added with
wiring diagram, call site cardinality table, and B1 next-steps for
fresh-implementer dispatch.
Files: 92 LOC net across 4 source files + audit doc:
- crates/ml-dqn/src/replay_buffer_kernels.cu (+21)
- crates/ml-dqn/src/gpu_replay_buffer.rs (+54)
- crates/ml/src/cuda_pipeline/gpu_experience_collector.rs (+17)
- crates/ml/src/trainers/dqn/trainer/training_loop.rs (+1)
- docs/dqn-wire-up-audit.md (B0 section)
Next: B1 — aux head 1->2 dim, MSE->CE loss, aux_dir_acc reads softmax,
aux_pred_to_isv_tanh logit-diff rewrite, slot 117 retirement,
dqn_param_layout fingerprint bump, kernel populates aux_sign_labels
with real -1/0/1 labels, aux_b1_diag HEALTH_DIAG, 17+ unit tests.
B1 dispatched to fresh implementer with this audit doc as truth-source.
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%