Quantum Canary
Qubit health checks for IBM superconducting hardware, and gate-error checks for IonQ trapped ions.
- Before your job: check the qubits you will use.
- Your jobs: run as normal, without Canary interrupting.
- Between jobs, if you want: check again as often as you like (most useful in long workflows).
- After: check again and compare. If a qubit changed, results that depend on that qubit may be inaccurate.
Each check is its own short job: 74 circuits per qubit (8,640 shots) that measure T1, T2 (echo), T2* (Ramsey), the qubit's frequency offset Δω and its single-qubit gate error (randomized benchmarking: 60 random Clifford sequences, error per pulse), with error bars and a check that the fits can be trusted. Qubits are probed in at most two parallel groups, never two neighbours in the same circuit, so checking more qubits costs little extra QPU time.
Install
pip install quantum-canary
Python 3.10 or newer. From a clone of this repository: pip install -e ..
Use
import quantum_canary as canary
from qiskit_ibm_runtime import QiskitRuntimeService
backend = QiskitRuntimeService().backend("ibm_kingston")
before = canary.check(backend, [13, 14]) # one short job
before.print() # numbers, fit, health, DD advice
before[13].t1, before[13].t2_star, before[13].health
# ... run your jobs ...
after = canary.check(backend, [13, 14])
d = canary.compare(before, after)
d.print()
d.changed # qubits that moved beyond their error bars
To check between jobs, as often as you like:
mon = canary.Monitor(backend, [13, 14])
mon.check() # baseline
for batch in my_batches:
sampler.run(batch).result() # your job, untouched
mon.check() # a few seconds of QPU time
if mon.changed: # moved since the baseline?
... # re-check, re-learn mitigation or move qubits
mon.print() # every check against the baseline
mon.save("checks/")
Checking many times raises the chance of a false alarm, so Monitor (and
compare with more than two files on the command line) raises the |z| limit
with the number of checks: the chance of any false alarm over the whole
workflow stays that of a single comparison.
Results can be saved and reloaded: before.save("before.json"),
canary.load("before.json"). No hardware at all: canary.simulate(3).
Import the package as canary (Qiskit code usually uses qc for a circuit).
No IBM account yet? Use a fake backend with real device calibration, which runs locally:
from qiskit_ibm_runtime.fake_provider import FakeProviderForBackendV2
backend = FakeProviderForBackendV2().backend("fake_fez")
From the terminal:
quantum-canary # commands, examples, credentials
quantum-canary check ibm_kingston 13,14 # IBM hardware
quantum-canary check fake_fez 13,14 # local, no account
quantum-canary check ibm_kingston 13,14 --json before.json
quantum-canary compare before.json after.json # what changed
quantum-canary compare c0.json c1.json c2.json # every check vs the first
check prints each qubit's T1, T2, T2*, frequency offset and gate error with
error bars, a fit column (each probe's χ²/dof against its limit: whether
the numbers can be trusted) and the health verdict with its reason.
Credentials
Quantum Canary stores no secrets and searches for none. It uses the same lookup as the vendors' libraries:
- IBM: the account saved once with
QiskitRuntimeService.save_account(channel="ibm_quantum_platform", token="...", instance="...")(kept in~/.qiskit/qiskit-ibm.json, outside your project), or theQISKIT_IBM_TOKENandQISKIT_IBM_INSTANCEenvironment variables. - IonQ (an API key only; there is no instance or CRN): the
IONQ_API_KEYenvironment variable. - A secret kept in a file is used only when you name the file, in Python,
canary.credentials.ibm_service("ibm_api_token.txt", "ibm_crn_instance.txt")andcanary.credentials.ionq_provider("ionq_api_token.txt"), or on the command line,--ibm-token-file,--ibm-instance-fileand--ionq-token-file. The file is read once and handed to the vendor's constructor; it is never printed, logged, exported or saved in a Report. Keep such files out of version control (add them to.gitignore).
What the answers mean
- GREEN: every probe's fit converged and passed its χ²/dof limit, and T2* is within 20% of T2.
- YELLOW: a probe's χ²/dof is over its limit (that probe's numbers may be wrong), or T2* and T2 differ by more than 20% (slow frequency noise). The report says which.
- RED: a fit did not converge. Generally try to avoid using such uncertain qubits in your workflows, and try to re-characterize if feasible.
- On simulated qubits that follow the model exactly, each probe goes over its limit about 1% of the time (randomized benchmarking about 2.5%), and a qubit comes out YELLOW about 9% of the time: a little over half from a fit, the rest from the T2*/T2 rule, which estimation noise alone can trip.
- The verdict describes the measurement, not how good the qubit is: a qubit with a short T1 that is measured cleanly is GREEN. Read the numbers for that.
- Dynamical decoupling is recommended for a qubit when T2*/T2 < 0.8
(slow frequency noise that decoupling refocuses). Turn it on in your
sampler with
dynamical_decoupling.enable = True. - Frequency offset: when |Δω|·T2* > 1 rad the qubit's offset turns a large phase while it sits idle. A steady offset is best removed with a virtual-Z frame update or a frequency recalibration; DD helps only if it drifts.
- at bound in the fit column means a fit stopped at its allowed limit (for example T2 = 2·T1), so that value's error bar is not reliable.
- Drift is a two-sample z-test on each parameter, Holm-corrected across the qubit's four parameters (T1, T2, Δω and gate error; T2* feeds the health verdict instead), at |z| > 2 (raised for repeated checks).
- Canary measures each qubit with its neighbours idle in |0⟩, the usual characterisation condition.
IonQ
canary.check works on IonQ too: pass a qiskit-ionq backend
(IonQProvider(key).get_backend("qpu.forte-1", gateset="native")) and a list of
ions, or on the command line quantum-canary check qpu.forte-1 0,3
(see Credentials above). IonQ's native gates (GPi and GPi2, with ZZ on Forte or
MS on Aria) include no delay instruction, so the T1, T2, T2* and
frequency-offset probes cannot run there (with T1 and T2 seconds long they
would also need nearly twelve hours of circuit time per check); only the
gate error ε is measured, with IonQ's debiasing off. By default the ions share
circuits, each running its own random sequences, so ε includes crosstalk;
canary.run_ionq(backend, ions, parallel=False) probes one ion at a time. The
Report, save/load, compare, Monitor and the CLI work as on IBM; health is
RED if the gate fit failed and YELLOW if its χ²/dof is over the gate probe's
limit (there is no T2*/T2 rule).
For a cost limit use canary.run_ionq(backend, ions, max_cost=...), which
refuses a run whose IonQ estimate is higher, and
canary.Report(canary.ionq.to_canary_report(...)) for the same Report.
Quantum Canary never prices runs itself.
Advanced
canary.runner.run_ibm(backend, qubits): the full report behindcheck.canary.runner.run_simulation(...)andcanary.simulation: the device simulator Canary was validated on, with every noise model and its source.
Reproducing the paper
Everything behind the paper's figures, tables and Appendix A is in research/.
Install the pinned stack (it records the versions each part used) and the package:
pip install -r research/requirements.txt
pip install -e .
cd research/fig_generation
Data (in research/data/) |
Produced by | Paper output | Script in research/fig_generation/ |
|---|---|---|---|
ideal_parity.csv |
research/ideal_parity.py (workflow ideal_parity.yml) |
Fig. 2, Appendix A5 | fig2.py, derivations.py |
nisq_benchmark.csv (+ shard_inputs/ metadata) |
research/nisq_benchmark.py (workflow nisq_benchmark.yml) |
Figs. 3, 4, S1; Tables IV, S1–S6; the simulated predictions in Fig. 5 and Tables H1, H3 | fig3.py, fig4.py, fig5.py, table1.py, fig6.py, table_hw.py |
hardware/ibm_kingston_20261026T014902Z/ |
research/ibm_hardware.py sandwich ibm_kingston |
Figs. 5, S2; Tables H1–H9; Appendix A2, A4 | fig6.py, fig7.py, table_hw.py, derivations.py |
hardware/ionq_qpu.forte-1_[A-D]_* |
research/ionq_hardware.py submit A,B,C,D qpu.forte-1 MAX_COST, then collect qpu.forte-1 |
Fig. 6 | fig8.py |
| none | Fig. 1 (architecture) and Appendix A1, A3 | fig1.py, derivations.py |
Each script writes to research/figures/ (figN.pdf; table1.tex, tables_supp.tex,
tables_hw.tex). Script and paper numbering differ for three figures: fig6.py is Fig. 5,
fig8.py is Fig. 6, and fig5.py and fig7.py are Figs. S1 and S2. table_hw.py,
fig8.py and derivations.py also print the numbers the text quotes that no table shows.
Hardware data other than the ibm_kingston_20261026T014902Z run and IonQ runs A–D, and
everything in research/data/archive/, come from earlier versions of the package and are
not used.
Citing
If Quantum Canary helps your work, please cite it: the "Cite this repository" button on GitHub (from CITATION.cff) gives the reference.
License
MIT. See LICENSE.
Metadata
Release files for quantum-canary 0.9.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| quantum_canary-0.9.1.tar.gz | 154.8 kB | With provenance | Details for quantum_canary-0.9.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| quantum_canary-0.9.1-py3-none-any.whl | Python 3 | none | any | Details for quantum_canary-0.9.1-py3-none-any.whl |
Total release size: 305.2 kB
Release files / quantum_canary-0.9.1.tar.gz
| Download URL | quantum_canary-0.9.1.tar.gz |
|---|---|
| Size | 154.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c80d08322c7188bde41c5c3ba14c966923a847b0a0ec949f88ad646b27d45f65
|
|
BLAKE2b-256 checksum How to use checksums |
00584292400cb31786d27452eb650bbb6e01f4e62fa050afdcaefa03ba367d40
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.
Transparency logRelease files / quantum_canary-0.9.1-py3-none-any.whl
| Download URL | quantum_canary-0.9.1-py3-none-any.whl |
|---|---|
| Size | 150.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a8d1eae46e1ec67f31b01a2f951cd9279bb3f50c12b8300f0d52af696142ab96
|
|
BLAKE2b-256 checksum How to use checksums |
83fca340faf372781b69a2b849458038510f3a095f47f24b0d5399d236136e36
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.
Transparency logSecurity for quantum-canary 0.9.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for quantum_canary-0.9.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.