nvalchemi.hooks.RichReporter#
- class nvalchemi.hooks.RichReporter(*, custom_scalars=None, include_losses=True, include_optimizer_lrs=True, include_dynamics_scalars=None, rank_reduction=None, title='nvalchemi report', precision=6, max_scalars=None, history_size=200, layout=None, plot_keys=None, max_plots=3, plot_height=8, refresh_per_second=2.0, console=None, screen=False, transient=False, rank_zero_only=True, strict_layout=False)[source]#
Render scalar reporting snapshots as a live Rich dashboard.
- Parameters:
custom_scalars (Mapping[str, ScalarCallback] | None, optional) – Additional scalar callbacks passed to
collect_scalars().include_losses (bool, default True) – When
True, include loss scalars from the hook context.include_optimizer_lrs (bool, default True) – When
True, include optimizer learning rates from the hook context.include_dynamics_scalars (bool | None, optional) – When
True, include default dynamics observables from the hook context.Nonelets the selected layout choose; the built-in dynamics layout enables them.rank_reduction (torch.distributed.ReduceOp | {"none", "mean", "sum", "min", "max"} | None, default None) – Optional distributed reduction applied to scalars before rendering. String values are normalized to
torch.distributed.ReduceOp. Reduction requires every rank to call this reporter; only rank zero renders the reduced dashboard.title (str, default "nvalchemi report") – Dashboard title.
precision (int, default 6) – Significant digits used when formatting scalar values.
max_scalars (int | None, optional) – Maximum number of scalar rows to show. When omitted, all scalars are shown.
history_size (int, default 200) – Maximum history points retained per scalar.
layout (RichLayout | {"training", "dynamics"} | None, optional) – Dashboard layout policy.
Noneand"auto"select the first built-in layout that supports the first reported context.plot_keys (Sequence[str] | None, optional) – Scalar keys to plot. When omitted, the selected layout chooses common metrics for that workflow before falling back to alphabetical order.
max_plots (int, default 3) – Maximum number of history plots shown in the dashboard.
plot_height (int, default 8) – Height in terminal rows for each plotext plot.
refresh_per_second (float, default 2.0) – Rich
Liverefresh rate used while the reporter is entered.console (Console | None, optional) – Rich console used for output. When omitted, a stderr console is created.
screen (bool, default False) – Whether Rich
Liveshould use the terminal alternate screen.transient (bool, default False) – Whether Rich
Liveshould clear the dashboard on exit.rank_zero_only (bool, default True) – Request rank-zero-only dispatch from
ReportingOrchestrator.strict_layout (bool, default False) – When
True, raise if automatic layout selection cannot match the incoming context. WhenFalse, unmatched contexts are ignored.
- property history: dict[str, tuple[tuple[int, float], ...]]#
Return retained scalar history.
- Returns:
Mapping from scalar key to
(step, value)history tuples.- Return type:
dict[str, tuple[tuple[int, float], …]]
- classmethod preview(*, history=None, layout=None, steps=None, console=None, stage=None, step_count=None, epoch=_PREVIEW_DEFAULT, batch_count=_PREVIEW_DEFAULT, **reporter_kwargs)[source]#
Render a synthetic dashboard preview.
- Parameters:
history (Mapping[str, Sequence[float]] | None, optional) – Metric history used to populate plots and latest values. Defaults to representative curves from the selected layout.
layout (RichLayout | {"training", "dynamics"} | None, optional) – Dashboard layout policy.
Noneselects the training layout.steps (Sequence[int] | None, optional) – Step values aligned with each history sequence. Defaults to
range(len(series)).console (Console | None, optional) – Rich console used for preview output.
stage (str | None, optional) – Stage label shown in the dashboard header. When omitted, the selected layout supplies a workflow-appropriate default.
step_count (int | None, optional) – Step shown in the dashboard header. Defaults to the final step.
epoch (int | None, optional) – Epoch shown in dashboard metadata. When omitted, the selected layout supplies a workflow-appropriate default.
batch_count (int | None, optional) – Batch count shown in dashboard metadata. When omitted, the selected layout supplies a workflow-appropriate default.
**reporter_kwargs (object) – Additional keyword arguments forwarded to
RichReporter.
- Return type:
None
- renderable()[source]#
Build the current dashboard renderable.
- Returns:
Rich layout containing the header, latest scalar table, and plots.
- Return type:
Layout
- report(ctx, stage, state)[source]#
Update the dashboard from one scalar snapshot.
- Parameters:
ctx (HookContext) – Workflow hook context.
stage (Enum) – Hook stage being reported.
state (ReportingState) – Shared reporting state from the orchestrator.
- Return type:
None
- seed_history(history, *, steps=None, stage='AFTER_OPTIMIZER_STEP', step_count=None, epoch=None, batch_count=None, global_rank=0)[source]#
Seed dashboard history without running a workflow.
- Parameters:
history (Mapping[str, Sequence[float]]) – Metric history used to populate plots and latest scalar values.
steps (Sequence[int] | None, optional) – Step values aligned with each metric series.
stage (str, default "AFTER_OPTIMIZER_STEP") – Stage label for the synthetic snapshot.
step_count (int | None, optional) – Step count for the synthetic snapshot. Defaults to the final step.
epoch (int | None, optional) – Epoch metadata for the synthetic snapshot.
batch_count (int | None, optional) – Batch metadata for the synthetic snapshot.
global_rank (int, default 0) – Rank metadata for the synthetic snapshot.
- Returns:
Synthetic latest snapshot produced from
history.- Return type: