jgrusewski 749fc80edf feat(diag): Phase 2A — health_diag_isv_mirror kernel + GpuHealthDiag orchestrator
Phase 2A of the HEALTH_DIAG GPU port. Lands the simplest member of the
kernel family (single-block single-thread ISV scalar copies) plus the
orchestrator scaffolding (cubin loader, mapped-pinned snapshot owner,
launcher) that subsequent phases will reuse.

Why simplest first: 5 kernels each with different masking semantics
landing in one commit risks silent numerical mismatches that downstream
parsers (aggregate-multi-seed-metrics.py, smoke summarisers) would
mis-parse. Per feedback_no_quickfixes.md, kernel-by-kernel with
parallel-shadow validation. Phase 4 deletes CPU paths in one commit
once all kernels are bit-identical.

What this kernel does: copies 22 ISV signal-bus slots into the matching
HealthDiagSnapshot fields — reward-component EMAs (slots 63-68), VSN
attention focus EMAs (87, 88), target-drift EMAs (92, 93), aux-head
loss EMAs (113, 114, 117), MoE expert utilisation (118-126), gate
entropy (126), and λ_eff (128). 22 of 147 snapshot words populated
(reward_split[6] + noisy_vsn[2] + noisy_drift[2] + aux[3] + aux_moe[10]).
Producer-only — no consumer reads health_diag.snapshot() yet; Phase 3
wires the call site, Phase 4 makes the snapshot the sole emit source.

Architecture rules upheld:
  - No HtoD / DtoH (writes through mapped-pinned device pointer).
  - No atomicAdd (single-thread kernel; family-wide rule for 2B-2E too).
  - No DtoD memcpy on the diag path (kernel pointer-load + store).
  - Kernel WORD-index table inline; static_assert pins WORD_TOTAL=147 in
    lockstep with snapshot_size_is_stable test.
  - ISV indices passed as kernel args (not #define'd) so the kernel
    never embeds the numbering — single source of truth lives in
    gpu_dqn_trainer.rs constants.

Changes:
  - new crates/ml/src/cuda_pipeline/health_diag_kernel.cu (311 lines).
  - new crates/ml/src/cuda_pipeline/gpu_health_diag.rs (190 lines)
    holds GpuHealthDiag orchestrator (cubin module + isv_mirror_kernel
    handle + MappedHealthDiagSnapshot).
  - mod.rs: pub mod gpu_health_diag.
  - build.rs: registers health_diag_kernel.cu in kernels_with_common.
  - gpu_dqn_trainer.rs:
    - imports super::gpu_health_diag::GpuHealthDiag;
    - adds health_diag: Option<GpuHealthDiag> field next to aux_heads_fwd;
    - constructor calls GpuHealthDiag::new() after the cubin loads;
    - adds pub fn launch_health_diag_isv_mirror() (uses compile-time
      ISV index constants, single source of truth);
    - adds pub fn health_diag_snapshot() accessor.
  - docs/health_diag_inventory.md: Phase 2A entry + Phase 4 deletion
    list pinned per Invariant 7.
  - docs/dqn-wire-up-audit.md: new row for health_diag_kernel.cu under
    "CUDA Kernels (.cu files)" — classified Pending wire-up (Phase 3).

Verification:
  - cargo check -p ml: 0 new warnings (12 lib warnings pre-existing,
    none touch health_diag/gpu_health_diag).
  - cargo test -p ml --no-run: clean.
  - cargo test -p ml --lib cuda_pipeline::health_diag::tests: 3/3 pass
    (snapshot_size_is_stable, default_is_zeroed, alignment_is_4_bytes
    — the WORD_TOTAL=147 static_assert in the kernel matches the host
    size_of test bit-for-bit).

Scope discipline (per prompt's "if kernel #3 takes too long, stop"):
This commit lands the orchestrator scaffolding + simplest kernel only.
Phases 2B-2E (eval-histogram, q-mag-reduce, per-sample-reduce,
finalise) intentionally deferred — masking semantics for q_mag_reduce
in particular need careful per-CPU-getter inspection before kernel-side
implementation. Producer-only by design; no production caller of
launch_health_diag_isv_mirror in this commit (matches AuxHeadsForwardOps
landing pattern from Plan 4 Task 6 Commit A).
2026-04-28 23:54:45 +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%