Files
foxhunt/docs
jgrusewski f3e3ac3477 fix(dqn-v2): bottleneck Linear runtime indices + missing target/DDQN bn paths (2c.3a follow-up)
Three related bugs from the 2c.3a GRN trunk reshuffle that the
bottleneck-Linear runtime sites silently inherited:

1. **on_w_ptrs[24/25] -> [33/34]** (4 sites in gpu_dqn_trainer.rs).
   2c.3a's +9 shift migrated branch/value/VSN/GLU/KAN consumers but
   missed the bottleneck Linear's forward GEMM (line ~14098), forward
   bias-add (~14107), and backward dW/db offsets (~15109-15110).
   Post-2c.3a, indices 24/25 point at b_b1out (153 floats) and start
   of w_b2fc (4288 floats) — not w_bn (672 floats) / b_bn (16 floats).
   Forward + backward were self-consistent on wrong tensors; the actual
   w_bn/b_bn at documented indices 33/34 sat untouched as zeros for
   ~10 commits. Smoke kept passing because GRN's Linear_residual
   projection ran in parallel and provided a clean residual-only
   pathway around the corrupted bottleneck slot.

2. **Target net missing bottleneck path.** forward_target_raw passed
   raw next_states_buf (128-padded) to an encoder expecting
   [B, s1_input_dim=102]; it was reading
   [market|ofi|tlob|mtf] of next_states instead of
   [bn_market_proj|portfolio]. Fix: build tg_bn_concat_buf inline
   before forward_target_raw using tg_w_ptrs[33]/[34] (target's w_bn)
   on next_states_buf[market]; new buffer pair tg_bn_hidden_buf +
   tg_bn_concat_buf.

3. **DDQN argmax missing bottleneck path.** submit_forward_ops_ddqn
   had the same shape mismatch on the online-on-next_states pass.
   Fix: build on_next_bn_concat_buf using on_w_ptrs[33]/[34] (online
   weights, since DDQN argmax uses online net); new buffer pair
   on_next_bn_hidden_buf + on_next_bn_concat_buf.

Three call sites of the existing bn_tanh_concat_kernel now: online-on-
states (states + on_w_bn), target-on-next_states (next + tg_w_bn), and
ddqn-online-on-next_states (next + on_w_bn). Each combination of
weights × input states produces distinct features; sharing the kernel
across distinct buffer pairs preserves the GPU-only cold-path contract.

No fingerprint change (no ISV slot or param tensor added).

Smoke validation (multi_fold_convergence, 700.43s, 3 folds x 5 epochs):
  fold 0 best Sharpe  6.53 at epoch 2
  fold 1 best Sharpe 80.11 at epoch 4
  fold 2 best Sharpe 66.72 at epoch 4
  geom-mean: 39.27 (vs Task 3 20.03, 2c.3c.6 18.80)

The Sharpe lift is consistent with the bottleneck Linear now seeing
its actual weights and the target/DDQN nets seeing input-shape-
consistent features for TD-target / argmax-action computations.

+166 / -9 LOC all in gpu_dqn_trainer.rs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-25 18:24:06 +02:00
..