Skip to content

About

Code and data for the Shadow GSE project on IQM hardware

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Shadow-based generalized subspace expansion

Code and data for "Shadow-Based Generalized Subspace Expansion for Molecular and Periodic Ground States", L. Joseph, T. S. Hardikar, K. Heitritter and J. Brown (qBraid Co.).

Method

A state ρ prepared by an optimized VQE circuit is measured after a random unitary U, either a product of single-qubit Cliffords (Pauli shadows) or an n-qubit Clifford (Clifford shadows). Each shot (U, b) is inverted into a snapshot, ρ̂ = ⊗_j (3 U_j†|b_j⟩⟨b_j|U_j − I) for Pauli and ρ̂ = (2ⁿ + 1) U†|b⟩⟨b|U − I for Clifford shadows (Eqs. 3–4 of the paper). The snapshots are averaged into four independent estimators ρ̂_0..ρ̂_3. The energy E_GSE is the lowest eigenvalue of H a = S a E with H_jk = Tr(B_j† H B_k) and S_jk = Tr(B_j† B_k) over the 13-element basis {I} ∪ {ρ̂_b, ρ̂_b², ρ̂_b³} (b = 0..3), solved with scipy.linalg.eigh without regularizing S.

Conventions

  • N is the number of snapshots (for exhaustive Pauli runs: settings × shots per setting).
  • Binning. The snapshots, in recorded order, are split into 30 consecutive bins of four sub-batches. Curve point g = 1..29 uses bins 0..g−1, so points are evenly spaced in N and the last point uses 29/30 of the shots.
  • Errors are |E_GSE − E_optVQE| unless a file name ends in _FCI. E_optVQE is the energy of the optimized ansatz state, which is the noiseless limit of the method.
  • Energies are in hartree (Ha) in the data files.

Layout

folder contents
gse_shadows/ the package: snapshot inversion and measurement settings (shadows.py), Aer sampling (sampling.py), noise model (noise.py), binning (binning.py), GSE solve (gse.py), leading-eigenvector diagnostics (diagnostics.py), N → ∞ extrapolation (extrapolate.py), basic fits (fits.py), crossover fits of Table III (onset.py), file formats (io.py), figure style (plotting.py); build/ rebuilds the benchmark systems
notebooks/ h2o_shadow_gse.ipynb: the pipeline for H2O at four qubits, step by step in one notebook
simulations/ run_shadow_gse.py: one simulation (sample, reconstruct, GSE curve)
hardware_runs/ submission and retrieval scripts for the IQM Garnet run, and build_shadow_record.py
figures/ one script per figure; make_all.py writes all of them to figures/out/
analysis/ quoted_numbers.py recomputes every number quoted in the paper; scaling_table.py computes Table III; paper_runs.py names the runs behind each item
data/ systems, convergence curves, shot records and the hardware run (see data/README.md)
tests/ checks against the archived data and against exact results
environment/ pinned requirements

Notebook

notebooks/h2o_shadow_gse.ipynb runs the whole pipeline for H2O in the four-qubit active space in one place, in the order of the method: molecule and reference energies (PySCF through Tangelo), VQE with the QCC ansatz, the shadow measurement settings, shot sampling with Qiskit Aer (noiseless or with the noise model), reconstruction of the density matrix in 30 bins of four batches, the 13-element GSE solve, and the error against the number of shots. The shadow type, noise and number of shots are set in one cell; the default (Clifford shadows with the noise model, 10⁵ shots) runs in about a minute and a half and reaches chemical accuracy. It needs environment/requirements-build.txt. Its random settings are not seeded, so each run gives a different curve; the paper's runs were made with the package below, which implements the same steps with seeded random numbers.

Reproducing the paper

Python 3.12:

python -m venv .venv && source .venv/bin/activate
pip install -r environment/requirements.txt

python tests/run_tests.py          # 19 tests, about 15 s
python figures/make_all.py         # all figures -> figures/out/, about 1 min
python analysis/quoted_numbers.py  # every quoted number -> analysis/out/numbers.md, about 2 min

