Plan 4 Task 2c.2. Additive Rust wrapper around the kernels landed in
2c.1 (`grn_kernel.cu`, commit 68197c2c2). NO production callers in
this commit; dead code until Task 2c.3+4 wires it into the trunk
encoder.
GrnBlock struct holds:
- 5 save-for-backward state buffers per block (elu_post, linear_b_out,
sigmoid_b, ln_mean, ln_rstd, ln_normed) plus 2 partial-reduction
scratch buffers (dgamma_partials, dbeta_partials)
- 8 CudaFunction handles for the kernels in grn_kernel.cu
- has_residual_projection flag (true for h_s1 SD->SH1, false for
h_s2 SH1->SH2)
forward() sequences elu_inplace -> DtoD save post-ELU -> DtoD save
linear_b_out -> glu_forward -> residual+layernorm. cuBLAS GEMMs
(Linear_a, Linear_b, optional Linear_residual) called by caller
outside the wrapper.
backward() sequences LN backward dx (full Jacobian) -> LN backward
dgamma/dbeta two-phase (no atomicAdd) -> GLU backward -> ELU backward.
Residual split is pure pointer aliasing; cuBLAS Linear backward GEMMs
called by caller between steps 4 and 6.
ELU backward saves the POST-activation per the kernel's docstring
(grn_elu_backward recovers f'(x_pre) from x_post via the identity
exp(x_pre) = x_post + 1 for x_post < 0). The wrapper DtoD-copies the
post-ELU buffer into state.elu_post immediately after the in-place
ELU launch.
LN dgamma/dbeta phase-1 partial-reduction allocation is sized for the
maximum batch (num_blocks_b = ceil(B/256)); runtime backward verifies
the runtime batch fits.
Pattern matches gpu_tlob.rs and gpu_attention.rs for idiom
consistency. Module is dead code; production wiring + numerical
validation happens in 2c.3+4.
GRN_CUBIN ref added in gpu_dqn_trainer.rs alongside other Plan 4
kernel cubins. mod.rs declares pub mod gpu_grn. Wire-up audit doc
updated with Task 2c.2 entry + 1 new Orphan-by-design row (will
reclassify Wired at 2c.3+4 alongside the 2c.1 kernel entry).
Co-Authored-By: Claude Opus 4.7 (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;