Per-step (16K/epoch): - total_loss, mse_loss, grad_norm, q_divergence: CudaSlice → pinned device-mapped. GPU kernels write via dev_ptr, CPU reads via host_ptr. Zero copies in replay_adam_and_readback (was 4x cuMemcpyDtoHAsync). - readback_scalars_sync, execute_train_scalars_only: sync DtoH → direct pinned read after cuStreamSynchronize. Per-50-steps: - eval_v_range: cuMemcpyHtoDAsync → pinned host write (CPU writes v_min/v_max, GPU reads via dev_ptr, no copy). - per_branch_q_gaps: cuMemcpyHtoD → pinned host write (CPU writes 4 Q-gaps, GPU reads via dev_ptr in qlstm_step + liquid_tau_rk4_step). - q_stats + q_out readback: stack destination → pinned DtoHAsync destination (DMA-capable, faster async transfer). Structural changes: - launch_loss_reduce signature: &CudaSlice<f32> → u64 dev_ptr - loss_gpu_buf/grad_norm_gpu_buf → loss_gpu_ptr/grad_norm_gpu_ptr (u64) - memset_zeros on CudaSlice → cuMemsetD8Async on dev_ptr - 6 new pinned allocations in constructor, freed in Drop Only cuMemcpy remaining: constructor init, checkpoint save/restore, xavier_init upload, trajectory backtracking, causal intervention, compute_q_values inference. All per-step training copies eliminated. 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;