infer_restart_shape

jaxrens.init.restart.infer_restart_shape(bundle)[source]

Infer which run_ns entry-point matches the loaded restart bundle.

Inspects the Python type of the value returned by load_restart:

  • (WalkerSet, RestartBundle) tuple → "single" — feed into run_ns(restart_state=bundle).

  • list[RestartBundle] → "parallel" — feed into run_ns_parallel(..., restart_states=bundle).

  • list[list[RestartBundle]] → "multi_gpu" — feed into run_ns_multi_gpu(..., restart_states=bundle).

Parameters:

bundle (tuple[WalkerSet, RestartBundle] | list[RestartBundle] | list[list[RestartBundle]]) – Return value of load_restart(path).

Returns:

One of "single", "parallel", or "multi_gpu".

Raises:

TypeError – If bundle does not match any of the three expected shapes.

Return type:

Literal[‘single’, ‘parallel’, ‘multi_gpu’]

Example:

loaded = load_restart("run.checkpoint.h5")
shape = infer_restart_shape(loaded)
if shape == "single":
    ws, b = loaded
    run_ns(..., restart_state=b)
elif shape == "parallel":
    run_ns_parallel(..., restart_states=loaded)
else:  # "multi_gpu"
    run_ns_multi_gpu(..., restart_states=loaded)