jgrusewski 392fc7d698 feat(sp4): Tasks A10+A11 — wire all 5 SP4 producer launches in training_loop
Layer A: cold-path SP4 producer launches added next to launch_h_s2_rms_ema
and the surrounding ISV producers (mag_concat h_s2_rms_ema, fold_warmup,
iqn_quantile_ema, vsn_mask_ema, aux_heads_loss_ema, moe_expert_util_ema,
moe_lambda_eff_update). All five fire once per training step before the
HEALTH_DIAG line emit per the post-cascade-fix invariant (a5f23b28f).

Producers wired:
  - launch_sp4_target_q_p99               (TARGET_Q_BOUND, slot 131)
  - launch_sp4_atom_pos_p99_all_branches  (ATOM_POS_BOUND[0..4], 132-135)
  - launch_sp4_grad_norm_p99              (GRAD_CLIP_BOUND, slot 168)
  - launch_sp4_h_s2_p99                   (H_S2_BOUND, slot 169)
  - launch_sp4_param_group_oracles_all_groups via build_sp4_aux_buffers
    (WEIGHT/ADAM_M/ADAM_V/WD_RATE × 8 groups + L1_LAMBDA[trunk]; 33 slots)

For param_group_oracles, the SP4AuxBuffers descriptor is built each step
via FusedTrainingCtx::build_sp4_aux_buffers, threading curiosity_weights
and curiosity_trainer through from gpu_experience_collector. To support
that, added GpuExperienceCollector::curiosity_trainer() accessor mirroring
the existing has_curiosity_trainer / curiosity_weight_set pair. When the
collector is absent or curiosity is disabled, the curiosity descriptor
empties and the launcher's count==0 short-circuit silently skips group 7.

All 40 SP4 ISV bound slots are now populated correctly each step via
Pearls A+D (host-side EMA + p99 application). No consumer reads them yet —
Mech 1/2/5/6/9/10 clamps still use SP3 hardcoded multipliers, so behavior
is unchanged. Layer B will wire consumers and may relocate the captured-
graph-eligible producers (target_q_p99 in particular) as part of Mech 1's
pre-clamp ordering.

Each launch uses the same `if let Some(ref fused) = self.fused_ctx` guard
+ tracing::warn-on-error pattern as launch_h_s2_rms_ema. Errors never
propagate (warn-and-continue) since Layer A is observability-only.

cargo check -p ml --lib --tests clean (11 pre-existing warnings).
state_reset_registry suite passes (3/3).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 00:47:49 +02:00

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
No description provided
Readme 849 MiB
Languages
Rust 88.2%
Cuda 7.7%
Python 1.3%
Shell 1.1%
PLpgSQL 0.8%
Other 0.8%