483cef454c639650ebdfd28ae274bb63022d9c4f
Wave 4.2 (ef08611d3) landed cuRAND Kaiming-He weight reset as orphan-
with-tests-only. Phase 3.5.4.c creates the production caller and the
action-selection consumer atomically per spec lines 4346-4448.
Production caller in gpu_experience_collector.rs step 4-pre (BEFORE
experience_action_select):
- fan_in = cfg.adv_h = 128 (CORRECTED from Wave 4.2's audit-doc
error claiming 6528 = adv_h × num_atoms; that's total weight
count of one branch's projection, not per-unit input dim. Per
feedback_trust_code_not_docs the audit-doc error is also fixed
inline in this commit.)
- n_weights = branch_0_size × num_atoms × adv_h = 4 × 51 × 128 =
26112 (default config). Resets last 10% = 2611 directional
advantage-head weights via cuRAND curand_normal × sqrt(2/128) ≈
0.125 stddev (was wrongly documented as 0.0175).
- Branch: w_b0out (directional) only — plasticity is about
escaping stuck-in-flat regimes; targeted at directional choice.
- Seed: mix_seed(Phase-3.5.4.c-unique base) ^ t per-step
deterministic source; same (FOXHUNT_SEED, t) always yields the
same Kaiming-He samples per kernel thread.
- Trainer exposes target via new pub fn sp15_w_b0out_target()
returning (dev_ptr, n_weights, fan_in); collector consumes via
new set_sp15_plasticity_target(); training_loop wires the two.
OR-gate consumer in experience_action_select:
- New kernel arg float plasticity_m_warm threaded into the
cooldown-mask code path.
- Wave 1.B's cooldown_active = (cooldown_remaining > 0) extended
to cooldown_active = (cooldown_remaining > 0) ||
(plasticity_warm_remaining > 0).
- Flat-on-fire-bar detection — option (a), warm ≥ m_warm − 1.5f
per the trigger-then-decrement convention. The kernel sees
warm = m_warm − 1 on the fire bar; subsequent warm-up bars
observe warm ≤ m_warm − 2. New if (plasticity_fire_bar) branch
BEFORE the existing else if (cooldown_active) branch — the
fire-bar gets DIR_FLAT, subsequent warm bars get DIR_HOLD via
the OR-gate cooldown.
Two-step recovery semantics:
- Bar T (fire): plasticity launches → ISV[436]=1, ISV[438]=
m_warm then decrements to m_warm−1. action_select detects
fire-bar → dir_idx = DIR_FLAT.
- Bars T+1..T+M_warm−1 (warm): action_select OR-gate forces
dir_idx = DIR_HOLD.
- Bar T+M_warm: warm transitions to 0, OR-gate inactive, normal
Thompson/argmax resumes.
When the production caller is unwired (test scaffold path):
plasticity_m_warm passes 0.0f, the kernel's fire-bar predicate is
dead (warm == 0 too), and the OR-gate degenerates to cooldown-only
— bit-identical to the pre-3.5.4.c behaviour. Existing 3 SP15
3.5.b/3.5.3.b action_select oracle tests pass unchanged at
m_warm = 0.0f.
New behavioral oracle test plasticity_fires_force_flat_then_cooldown_
holds verifies the full sequence on RTX 3050 Ti with M_warm = 5
(shrunk from production's 200 for test runtime): bar 0 → DIR_FLAT,
bars 1-3 → DIR_HOLD, bar 4 (warm boundary) → DIR_LONG. ISV side-
effects (fired flips 0→1 then debounces, warm decrements with
underflow guard) verified bar-by-bar.
Eval/backtest path passes m_warm = 0.0f because plasticity is a
training-only mechanism (during deterministic eval the weights must
remain frozen at their checkpoint values).
Atomic per feedback_no_partial_refactor: kernel + caller + consumer +
trainer plumbing + 4 launcher-call-site updates (1 production
collector + 1 eval-path + 2 test scaffolds) + new behavioral test +
audit-doc fan_in inline correction + new audit-doc entry all in this
commit. No fallback. SP15 Phase 3.5 recovery-dynamics chain is now
end-to-end production-wired (3.5.2 + 3.5.3 + 3.5.4 + 3.5.4.c +
3.5.5 + 3.5.5.b all firing).
Verified: cargo check -p ml --features cuda clean; cargo check -p ml
--features cuda --tests clean; CUDA_COMPUTE_CAP=86 cargo test -p ml
--test sp15_phase1_oracle_tests --features cuda -- --ignored
--nocapture 34 of 34 SP15 oracle tests green (5 plasticity + 3
action_select + 3 cooldown + 23 others); cargo test -p ml --features
cuda --lib HOLDS the Wave 4.3 baseline (946 pass / 13 fail) on RTX
3050 Ti — no new regressions.
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%