pygsti.tools.mpitools.write_mpi_runner_artifacts#
- write_mpi_runner_artifacts(protocol_obj, run_kwargs, artifact_dir, artifacts_persistent)#
Serialize a protocol run into a self-contained directory for MPI workers.
Writes three files into artifact_dir:
protocol/— the serialized protocol (viaprotocol_obj.write).volatile_run_kwargs.pkl— pickled keyword arguments forprotocol.run.The “volatile” prefix indicates that this file’s contents shouldn’t be treated as portable or long-lived.
mpi_runner.py— a stand-alone Python script that each MPI worker executes. The scriptreads the data, protocol, and kwargs from disk, then
calls
protocol.run(data, comm=MPI.COMM_WORLD, **kwargs), andhas rank 0 write the results back to data_dir.
- Parameters:
protocol_obj (Protocol) – The protocol to serialize. Must implement a
write(dirname)method.run_kwargs (dict) – Keyword arguments forwarded to
protocol.run. Modified in place:disable_checkpointingdefaults toTrueif not already set.artifact_dir (path-like) – Directory in which to write the three artifacts. Must already exist, and must eventually contain serialization of a
ProtocolDataobject Embedded verbatim into the runner script.arifacts_persistent (bool) – A flag indicating if the arifact_dir should be assumed persistent or not. If the directory is NOT persistent then we disable checkpointing, which would only slow us down. If a directory IS persistent then we log a warning about serializing with pickle.
artifacts_persistent (bool)
- Returns:
Absolute path to
mpi_runner.py.- Return type:
str
Notes
See RUN_KWARGS_PICKLE_MSG for a warning about this function’s behavior when artifact_dir is persistent.