Files
foxhunt/docs
jgrusewski 5608b866b6 fix(producer-cadence): migrate 4 more per-step ISV producers from process_epoch_boundary to per-step hot path
Continuation of SP14 B.11 cadence fix (commit 200f05fce). The same per-
epoch staleness bug affected 4 additional producers whose docstrings
explicitly claim "per-step" cadence but whose launches lived in
`process_epoch_boundary` (fires once per epoch at line ~780):

  * launch_h_s2_rms_ema           → ISV[H_S2_RMS_EMA_INDEX=96]
  * launch_fold_warmup_factor     → ISV[FOLD_WARMUP_FACTOR_INDEX=130]
  * launch_moe_expert_util_ema    → ISV[MOE_EXPERT_UTIL_EMA_BASE..+8) +
                                    ISV[MOE_GATE_ENTROPY_EMA_INDEX=126]
  * launch_moe_lambda_eff_update  → ISV[MOE_LAMBDA_EFF_INDEX=128]

Each producer's per-step consumer reads the ISV slot every training
step (thousands per epoch). With the producers stuck per-epoch, consumers
saw (steps_per_epoch − 1)-step-stale values — exactly the failure mode
SP14 B.11 documented for ALPHA_GRAD_SMOOTHED. Verified consumers:
  * h_s2_rms_ema → mag_concat_kernel (forward graph) +
    dqn_clamp_finite_f32_kernel (cuBLAS backward IQN-trunk sanitiser
    bound = 1e6 × ISV[96])
  * fold_warmup_factor → training_loop.rs:2662 per-step host read
    deriving lr_eff and clip_eff
  * moe_expert_util/entropy → consumed by launch_moe_lambda_eff_update
    immediately below (same step)
  * moe_lambda_eff → moe_load_balance_loss kernel reads ISV[128] per
    step at gpu_dqn_trainer.rs:16864

Atomic migration per `feedback_no_partial_refactor`. Producers leaving
process_epoch_boundary are replaced with one-line redirect comments
pointing to the new hook. Ordering dependencies preserved
(launch_moe_lambda_eff_update still runs AFTER launch_moe_expert_util_ema
per the kernel docstring at gpu_dqn_trainer.rs:16962). All 4 launchers
use pre-loaded CudaFunction fields (gpu_dqn_trainer.rs:12646, 30983,
16901, 16969) — graph-capture safe per
`pearl_no_host_branches_in_captured_graph`.

Cold-start ordering: h_s2_rms_ema reads `save_h_s2` populated by THIS
step's online forward (forward_child runs BEFORE aux_child per
`capture_training_graph`). MoE producer reads `moe_gate_softmax_buf`
populated by `launch_moe_forward` (in `submit_forward_ops_main`,
forward_child). Both inputs are valid by the time submit_aux_ops runs.

State-reset registry coverage already in place
(state_reset_registry.rs:304/427/380/387/398/442 — isv_h_s2_rms_ema,
isv_fold_warmup_factor, isv_moe_expert_util_ema, isv_moe_gate_entropy_ema,
isv_moe_lambda_eff, isv_grad_norm_fast_ema). HEALTH_DIAG read points
unchanged — per-epoch reads of per-step-updated slots get the latest
value (strict improvement over per-epoch reads of per-epoch-stale slots).

Producers DELIBERATELY KEPT per-epoch (audit trail):

  Collector EMAs (input data only updates per-epoch — running per-step
  computes the same EMA repeatedly off the same data):
    * launch_trade_attempt_rate_ema_inplace
    * launch_plan_threshold_update_inplace
    * launch_seed_step_counter_update_inplace
    * launch_cql_alpha_seed_update_inplace

  HEALTH_DIAG-only consumers (no per-step kernel reads these slots):
    * launch_iqn_quantile_ema  (ISV[99..103))
    * launch_vsn_mask_ema      (ISV[105..111))
    * launch_aux_heads_loss_ema (ISV[113], ISV[114])

DEFERRED follow-up (NOT changed in this commit per the user-specified
strict heuristic "docstring per-step + per-step consumer ⇒ migrate";
docstrings of the SP4/SP5 producers below don't explicitly claim
per-step cadence — they're silent — so they fall outside the heuristic
even though their consumers ARE per-step):
  * launch_sp4_target_q_p99 + atom_pos_p99 + grad_norm_p99 + h_s2_p99
  * launch_sp4_param_group_oracles_all_groups
    (consumed by `read_group_adam_bounds` per-step in submit_aux_ops)
  * launch_sp5_pearl_1_atom + pearl_3_sigma + pearl_2_budget +
    pearl_4_adam_hparams + pearl_5_iqn_tau + pearl_8_trail +
    pearl_1_ext_num_atoms
  * launch_max_budget_compute + launch_loss_balance_controller (SP7/SP8)
This staleness will be addressed in a follow-up audit pass; for now the
SP4/SP5 epoch-block producers stay where they are.

Verification:
  * SQLX_OFFLINE=true CUDA_COMPUTE_CAP=86 cargo check -p ml --tests
    --all-targets clean (only pre-existing unused-var warnings).
  * sp14_oracle_tests 6/6 pass (alpha_grad_adaptive_beta,
    alpha_grad_schmitt_hysteresis, dir_concat_qaux_correct,
    gradient_hack_circuit_breaker_fires,
    q_disagreement_all_hold_no_contribution, q_disagreement_k4_k2_mapping).
  * HEALTH_DIAG validation pending L40S re-dispatch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 18:55:29 +02:00
..