From 7db3a75c94945f64c17a6b5ea6dbd2a33dd08d88 Mon Sep 17 00:00:00 2001 From: jgrusewski Date: Thu, 16 Apr 2026 19:13:17 +0200 Subject: [PATCH] fix: purge raw_next from portfolio_sim_kernel + update stale comments portfolio_sim_kernel also used next_close_raw (future price) for mark-to-market and reward computation. Fixed: use current price only. Updated stale comments referencing per-bar reward in trade-level section. Co-Authored-By: Claude Opus 4.6 (1M context) --- crates/ml/src/cuda_pipeline/experience_kernels.cu | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/ml/src/cuda_pipeline/experience_kernels.cu b/crates/ml/src/cuda_pipeline/experience_kernels.cu index 8b1857280..44c5424ff 100644 --- a/crates/ml/src/cuda_pipeline/experience_kernels.cu +++ b/crates/ml/src/cuda_pipeline/experience_kernels.cu @@ -1630,8 +1630,8 @@ extern "C" __global__ void experience_env_step( } /* ── v10: Trade-level reward attribution ────────────────────────────── - * Per-bar reward (next_close - close) has SNR ~0.01 — 99% random walk - * noise. Trade-level P&L has SNR ~0.1-0.5 — the atomic unit of signal. + * Rewards are PER-TRADE only. No per-bar P&L (was removed: used raw_next + * which is future information, and per-bar noise has SNR ~0.01). * * When segment_complete fired above, reward already has the trade P&L * (vol-normalized, soft-clamped, with Layer 4-9 credits). @@ -2027,7 +2027,7 @@ extern "C" __global__ void portfolio_sim_kernel( float current_close = (targets[t_offset + 0]); float next_close = (targets[t_offset + 1]); float current_close_raw = (targets[t_offset + 2]); - float next_close_raw = (targets[t_offset + 3]); + (void)(targets[t_offset + 3]); /* next_close_raw: FUTURE — must NOT be used */ float price = (current_close_raw != 0.0f) ? current_close_raw : current_close; if (price <= 0.0f) price = 1.0f; @@ -2094,10 +2094,10 @@ extern "C" __global__ void portfolio_sim_kernel( last_price = price; - float next_price = (next_close_raw != 0.0f) ? next_close_raw : next_close; - if (next_price <= 0.0f) next_price = price; - float next_value = cash + position * next_price; - float next_norm = next_value / initial_cap; + /* Use current price for mark-to-market — NOT next_close_raw (future info). + * next_close_raw must NOT feed into reward/equity/P&L. */ + float mtm_value = cash + position * price; + float next_norm = mtm_value / initial_cap; float max_pos_norm = (price > 0.0f) ? initial_cap / price : 1.0f; float pos_norm = position / max_pos_norm;