You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For all development, please work out of the devel branch
We should add a facility for checkpointing; writing the contents of a Qureg to a file, so it may be later parsed and loaded into another Qureg. This is useful for HPC jobs vulnerable to timeout or other failures - an evolving Qureg can be occasionally written to disk and resumed in a subsequent process.
Implementing checkpointing involves defining two new API functions within qureg.cpp:
The first function (saveQuregToFile) should record relevant Qureg parameters to the file, like the number of qubits, and whether the Qureg is a statevector or density matrix, in addition to the full set of amplitudes. It should not record incidental deployment information (like whether Qureg is multithreaded), nor any property which can be inferred from the others (like numAmps).
The second function (createQuregFromFile) should parse the file, create a Qureg of the specified size, and populate its amplitude buffers with the file contents.
The challenge of checkpointing is performing all this without excessive memory usage, and handling the various Qureg deployment schemes, like GPU-acceleration and distribution. Checkpointing should be implemented via integrating ADIOS2. This requires optionally compiling and linking ADIOS2, when a CMake variable such as ENABLE_CHECKPOINTING=1 is specified, exposing the above two functions.
saveQuregToFile() and createQuregFromFile() are added to qureg.cpp, behind a new CMake option ENABLE_CHECKPOINTING (requiring ADIOS2). The file records only the Qureg dimension and amplitudes - never deployment fields - so a Qureg can be restored under a different deployment than it was saved with. Amplitudes are written as an ADIOS2 global array with each node contributing only its local slice, so it streams without excessive memory and is distribution-ready; GPU state is synced to host before writing and back after reading.
I've verified bit-exact statevector and density-matrix round-trips (CPU, single-node) with a guarded unit test, and confirmed the default (non-checkpointing) build is unaffected. The distributed and GPU paths are written but not yet exercised here (my ADIOS2 was built MPI-off) - happy to extend/verify those, and to adjust anything (e.g. the file-format/metadata conventions, or the CMake option name) to your preference.
Activity
ashmitjsg commentedon Jun 4, 2026
Hey @TysonRayJones, I opened #780 implementing this.
saveQuregToFile()andcreateQuregFromFile()are added toqureg.cpp, behind a new CMake optionENABLE_CHECKPOINTING(requiring ADIOS2). The file records only theQuregdimension and amplitudes - never deployment fields - so aQuregcan be restored under a different deployment than it was saved with. Amplitudes are written as an ADIOS2 global array with each node contributing only its local slice, so it streams without excessive memory and is distribution-ready; GPU state is synced to host before writing and back after reading.I've verified bit-exact statevector and density-matrix round-trips (CPU, single-node) with a guarded unit test, and confirmed the default (non-checkpointing) build is unaffected. The distributed and GPU paths are written but not yet exercised here (my ADIOS2 was built MPI-off) - happy to extend/verify those, and to adjust anything (e.g. the file-format/metadata conventions, or the CMake option name) to your preference.
sim-eng-ii commentedon Jun 11, 2026
Should this feature be "OFF" by default? @TysonRayJones
TysonRayJones commentedon Jun 16, 2026
Completed by @ashmitjsg 🎉