accelmo.dashboard.fit¶
The live terminal dashboard of a gradient-descent fit.
- accelmo.dashboard.fit.LEFT_WIDTH_FRACTION = 0.66¶
Share of the terminal width the progress panel takes.
- accelmo.dashboard.fit.SHORT_FIT_STEPS = 30¶
Fits shorter than this many steps get a smaller plot.
- accelmo.dashboard.fit.REFRESH_PER_SECOND = 1¶
Redraws per second, so the resource line moves during a long step.
- accelmo.dashboard.fit.ETA_WINDOW = 10¶
Epochs averaged for the epoch time and ETA.
- accelmo.dashboard.fit.STALL_EPOCHS = 10¶
Epochs without a new best before the status turns “stalled”.
- accelmo.dashboard.fit.DIVERGENCE_FACTOR = 10.0¶
A loss this many times the best one is flagged as diverging.
- accelmo.dashboard.fit.MOVED_SIGMAS = 1.0¶
A knob counts as moved when it is this many prior widths from its start.
- accelmo.dashboard.fit.FACTOR_BELOW_RATIO = 0.01¶
A reduction of the loss beyond this is printed as a factor, not a percentage.
- accelmo.dashboard.fit.PHASES = ('data', 'model', 'workers', 'fit', 'uncertainty')¶
The stages of a run, in order; the strip at the top shows each one’s state.
- accelmo.dashboard.fit.format_duration(seconds)[source]¶
73->1m13s;4000->1h06m.- Return type:
str- Parameters:
seconds (float)
- accelmo.dashboard.fit.format_change(first, best)[source]¶
How far
bestis belowfirst: a percentage, or a factor when it is large.- Return type:
Text- Parameters:
first (float)
best (float)
- class accelmo.dashboard.fit.Best(epoch, chi2, validation, true_diff, knobs)[source]¶
Bases:
objectThe best epoch so far.
- Parameters:
epoch (int)
chi2 (float)
validation (float | None)
true_diff (float | None)
knobs (dict[str, float])
- epoch: int¶
- chi2: float¶
- validation: float | None¶
- true_diff: float | None¶
- knobs: dict[str, float]¶
- class accelmo.dashboard.fit.PhaseState(status='pending', detail='', started=0.0, seconds=0.0, skipped=False)[source]¶
Bases:
objectOne stage of the run: whether it has started or finished, and how long it took.
- Parameters:
status (str)
detail (str)
started (float)
seconds (float)
skipped (bool)
- status: str = 'pending'¶
- detail: str = ''¶
- started: float = 0.0¶
- seconds: float = 0.0¶
- skipped: bool = False¶
- class accelmo.dashboard.fit.FitDashboard(title, *, console=None, enabled=True)[source]¶
Bases:
objectThe live terminal view of a fit: a strip of stages, progress, loss history and best-so-far.
Does nothing when the output is not a terminal; the run log has the numbers then. The display starts at the first
phase()(or on entering thewithblock) and stays on screen afterclose(). Mark each stage of the run withphase(), state what the run is made of withfact(), callbegin_fit()before the epoch loop andupdate()after every epoch.- Parameters:
title (str)
console (Console | None)
enabled (bool)
- facts: dict[str, str]¶
- run_log_path: Path | None¶
- start_knobs: dict[str, float]¶
- sigmas: dict[str, float]¶
- gain_names: list[str]¶
- stage_epochs: int | None¶
- chi2: list[float]¶
- validation: list[float | None]¶
- epoch_times: list[float]¶
- stop_reason: str | None¶
- begin_fit(*, max_epochs, n_points, n_params, start_knobs, knob_sigmas, gain_names=(), stage_epochs=None, loss_is_total=False, unit='epoch', rate_name='lr')[source]¶
Start the fit stage.
n_pointsandn_paramsgive the degrees of freedom of the reduced chi-square (lossis chi-square per point);n_points=Noneshows the total chi-square.knob_sigmasare the prior widths of the magnet knobs,start_knobstheir starting values,gain_namesthe BPM gains. Withloss_is_totalthe loss given toupdate()is the chi-square itself, not per point.unitnames a step (epoch,iter) andrate_namethe step-size parameter shown beside the gradient (lr,λ).- Return type:
None- Parameters:
max_epochs (int)
n_points (int | None)
n_params (int)
start_knobs (Mapping[str, float])
knob_sigmas (Mapping[str, float])
gain_names (Sequence[str])
stage_epochs (int | None)
loss_is_total (bool)
unit (str)
rate_name (str)
- fact(label, value)[source]¶
Show
label: valuein the run panel.- Return type:
None- Parameters:
label (str)
value (object)
- skip(name)[source]¶
Hide stage
name: this run does not have it.- Return type:
None- Parameters:
name (str)
- set_detail(name, detail)[source]¶
Text shown after stage
namein the strip.- Return type:
None- Parameters:
name (str)
detail (str)
- phase(name)[source]¶
Mark stage
namerunning for the duration of the block, then done (or failed).- Return type:
Iterator[None]- Parameters:
name (str)
- uncertainty_progress(done, total, eta)[source]¶
Show how far the uncertainty stage has got.
- Return type:
None- Parameters:
done (int)
total (int)
eta (float | None)
- finish(reason)[source]¶
The fit stage is over: show why the loop ended.
- Return type:
None- Parameters:
reason (str)
- update(*, epoch, loss, validation_loss, grad_norm, lr, epoch_time, true_diff, knobs, new_best, note=None)[source]¶
Record one finished epoch and redraw.
- Return type:
None- Parameters:
epoch (int)
loss (float)
validation_loss (float | None)
grad_norm (float)
lr (float)
epoch_time (float)
true_diff (float | None)
knobs (Mapping[str, float])
new_best (bool)
note (str | None)