AdaptationCallback

class jaxrens.cli.monitor.AdaptationCallback(logger_obj)[source]

Bases: object

Writes per-move adaptation data to an HDF5 trace file.

Wraps an AdaptationLogger and calls write_entry on every iteration where info["step_sizes_per_move"] is present. Iterations between adaptation adjustments are skipped (the info key is absent).

Also surfaces two adapter-health WARNINGs to the textual log on top of the silent h5 trace:

  • First-hit floor warning — fires once per move the first time any replica’s bisection clamps the step size to the configured floor. Signals “the move can’t shrink further; remaining rejections are not informative for the adapter”.

  • Stall guard — fires once (then suppressed for _STALL_SUPPRESS_EVENTS adjust events) when a move shows mean-trial-acceptance < 0.01 AND any replica at the floor AND no replica detecting a bracket, for _STALL_HISTORY_LEN consecutive adjust events.

Parameters:

logger_obj (Any) – A ready-to-use AdaptationLogger instance.

on_start(ns_state, start_info=None)[source]

Write the mandatory iter-0 baseline row.

This pins the initial step sizes for post-hoc reconstruction: active ss at iter k = last row whose iter <= k. Without this row, a non-full_auto run would produce an empty file (no adjustment events ever fire), and a full_auto run would mis-attribute the pre-first-adjust period to the first adjustment event’s step size.

Adjustment-event-only fields (n_rounds, cap_hits, floor_hits, converged, bracket_detected, reject_reason_counts) are written as zeros / True to signal “no bisection ran for this row”. Evaluation counters are zero too.

Acceptance rates default to 0 here: real chain rates are absent at iter 0 (no NS step has run yet), and the trial-phase rates from bisection don’t exist either. Downstream readers should ignore acc rates on the iter-0 row.

Parameters:
  • ns_state (Any)

  • start_info (dict | None)

Return type:

None