analysis/out/numbers.md lists each number of the manuscript next to its recomputed value. No step samples new shots: figures and numbers use the stored curves, and the shot-based results (Fig. 2 hardware curve, Fig. 6, App. B regularization test) are recomputed from stored shots.

paper item script data
Fig. 1 figures/fig1_pauli_vs_clifford.py h2o_4q_{pauli,clifford}_{noiseless,noisy}_1e6
Fig. 2 figures/fig2_hardware.py exhaustive-Pauli runs; hardware shot record
Fig. 3 (a, b) figures/fig3_scaling.py h2o_{4,6,8,10}q_*_noiseless_1e6
Fig. 4 (a, b), Table II figures/fig4_extrapolation.py, analysis/quoted_numbers.py the noiseless 10⁶-shot runs
Fig. 5 (a, b), Sec. III C figures/fig5_mos2.py, analysis/quoted_numbers.py mos2_*
Fig. 6, App. E figures/fig6_hw_diagnostics.py, analysis/quoted_numbers.py three 97 200-shot records; hardware metadata and calibration
Table I analysis/quoted_numbers.py data/systems/h2o_*
Table III, App. C analysis/scaling_table.py, analysis/quoted_numbers.py the 18 noiseless runs, h2o_8q_*_noiseless_1e5, results/seeds/
App. B analysis/quoted_numbers.py systems, shot records, hardware calibration
App. D analysis/quoted_numbers.py the noiseless 10⁶-shot runs

Figure file names are those included by the manuscript source: Fig. 2 is written to fig3_exhaustive_hw_*, and Fig. 3 to fig2a_scaling_curves_* and fig2b_scaling_vs_nq_*. Figs. 1, 2, 3 and 5 are written with the error from E_optVQE (_optVQE, used in the paper) and from E_FCI (_FCI).

Simulations

python simulations/run_shadow_gse.py --system h2o_4q --shadow clifford --noise noisy --shots 100000 --seed 1

--system is a folder of data/systems/; --shadow is pauli, pauli_exhaustive or clifford; a run is fixed by --seed. The noise model (gse_shadows/noise.py) applies a one-qubit depolarizing channel (parameter 7×10⁻⁴) after each h, s, t, rx, ry, rz, u1, u2, u3 gate, a two-qubit depolarizing channel (6.4×10⁻³) after each cx and cz gate, and an independent bit flip with probability 6×10⁻² on each measured qubit; circuits, including the measurement-basis rotations, are simulated as built. Noiseless Pauli runs of 10⁶ shots take about 10 s at 4 qubits and 40 s at 6 on a laptop; Clifford and noisy runs simulate each shot (about 0.6 ms per Clifford shot at 4 qubits). Memory is dominated by the dense estimators, 120 × (2ⁿ)² complex numbers (2 GB at 10 qubits). gse_shadows/build/ rebuilds the systems and needs environment/requirements-build.txt (Tangelo, OpenFermion, PySCF, Qulacs).

Hardware

The submission and retrieval scripts document how the run in the paper was made. They cannot be run without your own IQM Resonance account and API token; no token is included in this repository. They are not needed to reproduce the paper: the bitstrings, job metadata and calibration of the run are in data/hardware/, and build_shadow_record.py and the figure scripts work from those files alone.

hardware_runs/submit_pauli_exhaustive.py builds the 81 measurement-basis circuits, pins virtual qubits 0–3 to QB3, QB4, QB1, QB2 of IQM Garnet, checks that every transpiled circuit has this layout, and submits one batch of 1200 shots per circuit with dynamical decoupling through IQM Resonance (the token is read from the environment variable IQM_TOKEN; environment in environment/requirements-hardware.txt). retrieve_pauli_exhaustive.py saves the bitstrings, and build_shadow_record.py orders them for the analysis. The data of the run in the paper (19 June 2026) are in data/hardware/; no readout-error mitigation is applied.

Acknowledgement

Claude Opus 5.5 and earlier models (Anthropic) were used to write and run the simulation and analysis code, to analyse data and prepare figures, and to assemble this repository. All of it was reviewed and checked by the authors.

About

Code and data for the Shadow GSE project on IQM hardware

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages