Save and resume a portable run¶
A run bundle keeps the data needed to inspect a search in one directory.
Its run.json records the seed, the configuration you passed to the
runner, the evaluation count, and checksums and relative paths for the
archive, history, lineage, and checkpoint. Open it with
qdpy.bundles.open_run_bundle() to verify those files before plotting.
Stop, move, and continue MAP-Elites¶
The example runs polynomial MAP-Elites on normalized Rastrigin. Pause
after 32 of its 96 evaluations, move the whole directory, and resume
with the same algorithm settings and evaluator. Keep the hidden
.run-state directory when moving a run you plan to resume.
python examples/run_bundle.py results/rastrigin --stop-after 32
mv results/rastrigin results/rastrigin-moved
python examples/run_bundle.py results/rastrigin-moved --resume-trusted
The resumed invocation performs 64 evaluations. The new manifest counts all 96 attempts and keeps the same run ID. The original proposal IDs follow the elites across restart, including elites that later become parents. The final archive, history, and lineage match the uninterrupted example at the same seed.
Independent figures¶
The archive, history and lineage are portable JSON or JSON Lines. A
recipient can regenerate the figures from run.json and its linked
files. Verification reads the bytes of any linked checkpoint to calculate
its checksum. Plotting uses the numeric artifacts.
python examples/run_bundle.py results/rastrigin-moved --plot-only --figures results/figures
The archive and ancestry regenerated after moving and resuming the run. The orange edge joins a parent evaluated before the saved pause to a child evaluated after it. The example also writes a time-lapse.¶
Configure a bundle from Python¶
Continue using qdpy.simple.run. Pass
qdpy.bundles.RunBundleOptions with an output directory to opt in.
The same search can run without checkpoints by leaving out
checkpoint_every. Set lineage=True to include measured parentage,
or set history_every=None to omit archive history.
from dataclasses import replace
from qdpy.benchmarks import illumination_rastrigin_normalised
from qdpy.bundles import RunBundleOptions, open_run_bundle
from qdpy.lineage import plot_lineage
from qdpy.simple import map_elites, run
settings = dict(dimension=4, budget=96, batch_size=8, shape=(8, 8),
fitness_domain=((0., 1.),), features_domain=((0., 1.),) * 2,
optimisation_task="maximisation")
bundle = RunBundleOptions(history_every=2, lineage=True, checkpoint_every=2)
run(map_elites(**settings), illumination_rastrigin_normalised, seed=329,
configuration=settings, output_dir="results/python-run",
bundle=replace(bundle, stop_after=32))
run(map_elites(**settings), illumination_rastrigin_normalised,
configuration=settings, output_dir="results/python-run",
bundle=replace(bundle, resume=True, trusted=True))
saved = open_run_bundle("results/python-run")
plot_lineage(saved.lineage_path, elite=saved.best_lineage_id)
Fresh bundles record an automatically chosen seed when you omit
seed. On resume, an omitted seed reuses the recorded one. Pass the
same resolved configuration, including the relevant simulator settings,
when rebuilding the optimiser. RunResult.evaluations describes the
current call. The checkpointed bundle’s manifest uses the cumulative
count across calls.
Both cadence options are in completed batches. Pausing between history captures saves the paused archive in the manifest and preserves the original history cadence. The final completed archive always gets a history frame when history is enabled.
After an abrupt exit, resume from the most recent working checkpoint. QDpy validates the history and lineage through that boundary, drops uncommitted telemetry, then evaluates the unsaved work again. The manifest describes the last published pause or completion and remains readable during recovery. Use one writer per directory and a filesystem that supports advisory locks.
Checkpointed bundles use the native checkpoint driver’s supported
optimisers and settings. The example uses a fixed Grid and a sequential
evaluator. A packed evaluator can use pack_size equal to the batch
size. Only resume a checkpoint from a trusted source in a compatible
runtime. For simulator state, random generators, and evaluation journals,
see Replay a saved search.