jgrusewski
e19ce1dd9b
perf(cuda): PPO loss + portfolio sim + state build fully GPU-native
ppo.rs update_gpu():
- Advantage normalization: ReductionKernels::stats() (5 scalars) + affine()
- Value loss: sub() → sqr() → mean_all() (1 scalar readback)
- Policy loss: sub → clamp → exp → mul → GPU min → neg → mean_all
- Zero full-buffer downloads (was: 4 arrays × N elements)
gpu_portfolio.rs:
- New simulate_batch_gpu() returns CudaSlice (DtoD clone from kernel)
- Zero CPU download for portfolio features/rewards/done
cuda_pipeline/mod.rs:
- build_state_tensor/build_batch_states: DtoD assembly
- dtod_copy_into/dtod_copy_into_at_offset helpers
- Zero memcpy_dtoh in state construction
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>