Skip to content

Repository files navigation

cr2-closed-loop-sqd

Closed-loop Sample-based Quantum Diagonalization (SQD) for the chromium dimer (Cr₂/STO-3G, CAS(12e,12o)). This code implements the workflow behind an upcoming, not-yet-published paper, which adapts the closed-loop methodology of Shirakawa et al., "Closed-Loop Calculations of Electronic Structure on a Quantum Processor and a Classical Supercomputer at Full Scale" (arXiv:2511.00224, 2025) with a minimal, closed-form amplitude update in place of the original's differential-evolution search.

Closed loop

Each iteration alternates a classical stage and a quantum stage:

  1. Classical setup (qc_chemistry.py, setup_molecule / compute_amplitudes): RHF reference over Cr₂/STO-3G (atomic-density guess, 0.3 Ha level shift), active-space integrals written to an FCIDUMP file, and the initial (t1, t2) amplitudes seeded from CCSD, cascading to MP2 and then Hartree-Fock if CCSD fails to converge -- expected for Cr₂'s strong multireference character.
  2. Quantum (quantum_circuit.py): builds the LUCJ ansatz from the current (t1, t2), submits it to IBM Quantum Cloud, and accumulates the sampled determinants into the monotonic bitstring pool that sbd (Selected Basis Diagonalization) diagonalizes next.
  3. Amplitude update (src/main.cpp, qc_chemistry.t2_from_rdm): reads the 1p/2p reduced density matrices that sbd writes, extracts new t2 amplitudes from them, and blends them with the previous iteration's amplitudes (carryover_scale in conf.toml) -- a closed-form update, with no parameter search. t1 stays fixed at its initial seed throughout.

An alternative update, natural-orbital rotation followed by a CCSD/MP2 rerun (qc_chemistry.t2_via_orbital_rotation), is also implemented; the active method is selected via [quantum.t2_update].method ("rdm" | "orbital_rotation" | "fixed") in conf.toml.

All algorithmic and active-space parameters (loop bounds, SBD/Davidson settings, t2 update method, molecule geometry, active space, SCF and CCSD settings) are set in conf.toml.

Execution on CESGA

The classical stage (main, C++/MPI, linking sbd) runs on CESGA under SLURM; the quantum stage (quantum_circuit.py) submits circuits to the IBM Quantum Cloud backend configured in conf.toml.

1. Fetch the sbd submodule

git submodule update --init --recursive

sbd (https://github.com/r-ccs-cms/sbd) is a git submodule under sbd/ and is required to build; CMakeLists.txt includes sbd/include directly.

2. Build environment

source ./setup_qmio.sh
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j

setup_qmio.sh loads the required CESGA modules (GCC, OpenBLAS, MPI) and points the build at the DMR and tomlc17 install prefixes. DMR_PATH must be set (CMakeLists.txt fails the configure step otherwise): src/ includes <dmr.h> and links libdmr even in the default build, because DMR is a build-time dependency regardless of whether reconfiguration is requested at runtime.

Two independent things determine what a given build actually does at runtime:

  • CMAKE_BUILD_TYPE -- Release (-O3) vs. the CMake default Debug (-O0, no optimization). Always build Release; Debug makes every reported timing meaningless.

  • -DLOOPQC_MALLEABLE=ON|OFF (default OFF) -- whether the run requests a DMR shrink/expand around the quantum stage. OFF builds the no-reconfiguration baseline used for the results in the accompanying paper: DMR stays linked and initialized, but src/main.cpp never asks for a shrink or an expand, so the SLURM allocation keeps its initial size for the whole run. ON builds the malleable variant that actually resizes.

    To build both side by side, e.g. for comparing the two:

    cmake -B build     -DCMAKE_BUILD_TYPE=Release
    cmake -B build-dmr -DCMAKE_BUILD_TYPE=Release -DLOOPQC_MALLEABLE=ON

3. IBM Quantum credentials

Set up IBM Quantum Cloud credentials once per environment before submitting any job:

python set_ibm_account.py

Edit the token and instance CRN in the script first. This saves the credentials to ~/.qiskit/qiskit-ibm.json and prints the target backend's status to confirm the account is working.

4. Submit a run

./send_batch_jobs.sh

This submits three independent SLURM jobs (RUN_TAG=r1, r2, r3), each running start_minidmr.sbatch and chained with --dependency=afterany so each repetition starts only after the previous one finishes. Every repetition writes to its own data/<RUN_TAG>/ directory, so the three runs never overwrite one another. Running three independent repetitions of the same configuration is how run-to-run variability is characterized under an otherwise identical setup.

start_minidmr.sbatch validates the environment before launching (build present and built in Release, dmr_wrapper on PATH, the Python interpreter for the quantum stage executable, and that adet_comm_size × bdet_comm_size × task_comm_size in conf.toml matches the requested MPI rank count) and fails fast with an explicit error otherwise.

Python environment for the quantum stage

python3.11 -m venv ~/venv-qiskit
source ~/venv-qiskit/bin/activate
pip install -r requirements.txt

Package versions in requirements.txt are pinned to match the closed-loop reference paper for reproducibility. LOOPQC_PYTHON (read by src/main.cpp) must point at this environment; it defaults to ~/venv-qiskit/bin/python3.11 in start_minidmr.sbatch.

Dependencies

  • Python 3.11 (ffsim, qiskit, qiskit-ibm-runtime, qiskit-addon-sqd, pyscf)
  • GCC >= 14 with C++23 support (std::println, std::ranges::to)
  • CMake >= 3.20
  • Open MPI, OpenMP, BLAS/LAPACK
  • tomlc17
  • sbd (Selected Basis Diagonalization, git submodule)
  • DMR (build-time dependency always; used for actual reconfiguration only when built with -DLOOPQC_MALLEABLE=ON)

Citation

This code implements the workflow of a paper that is not yet published; a citation for it will be added here once available.

It builds on the closed-loop methodology of:

Shirakawa, T., Robledo-Moreno, J., Itoko, T., et al. (2025). Closed-loop calculations of electronic structure on a quantum processor and a classical supercomputer at full scale. arXiv:2511.00224.

About

Closed-loop Sample-based Quantum Diagonalization (SQD) for Cr₂/STO-3G on IBM Quantum Cloud + CESGA, with a minimal closed-form amplitude update in place of parameter search.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages