jgrusewski dde38d800d feat(dqn-v2): Plan 4 Task 1B-ii — VSN params (24 tensors) + 6 ISV slots (additive)
Per-group VSN MLP parameter tensors and per-group importance-mask EMA ISV
slots land additively — no production callers in this commit. The
forward orchestrator + cuBLAS Linear_1/Linear_2 wire-in lands in 1B-iii;
backward orchestrator + autograd integration lands in 1B-iv.

Param tensors (24 new, indices [95..119)):
  * Per-group quad (`vsn_w1_g{g}`, `vsn_b1_g{g}`, `vsn_w2_g{g}`,
    `vsn_b2_g{g}`) for each `FEATURE_GROUP_RANGES` entry
    (market / ofi / tlob / mtf / portfolio / plan_isv).
  * `VSN_HIDDEN_DIM = 16`. Per-group element count =
    16*group_dim_g + 33; sum = 16*121 + 6*33 = 2134 floats.
  * Xavier init on weights, zero on biases — initial logits ≈ 0 yield
    softmax mask ≈ 1/SL_NUM_FEATURE_GROUPS (uniform cold-start).
  * `NUM_WEIGHT_TENSORS` 95 → 119; `compute_param_sizes()` and
    `xavier_init_params_buf()` rewritten with a runtime per-group loop
    reading `FEATURE_GROUP_RANGES` from `ml_core::state_layout`
    (Task 1A's prerequisite).
  * Adam state, target params, and grad buffers grow automatically
    since their allocations use `compute_total_params(cfg) +
    cutlass_tile_pad`.

ISV slots (6 new, indices [105..111)):
  * `VSN_MASK_GROUP_0_EMA_INDEX = 105` (market) through
    `VSN_MASK_GROUP_5_EMA_INDEX = 110` (plan_isv).
  * Cold-start `1.0 / SL_NUM_FEATURE_GROUPS = 1/6` (uniform prior — no
    group preference at init).
  * FoldReset reapplies the same uniform value at fold boundary; 6 new
    `RegistryEntry` rows + a single dispatch arm in
    `training_loop.rs::reset_named_state` covering all six names.
  * Producer kernel `vsn_mask_ema_update` (1B-i) overwrites these slots
    once the launch site is wired in 1B-iii.

Fingerprint:
  * Pair shifted 103/104 → 111/112; `ISV_TOTAL_DIM` 105 → 113.
  * `layout_fingerprint_seed()` extended with the 6 new ISV slot names
    + 24 new `PARAM_VSN_*` entries terminating at
    `PARAM_TOTAL_TENSORS=119`.
  * New `LAYOUT_FINGERPRINT_CURRENT = 0x1b28321bb816f246`
    (was `0x5789155b683ab59c`). Checkpoint break by intent — fail-fast
    at constructor load on mismatch, no migration path per
    `feedback_no_legacy_aliases.md`.

Cubin refs:
  * `VSN_FEATURE_SELECTION_CUBIN` and `VSN_MASK_EMA_CUBIN` added as
    `pub(crate) static` `#[allow(dead_code)]` byte arrays — the
    `include_bytes!()` runs at compile time, but no `load_cubin(...)` /
    `load_function(...)` call exists yet (deferred to 1B-iii).

Mirrors the 2c.3a pattern (param tensor reshuffle without runtime
callers — that landed cleanly because the runtime sites were panic-
gated; here, the runtime sites simply don't exist yet so no gating
needed).

cargo check clean at 11 warnings (workspace baseline preserved); cargo
build compiles 62/62 cubins clean (unchanged — no new `.cu` files).
Smoke deferred — behaviour byte-identical to the f3e3ac347 /
0x5789155b683ab59c post-bottleneck-fix baseline (700.43s, 3 folds × 5
epochs, per-fold best train Sharpe 6.53 / 80.11 / 66.72, geom-mean
39.27) since no consumer reads the new params or ISV slots; smoke
re-validation lands at 1B-iii.

Audit doc updated.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-25 18:58:01 +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%