Skip to main content

Quantum Canary

Qubit health checks for IBM superconducting hardware, and gate-error checks for IonQ trapped ions.

  1. Before your job: check the qubits you will use.
  2. Your jobs: run as normal, without Canary interrupting.
  3. Between jobs, if you want: check again as often as you like (most useful in long workflows).
  4. 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 the QISKIT_IBM_TOKEN and QISKIT_IBM_INSTANCE environment variables.
  • IonQ (an API key only; there is no instance or CRN): the IONQ_API_KEY environment 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") and canary.credentials.ionq_provider("ionq_api_token.txt"), or on the command line, --ibm-token-file, --ibm-instance-file and --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. Re-run the check.
  • 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 behind check.
  • canary.runner.run_simulation(...) and canary.simulation: the device simulator Canary was validated on, with every noise model and its source.

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.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for quantum-canary 0.9.0
File Size Uploaded Provenance Actions
quantum_canary-0.9.0.tar.gz 153.2 kB With provenance Details for quantum_canary-0.9.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for quantum-canary 0.9.0
File Interpreter ABI Platform Actions
quantum_canary-0.9.0-py3-none-any.whl Python 3 none any Details for quantum_canary-0.9.0-py3-none-any.whl

Total release size: 302.8 kB

Release files / quantum_canary-0.9.0.tar.gz

Download URL quantum_canary-0.9.0.tar.gz
Size 153.2 kB
Tags Source
SHA-256 checksum
How to use checksums
01564ec5cc0f49ebf885b365da62d54644c0a98d535b32453bfd077466095d7e
BLAKE2b-256 checksum
How to use checksums
b476e51fdc57db033c0d81b6bc44e40e3dc7bba0881f57d2da47933f35b2182f
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 6, 2026.

Transparency log

Release files / quantum_canary-0.9.0-py3-none-any.whl

Download URL quantum_canary-0.9.0-py3-none-any.whl
Size 149.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
14e0269bedff0930d0beed16f37f0c0c964455d17c2af7e9f13526cf9b70e8f5
BLAKE2b-256 checksum
How to use checksums
93e068b4000d77784be5ef6b2e195532a2e53ec63bf5d02d5414a50c8bc992cd
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 6, 2026.

Transparency log

Security for quantum-canary 0.9.0

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.

Select from 2 files

Attestation for quantum_canary-0.9.0.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 6, 2026.

Transparency log

A 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.

Release history Release notifications | RSS feed

This release

0.9.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page