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.
We should add a facility for checkpointing; writing the contents of a
Quregto a file, so it may be later parsed and loaded into anotherQureg. This is useful for HPC jobs vulnerable to timeout or other failures - an evolvingQuregcan 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 relevantQuregparameters to the file, like the number of qubits, and whether theQuregis a statevector or density matrix, in addition to the full set of amplitudes. It should not record incidental deployment information (like whetherQuregis multithreaded), nor any property which can be inferred from the others (likenumAmps).The second function (
createQuregFromFile) should parse the file, create aQuregof 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
Quregdeployment schemes, like GPU-acceleration and distribution. Checkpointing should be implemented via integratingADIOS2. This requires optionally compiling and linkingADIOS2, when a CMake variable such asENABLE_CHECKPOINTING=1is specified, exposing the above two functions.