Root cause from train-6fcml 5-epoch trajectory (commit 5608b866b after
producer cadence migration): HEALTH_DIAG[0] (post-experience-collection)
showed q_dis_s=0.0595 q_dis_l=0.1329 var_q=0.00091 — meaningful rollout
signal. HEALTH_DIAG[1+] (post-training, per-step launches) all showed
q_dis_s=0.0000 q_dis_l=0.0000 var_q=0.00000 — signal decayed to zero
inside ONE epoch.
The kernel's ISV write block ran unconditionally even when total_cnt
(non-masked-row count after Hold/Flat masking) was 0. Empty-batch
launches blended `batch_mean = 0/1 = 0` into the EMA, decaying the
rollout signal to 0 over ~178 training steps × 0.7^n. Per-step training
launches read replay batches whose Q-direction picks are dominated by
Hold/Flat (the natural distribution); so total_cnt = 0 was the common
case, not a corner case.
Fix (atomic, single kernel):
- Wrap the ISV write block in `if (total_cnt > 0.0f) { ... }`. When the
training batch has no non-masked rows, the kernel is a no-op for that
step — EMAs stay at the prior step's values. Stream-ordered launches
still run; only the ISV write is skipped.
- Remove redundant `&& (total_cnt > 0.0f)` clause from the `is_first`
bootstrap check (now guaranteed by the outer gate).
Per pearl_first_observation_bootstrap semantics: "no observation"
preserves prior; only "first observation" replaces sentinel. Decay-on-
empty was inconsistent with both rules.
Other EGF-chain kernels audited:
- alpha_grad_compute_kernel.cu — operates on persistent ISV state,
no batch concept; var_aux/var_alpha Welford updates use `diff` of
persistent EMAs, not batch means. No empty-batch path. SAFE.
- aux_dir_acc_reduce_kernel.cu — emits out_6[0..3] with sentinel
fallback (0.5) when denom==0; downstream apply_fixed_alpha_ema then
blends 0.5 toward EMA. The sentinel is the random-baseline (target
threshold lies above it), so empty-batch pulls EMA toward harmless
baseline rather than zero. Different semantics from q_disagreement
(which has 0 — far below baseline 0.5). SAFE.
- gradient_hack_detect_kernel.cu — single-thread state machine on
persistent ISV, no batch. SAFE.
Verification:
- 6 existing sp14_oracle_tests pass.
- New q_disagreement_empty_batch_preserves_ema test asserts bit-exact
preservation of pre-seeded EMAs (0.0595, 0.1329, 0.0009 — the
train-6fcml HEALTH_DIAG[0] values) across an all-Hold batch. Catches
the regression the existing all-hold test missed (its bound
`[0.0, 0.5]` accepted both decay-to-blend and preserve-prior; the new
test is strict bit-equality).
- L40S smoke validation pending — train-6fcml symptoms (alpha_smoothed
stuck at 0.0002, gate1 closed forever) expected to resolve.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>