Skip to content

Add Qureg checkpointing. #747

Closed
Closed

Description

@TysonRayJones

Note

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:

void saveQuregToFile(Qureg qureg, const char* fn);
Qureg createQuregFromFile(const char* fn);

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.

Activity

  1. added
    unitaryHACK2026
    on Jun 3, 2026
  2. ashmitjsg commented on Jun 4, 2026

    @ashmitjsg
    Contributor

    Hey @TysonRayJones, I opened #780 implementing this.

    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.

  3. sim-eng-ii commented on Jun 11, 2026

    @sim-eng-ii

    Should this feature be "OFF" by default? @TysonRayJones

  4. TysonRayJones commented on Jun 16, 2026

    @TysonRayJones
    MemberAuthor

    Completed by @ashmitjsg 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementunitaryHACK2026

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions