5608b866b697d55549f67674db13a8a7c02b2308
Continuation of SP14 B.11 cadence fix (commit 200f05fce). The same per-
epoch staleness bug affected 4 additional producers whose docstrings
explicitly claim "per-step" cadence but whose launches lived in
`process_epoch_boundary` (fires once per epoch at line ~780):
* launch_h_s2_rms_ema → ISV[H_S2_RMS_EMA_INDEX=96]
* launch_fold_warmup_factor → ISV[FOLD_WARMUP_FACTOR_INDEX=130]
* launch_moe_expert_util_ema → ISV[MOE_EXPERT_UTIL_EMA_BASE..+8) +
ISV[MOE_GATE_ENTROPY_EMA_INDEX=126]
* launch_moe_lambda_eff_update → ISV[MOE_LAMBDA_EFF_INDEX=128]
Each producer's per-step consumer reads the ISV slot every training
step (thousands per epoch). With the producers stuck per-epoch, consumers
saw (steps_per_epoch − 1)-step-stale values — exactly the failure mode
SP14 B.11 documented for ALPHA_GRAD_SMOOTHED. Verified consumers:
* h_s2_rms_ema → mag_concat_kernel (forward graph) +
dqn_clamp_finite_f32_kernel (cuBLAS backward IQN-trunk sanitiser
bound = 1e6 × ISV[96])
* fold_warmup_factor → training_loop.rs:2662 per-step host read
deriving lr_eff and clip_eff
* moe_expert_util/entropy → consumed by launch_moe_lambda_eff_update
immediately below (same step)
* moe_lambda_eff → moe_load_balance_loss kernel reads ISV[128] per
step at gpu_dqn_trainer.rs:16864
Atomic migration per `feedback_no_partial_refactor`. Producers leaving
process_epoch_boundary are replaced with one-line redirect comments
pointing to the new hook. Ordering dependencies preserved
(launch_moe_lambda_eff_update still runs AFTER launch_moe_expert_util_ema
per the kernel docstring at gpu_dqn_trainer.rs:16962). All 4 launchers
use pre-loaded CudaFunction fields (gpu_dqn_trainer.rs:12646, 30983,
16901, 16969) — graph-capture safe per
`pearl_no_host_branches_in_captured_graph`.
Cold-start ordering: h_s2_rms_ema reads `save_h_s2` populated by THIS
step's online forward (forward_child runs BEFORE aux_child per
`capture_training_graph`). MoE producer reads `moe_gate_softmax_buf`
populated by `launch_moe_forward` (in `submit_forward_ops_main`,
forward_child). Both inputs are valid by the time submit_aux_ops runs.
State-reset registry coverage already in place
(state_reset_registry.rs:304/427/380/387/398/442 — isv_h_s2_rms_ema,
isv_fold_warmup_factor, isv_moe_expert_util_ema, isv_moe_gate_entropy_ema,
isv_moe_lambda_eff, isv_grad_norm_fast_ema). HEALTH_DIAG read points
unchanged — per-epoch reads of per-step-updated slots get the latest
value (strict improvement over per-epoch reads of per-epoch-stale slots).
Producers DELIBERATELY KEPT per-epoch (audit trail):
Collector EMAs (input data only updates per-epoch — running per-step
computes the same EMA repeatedly off the same data):
* launch_trade_attempt_rate_ema_inplace
* launch_plan_threshold_update_inplace
* launch_seed_step_counter_update_inplace
* launch_cql_alpha_seed_update_inplace
HEALTH_DIAG-only consumers (no per-step kernel reads these slots):
* launch_iqn_quantile_ema (ISV[99..103))
* launch_vsn_mask_ema (ISV[105..111))
* launch_aux_heads_loss_ema (ISV[113], ISV[114])
DEFERRED follow-up (NOT changed in this commit per the user-specified
strict heuristic "docstring per-step + per-step consumer ⇒ migrate";
docstrings of the SP4/SP5 producers below don't explicitly claim
per-step cadence — they're silent — so they fall outside the heuristic
even though their consumers ARE per-step):
* launch_sp4_target_q_p99 + atom_pos_p99 + grad_norm_p99 + h_s2_p99
* launch_sp4_param_group_oracles_all_groups
(consumed by `read_group_adam_bounds` per-step in submit_aux_ops)
* launch_sp5_pearl_1_atom + pearl_3_sigma + pearl_2_budget +
pearl_4_adam_hparams + pearl_5_iqn_tau + pearl_8_trail +
pearl_1_ext_num_atoms
* launch_max_budget_compute + launch_loss_balance_controller (SP7/SP8)
This staleness will be addressed in a follow-up audit pass; for now the
SP4/SP5 epoch-block producers stay where they are.
Verification:
* SQLX_OFFLINE=true CUDA_COMPUTE_CAP=86 cargo check -p ml --tests
--all-targets clean (only pre-existing unused-var warnings).
* sp14_oracle_tests 6/6 pass (alpha_grad_adaptive_beta,
alpha_grad_schmitt_hysteresis, dir_concat_qaux_correct,
gradient_hack_circuit_breaker_fires,
q_disagreement_all_hold_no_contribution, q_disagreement_k4_k2_mapping).
* HEALTH_DIAG validation pending L40S re-dispatch.
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%