jgrusewski 920a2d0219 fix(sp10): unconditional Thompson selector + ISV-driven temperature (Fix 38)
T10 train-multi-seed-khr7c (commit 8a25b330f, post-Fix-37) showed val-Flat-
collapse persisting at the eval-side selector despite all SP9 controller
fixes — dir_entropy=0 / trade_count=1 in 214,654 bars because
experience_action_select branched on eval_mode and used argmax(E[Q]) at
eval. With Hold's E[Q] ≈ 0 and directional E[Q] = ε (small edge minus tx
costs), argmax wins Hold deterministically every bar.

Per pearl_thompson_for_distributional_action_selection (amended): the
rollout SELECTOR is unconditional Thompson at all times (training AND
eval); argmax is reserved for the Bellman TARGET Q computation only
(DDQN target). Per pearl_controller_anchors_isv_driven: the temperature
on the Thompson sample is ISV-driven from the SP9 intent_eval_divergence
canary. Per pearl_blend_formulas_must_have_permanent_floor: MIN_TEMP=0.5
is the permanent-stochasticity floor — the eval selector is NEVER fully
deterministic.

Atomic commit per feedback_no_partial_refactor:

* 1 new ISV slot @ [339..340) (EVAL_THOMPSON_TEMP_INDEX); ISV_TOTAL_DIM
  339 → 340; SP5_PRODUCER_COUNT 165 → 166; layout fingerprint updated
* 1 new scratch slot @ [265..266) (SCRATCH_SP10_THOMPSON_TEMP);
  SP5_SCRATCH_TOTAL 265 → 266
* intent_eval_divergence_compute_kernel.cu extended with 2 params
  (divergence_target_isv_index, scratch_temp_idx) + new compute branch
  temp = clamp(divergence/div_target, 0.5, 2.0); existing scratch_idx
  renamed scratch_div_idx for semantic clarity
* experience_action_select: if (eval_mode) { argmax(E[Q]) } DELETED;
  unconditional temperature-blended Thompson installed:
  q_eff[d] = E[Q][d] + temp · (q_sample[d] − E[Q][d]); defensive clamp
  to [0.5, 2.0] for cold-start before producer first observation. Other
  branches (mag/ord/urg) keep their existing eps-greedy/Boltzmann logic
  per pearl_thompson §3 exemption
* state_layout.cuh: new ISV_EVAL_THOMPSON_TEMP_IDX 339 define
* gpu_dqn_trainer.rs::launch_intent_eval_divergence_compute extended
  with 2 kernel args + second apply_pearls_ad_kernel chain to smooth
  the temperature into ISV[339]
* New FoldReset entry sp10_eval_thompson_temp + dispatch arm in
  reset_named_state writing sentinel 0; Pearl A's first-observation
  replacement fires on the new fold's first producer launch
* Test renamed test_eval_action_select_eval_argmax_picks_best →
  test_eval_action_select_thompson_picks_proportionally; ISV buffer
  setup with EVAL_THOMPSON_TEMP_INDEX=1.0 (pure Thompson); assertions
  updated to ≥ 70% best-direction wins (was ≥ 99% under deterministic
  argmax) and < 100% (selector is sampling)
* Pearl pearl_thompson_for_distributional_action_selection §4 amended;
  MEMORY.md index entry updated
* Audit doc Fix 38 entry

Verification:
* SQLX_OFFLINE=true cargo check -p ml — clean (only pre-existing 18
  warnings; no new errors or warnings introduced by Fix 38)
* SQLX_OFFLINE=true cargo test -p ml --lib state_reset — 4/4 pass
  including contract test every_fold_and_soft_reset_entry_has_dispatch_arm
* SQLX_OFFLINE=true cargo test -p ml --lib sp5_isv_slots — 10/10 pass
  including new sp10_thompson_temp_slot_above_sp9_block
* SQLX_OFFLINE=true cargo test -p ml --lib test_eval_action_select_thompson —
  pass (RTX 3050 Ti local; τ=1.0 with clear Q gap → P(Long) ≥ 0.70 < 1.0)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 22:42:25 +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%