neighbayes.config.checkpoints¶
-
neighbayes.config.checkpoints(path, *, every=
300.0)[source]¶ Save long JAX Gibbs fits to disk as they run, and resume them after a crash.
A context manager. Every JAX Gibbs run started inside it is saved under
pathat the end of a 128-sweep chunk, at most once everyeveryseconds, in a directory named by a fingerprint of everything that determines its draws: the run’s lengths, the sampler’s structure, every chain’s starting state and random keys, and the data. Starting the same fit again, with the same data, options andrandom_seed, inside the samepathresumes it from its last save, and the draws are those an uninterrupted run would have returned. A fit whose inputs differ starts afresh in its own directory, and so does any fit without a fixedrandom_seed. A run that finishes removes its directory.- Parameters:¶
Examples
>>> from neighbayes.config import checkpoints >>> with checkpoints("runs/la-flows"): ... idata = model.fit(backend="jax", random_seed=7)Notes
With
enable_compile_cache()a resumed fit also skips compiling its sampler. The NumPy samplers are not checkpointed. Checkpoints are pickles; load only those you wrote.