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, 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.
bind_monitor
¶
Resolve a monitor against the vocabulary and the backend.
monitor=None selects the default reporter. 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.
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. |
Source code in src/hifuku/monitor.py
default_reporter
¶
Build the monitor that runs when the caller gives none.
The reporter writes survey statistics to stderr. It is an ordinary monitor that names free values only, so it goes through the same signature check as any other monitor.
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.
The halt rates need a trailing window of gate_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.