Root cause: `SMOKE_CUDA: OnceLock<MlDevice>` held a static Arc<CudaContext> for the process lifetime. CudaSlice Drop from test N recorded errors on this shared context's error_state, causing test N+1's bind_to_thread() to fail with CUDA_ERROR_INVALID_VALUE. Fix: create a fresh MlDevice per test (no static caching). Each test gets its own CudaContext Arc with clean error_state. Also: convert all GPU smoke tests from #[tokio::test] to synchronous #[test] with explicit tokio::runtime::Builder::new_current_thread(). The runtime is explicitly dropped between tests, ensuring all Arc<CudaContext> refs are freed. Result: 5 of 6 sequential smoke tests now pass. The remaining 1 failure is a real Candle GpuTensor bug: the replay buffer insertion path still uses Candle's elementwise kernels, which cache CudaFunction handles that become stale across test boundaries. Fix: eliminate Candle from replay buffer path. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ml
10-model ML ensemble for the Foxhunt HFT system, built on Candle v0.9.1.
Models
- DQN (Rainbow) — deep Q-network with prioritized replay, dueling heads, noisy nets
- PPO — proximal policy optimization with GAE, LSTM policies, clip-higher
- TFT — temporal fusion transformer for multi-horizon forecasting
- Mamba2 — state space model for sequence prediction
- Liquid Networks — biologically inspired networks for non-stationary data
- TLOB — transformer-based limit order book analysis
- KAN — Kolmogorov-Arnold networks
- xLSTM — extended LSTM architecture
- TGGN — temporal graph neural network
- Diffusion — diffusion-based generative model
Key Modules
ensemble— model ensemble coordination and confidence aggregationhyperopt— PSO-based hyperparameter optimization with per-model adapterstrainers— unified training loops (DQN, PPO, supervised)inference—InferenceAdaptertrait for predictioncheckpoint— model checkpointing and restorationevaluation— walk-forward evaluation pipeline
Usage
use ml::dqn::DQN;
use ml::ppo::PpoTrainer;