Checkpoint Monitors¶
A monitor is a plain callable that names the values it wants as its parameters. The driver reads the signature once, at setup, and then calls the monitor by keyword with exactly those values.
def watch(iters, n_filled, best_logL): # free
bar.update(iters)
def watch(iters, elite_ij, elite_logL, grid): # free: read for the landscape
chart.show(elite_ij, elite_logL)
def watch(iters, logL_map): # one bounded transfer
queue.put((iters, logL_map))
def watch(iters, trees): # state read and rebuild
popup.update(iters, trees)
A value that costs a device read is read only when a monitor names it. An unknown name raises before any survey work starts. Every snapshot is a copy and can be pickled, so a monitor that sends checkpoints to another process is one line.
The default reporter shows the growth exponent beta under the QD-score rule,
and the coverage and precision rates under the rate rule.
bind_monitor
¶
bind_monitor(monitor, *, caps, n_checkpoints: int, rate_window: int = 1, halt_rule: str = 'qd_score') -> BoundMonitor | None
Resolve a monitor against the vocabulary and the backend.
monitor=None selects the default reporter for halt_rule.
monitor=False gives None, and the driver then calls nothing. Any
other value must be a callable.
Raises:
| Type | Description |
|---|---|
ValueError
|
An unknown parameter name, or a |
Source code in src/hifuku/monitor.py
Checkpoint
dataclass
¶
One checkpoint of a running survey.
logL_map and trees are None unless a monitor named them.
beta is the growth exponent of the QD-score at this checkpoint. See
:mod:hifuku.halt. It is None under the rate rule, before the guard,
and when the exponent is undecided.
closing is True only on the closing call. The driver makes that call
once, after the run ends, and only to a monitor that names
shoreline and runs with an alignment. The call repeats the free
values of the final checkpoint, including final=True. It gives
logL_map and trees as None, and adds shoreline, the
:class:~hifuku.analysis.Shoreline of the final archive, or None when it
cannot be computed. A monitor that names shoreline must also name
closing, or it cannot tell the closing call from the final
checkpoint.
Source code in src/hifuku/monitor.py
BoundMonitor
dataclass
¶
A monitor with its parameter names resolved.
Attributes:
| Name | Type | Description |
|---|---|---|
fn |
callable
|
The monitor. |
names |
frozenset[str]
|
The values to pass. A |
wants_map |
bool
|
True when the driver must read the log-likelihood grid. |
wants_trees |
bool
|
True when the driver must read the archive state and rebuild the trees. |
wants_shoreline |
bool
|
True when the driver must compute the shoreline of the final archive and make the closing call. |
Source code in src/hifuku/monitor.py
default_reporter
¶
default_reporter(n_checkpoints: int, rate_window: int = 1, stream=None, halt_rule: str = 'qd_score')
Build the monitor that runs when the caller gives none.
The reporter writes survey statistics to stderr. It is an ordinary monitor,
so it goes through the same signature check as any other monitor. It names
free values and shoreline.
Each run's lines are headed by the gene and the chart they measure, so a
batch that surveys nine markers into one log says which block is which. See
:func:_survey_heading.
The cadence comes from the budget. The reporter writes one line every
max(1, n_checkpoints // 8) checkpoints and always writes the last one.
A run of any size therefore gives about five to ten lines per gene. Output
goes to stderr so that stdout stays clean.
Each line also reports the quantity the halt rule reads. Under the
QD-score rule this is the growth exponent beta. Before the guard, or
while the exponent is undecided, the line shows beta (guard).
Under the rate rule the line shows the two rates. The rates need a
trailing window of rate_window checkpoints. Until that many exist the
rates have no value, and the line reports how much of the window has
filled instead. A reader then sees progress toward a halt rather than a
column of nan.
At the closing call the reporter writes one more line. It gives the edge z of the final archive on the per-tree Kishino-Hasegawa scale, the niche that sets it, and the z at the gate when there is one::
shorelines close below z = 1.22 (edge niche (31, 40)); gate at z = 4.43
When the shoreline cannot be computed, the line reads no shoreline for
this archive. See :func:hifuku.analysis.shoreline.