Files
foxhunt/docs
jgrusewski 7640a681c5 diag(dqn): per-step F1 explosion diagnostic — pinpoint which signal blows first
After 6+ intervention layers (A.1+A.2+A.3+F+H+K+warmup+N) F1 ep2 still
explodes with grad_norm=2.66T while F1 ep1 trains cleanly. None of our
defenses catch the explosion path. Need data to pinpoint WHICH signal
explodes first.

Per-step FOLD_EXPLOSION_DIAG in fold >= 1: when grad_norm > 1000 OR
jumps 5x from prior guard step, fire diagnostic warn with:
  - loss decomposition: total / c51 / mse / iqn (pinned readback, no DtoH)
  - Q range: q_min / q_mean / q_max via cold-path reduce
  - atom positions: per_sample_support[0,d0] + [0,d2] (v_min, v_max, dz)
  - prev grad norm + ratio for context
  - trigger flag + post-trigger trajectory countdown

After trigger, continues emitting for 5 guard steps so the explosion
trajectory is captured (not just the first crossing).

Plus an unconditional FOLD_EXPLOSION_DIAG[F1_END_EP1] baseline log at
the end of fold 1 epoch 0 — healthy state immediately preceding the
explosion. Compare-and-contrast with per-step explosion frames pins
the runaway driver.

CQL and ensemble losses are not pinned-readback (transient device
buffers consumed inside the training graph) and are explicitly absent
from the decomposition. If none of {c51, iqn, mse} is the runaway
driver but total_loss still explodes, that implicates the unexposed
CQL/ens path — the absence is itself diagnostic information.

Implementation:
  - Three diagnostic-only fields on DQNTrainer: current_fold,
    last_logged_grad_norm, explosion_diag_steps_remaining. Reset
    last_logged + remaining in reset_for_fold; current_fold
    overwritten unconditionally at fold-loop entry.
  - Three accessors on FusedTrainingCtx: explosion_diag_loss_components
    (pinned), explosion_diag_atom_range (12-elem cold DtoH),
    explosion_diag_q_range (reduce + 28B DtoH).
  - Three accessors on GpuDqnTrainer: c51_loss_pinned_value,
    mse_loss_pinned_value, stream_for_diag.

Diagnostic-only — remove once root cause identified. Not for prod.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-29 21:16:48 +02:00
..