feat(phase-e-4-a): alpha_c51_grad_input kernel (T10 prerequisite)

Phase E.4.A Task 10 partial: adds the C51 gradient-w.r.t.-input
kernel needed to chain the C51 head's loss gradient back into the
Mamba2 temporal encoder.

Kernel signature: alpha_c51_grad_input_kernel reads probs[B, A, K],
m[B, K], actions[B], W[A*K, in_dim] and writes d_input[B, in_dim].
Math: dL/d_input[b,j] = Σ_k (p[b,a_taken,k] − m[b,k]) · W[a_taken*K+k, j]
(only the taken-action column of W contributes; restricted by the
sparse-over-actions C51 CE gradient structure).

Status: kernel + Rust launcher in place. Mamba2 backward NOT yet
wired in the smoke binary because ml_alpha::Mamba2Block::backward
takes d_logit [B, 1] (post-W_out scalar gradient), not
d_h_enriched [B, hidden_dim]. Two paths to complete:
  1. Modify ml-alpha to expose backward_from_h_enriched(cache,
     d_h_enriched) bypassing W_out.
  2. Replicate the post-W_out backward sequence inline.

Both deferred pending backtest validation (T14): if frozen Mamba2
already lifts backtest Sharpe meaningfully, T10 becomes
optimisation rather than prerequisite. Smoke gate already passed
gate 1 (R_mean +3.9 vs C51-flat -1.1) with frozen weights.

docs/isv-slots.md updated.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
jgrusewski
2026-05-15 21:24:43 +02:00
parent 41a7da7008
commit 75d67bd203
3 changed files with 126 additions and 0 deletions

View File

@@ -777,6 +777,26 @@ inference; effective policy adapts via ISV slot 543 (threshold), 545
allocated for the E.3 follow-up; E.4.B will add MoE-gate-entropy and
Pearl-1 atom-headroom slots when those land.
### Phase E.4.A.10 — alpha_c51_grad_input (2026-05-15)
`crates/ml/src/cuda_pipeline/alpha_c51.cu` adds a 6th kernel:
`alpha_c51_grad_input_kernel`. Computes `dL/d_input[b, j]` for the
C51 layer (gradient w.r.t. the upstream encoder's output). Required
to chain C51's gradient into Mamba2's backward in `--temporal`.
NO ISV slot interaction — pure Q-layer gradient compute.
T10 status: kernel landed but Mamba2 backward NOT yet wired in the
smoke binary because `ml_alpha::Mamba2Block::backward` takes
`d_logit [B, 1]` (post-W_out gradient) rather than
`d_h_enriched [B, hidden_dim]`. Two paths to complete T10:
1. Modify ml-alpha to expose `backward_from_h_enriched`.
2. Replicate the post-W_out backward logic inline.
Deferred pending backtest validation — if frozen-Mamba2 already
lifts backtest Sharpe, T10 becomes optimisation rather than
prerequisite.
### Phase E.4.A.6 — alpha_window_push (2026-05-15)
`crates/ml/src/cuda_pipeline/alpha_window_push.cu`: shift+insert