Files
foxhunt/docs
jgrusewski 5478e7c821 feat(dqn-v2): Plan 4 Task 6 Commit A — aux heads scaffolding (kernels + params [119..127) + 2 ISV slots, additive)
Multi-task auxiliary heads (E.6) — additive scaffolding ONLY. NO
production callers in this commit; Commit B wires forward/backward +
training-loop loss accumulation.

Two `Linear(SH2 → 32) → ELU → Linear(32 → K)` MLPs branch off h_s2:
- Next-bar return regression head (K=1, MSE loss).
- 5-class regime classification head (K=5, cross-entropy loss).

Lands in this commit (additive, no behavioural change):

1. Two CUDA kernel files (kernel count 62 → 64):
   - `aux_heads_kernel.cu` — 8 entry points (per-head forward, backward,
     loss-reduce; shared regime label-builder + per-tensor batch-reduce).
     Single-block-per-sample, shmem-tree reductions, no atomicAdd.
   - `aux_heads_loss_ema_kernel.cu` — single-thread single-block ISV
     producer mirroring h_s2_rms_ema_kernel.cu's footprint.
2. Rust orchestrator `cuda_pipeline/gpu_aux_heads.rs` —
   `AuxHeadsForwardOps` + `AuxHeadsBackwardOps` mirror gpu_grn.rs's
   raw-u64-pointer ABI for graph-capture safety. NO callers.
3. Param tensors at [119..127) (NUM_WEIGHT_TENSORS 119 → 127):
   aux_nb_{w1,b1,w2,b2}, aux_rg_{w1,b1,w2,b2}. Xavier on weights,
   zero on biases. Adam SAXPY iterates 0..total_params (count-driven),
   so the new range gets covered automatically; with no producer for
   grad_buf[119..127) in this commit, Adam keeps params at Xavier
   init (intended dormant state).
4. Two new ISV slots tail-appended after VSN:
   AUX_NEXT_BAR_MSE_EMA_INDEX=113, AUX_REGIME_CE_EMA_INDEX=114.
   Producer: aux_heads_loss_ema_update. Cold-start 0.0; FoldReset → 0.0.
   Diagnostic only; no GPU consumer kernel reads slots [113..115).
5. Fingerprint pair shifted [111,112] → [115,116]; ISV_TOTAL_DIM
   113 → 117. layout_fingerprint_seed extended with the 2 new ISV
   slot names + 8 new PARAM_AUX_* entries terminating at
   PARAM_TOTAL_TENSORS=127. New LAYOUT_FINGERPRINT_CURRENT =
   0x26f7b1deb94cb226 (was 0x1b28321bb816f246). Checkpoint break by
   intent — fail-fast at constructor load on mismatch.
6. Two new FoldReset entries in state_reset_registry.rs
   (isv_aux_next_bar_mse_ema, isv_aux_regime_ce_ema) WITH matching
   dispatch arm in training_loop.rs::reset_named_state (the wire
   VSN-rc2 missed and chain-final fix made dispatch-mandatory).
7. Polyak EMA target sync NOT extended for aux heads — design
   decision: aux heads are online-only supervised heads, not used in
   Bellman bootstrapping. target_params_buf[119..127) initialised by
   xavier_init_params_buf (same Xavier values as online) and never
   updated; verified no consumer reads target_params_buf past
   padded_byte_offset(119).

Constraints honoured: GPU-only (every reduction GPU-side, zero DtoH);
no atomicAdd (shmem-tree reductions throughout backward + final
batch-dim collapse); no stubs (every Rust function is real
implementation; "no callers yet" applies only to orchestrator wrappers
waiting on Commit B); partial-refactor invariant honoured
(NUM_WEIGHT_TENSORS, Adam range, xavier init, fingerprint seed,
ISV_TOTAL_DIM, FoldReset entries + dispatch arm all migrate together);
no `// ok:` band-aids; no tuned constants.

cargo check --workspace clean at 11 warnings (workspace baseline
preserved). Smoke deferred to Commit B (no behaviour change in this
commit — aux head params are dormant Xavier weights).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-26 08:43:38 +02:00
..