qtiming Timing verifier for dynamic quantum circuits QT-0.1.0 · alpha · 2026-11-27 Source
On this page

qtiming in CI#

Question: can I make a pull request fail when a circuit's timing breaks, and see the finding in GitHub?

Yes: check has stable exit codes and four report formats, one of which is SARIF, the format GitHub code scanning reads. Reference: Command reference, Reading a verdict.

The program#

tp_sync is teleportation whose idle time on q2 must not depend on the measurement outcome. It does, so a CI gate should catch it.

_show.source("teleportation/tp_sync.qasm")
OPENQASM 3.0;
// Teleportation with one correction under the SYNC policy: no padding, the arm starts as soon
// as the result arrives. Expected to be REFUTED where idle gaps must not vary (O4).
qubit[3] q;
bit[2] c;

h q[1];
cx q[1], q[2];
cx q[0], q[1];
h q[0];
c[0] = measure q[0];
c[1] = measure q[1];

@timing.policy sync
box {
    if (c[1]) {
        x q[2];
    }
}

Exit codes are the gate#

A CI step fails on any non-zero exit. check exits 0 proved, 1 refuted, 2 usage error, 3 unknown, 4 internal.

prog = "benchmarks/families/teleportation/tp_sync.qasm"
basic = "benchmarks/families/teleportation/tp_basic.qasm"
code, out = _show.run("check", prog, "--contract", "ibm_heron")
assert code == 1 and out.startswith("REFUTED")
REFUTED  (contract ibm_heron, policy sync, sha256 9cf4d27a06ae)
  why: O4 at node 11: idle gap on q2 must not vary with outcomes or latencies
  O4 failed at benchmarks/families/teleportation/tp_sync.qasm:17 (tier 2)
  assumptions (weakest class: vendor):
    ff.default: [0 ns, 600 ns]  vendor: IBM blog, 2025-11-19 (feedforward about 600 ns); vendor claim, not a certified bound
  O4: 9 obligation(s): proved (tier 0, margin 0 ns); refuted (tier 2)
  timeline (counterexample):
    t(ns)     0                                                2406
    q0        ....ch.....................................................m.
    q1        h.c.c......................................................m.
    q2        ..c.........................................................x
  timeline (second execution):
    t(ns)     0                                                2404
    q0        ....ch......................................................m
    q1        h.c.c......................................................m.
    q2        ..c.........................................................x
  not checked by this build: O4a (off by default), O6 (blocking calls), O8 (grid), O9 (loop windows), O7 for SYNC with a spread bound
[exit 1]

tp_basic is PROVED-UNDER (it relies on a vendor-claimed latency). By default that exits 0; --strict-proved makes a gate that refuses assumptions exit 1.

code, out = _show.run("check", basic, "--contract", "ibm_heron")
assert code == 0 and out.startswith("PROVED-UNDER")
code, out = _show.run("check", basic, "--contract", "ibm_heron", "--strict-proved")
assert code == 1
PROVED-UNDER  (contract ibm_heron, policy sync, sha256 9cf4d27a06ae)
  assumptions (weakest class: vendor):
    ff.default: [0 ns, 600 ns]  vendor: IBM blog, 2025-11-19 (feedforward about 600 ns); vendor claim, not a certified bound
  O2b: 1 obligation(s): proved (tier 1, margin 0 ns)
  O3: 2 obligation(s): proved (tier 1, margin 2400 ns)
  O4: 11 obligation(s): proved (tier 0, margin 0 ns); proved (tier 1, margin 0 ns)
  O7: 1 obligation(s): proved (tier 1, margin 0 ns)
  not checked by this build: O4a (off by default), O6 (blocking calls), O8 (grid), O9 (loop windows), O7 for SYNC with a spread bound
[exit 0]


PROVED-UNDER  (contract ibm_heron, policy sync, sha256 9cf4d27a06ae)
  assumptions (weakest class: vendor):
    ff.default: [0 ns, 600 ns]  vendor: IBM blog, 2025-11-19 (feedforward about 600 ns); vendor claim, not a certified bound
  O2b: 1 obligation(s): proved (tier 1, margin 0 ns)
  O3: 2 obligation(s): proved (tier 1, margin 2400 ns)
  O4: 11 obligation(s): proved (tier 0, margin 0 ns); proved (tier 1, margin 0 ns)
  O7: 1 obligation(s): proved (tier 1, margin 0 ns)
  not checked by this build: O4a (off by default), O6 (blocking calls), O8 (grid), O9 (loop windows), O7 for SYNC with a spread bound
[exit 1]

A missing file is a usage error, exit 2, so a broken path in your workflow is distinguishable from a timing failure:

code, out = _show.run("check", "no_such_file.qasm", "--contract", "ibm_heron")
assert code == 2
error: E-CLI-PROGRAM: no program found for 'no_such_file.qasm'
  hint: pass an OpenQASM 3 file (.qasm); QPY files use .qpy
[exit 2]

Report formats#

--format json is for scripts, sarif for code scanning, html for a human (it embeds the SVG timeline), text is the default. --out FILE writes to a file instead of stdout.

d = Path(tempfile.mkdtemp())
for fmt in ("json", "sarif", "html"):
    code, _ = _show.run("check", prog, "--contract", "ibm_heron", "--format", fmt, "--out", d / f"r.{fmt}", show=False)
    assert code == 1 and (d / f"r.{fmt}").stat().st_size > 0
rep = json.loads((d / "r.json").read_text(encoding="utf-8"))
print(rep["verdict"], "| keys:", ", ".join(rep))
assert rep["verdict"] == "REFUTED" and "counterexamples" in rep
REFUTED | keys: verdict, policy, contract, assumptions, weakest_class, obligations, counterexamples, reasons, not_checked, notes, max_safe

SARIF: one finding per failed obligation#

Each SARIF result has a rule id, a level, a message and a source location. The assumptions the verdict relies on are note-level results; lint findings are warnings.

sarif = json.loads((d / "r.sarif").read_text(encoding="utf-8"))
run = sarif["runs"][0]
for r in run["results"]:
    loc = r["locations"][0]["physicalLocation"]
    uri = loc["artifactLocation"]["uri"].replace("\\", "/")
    uri = uri[uri.find("benchmarks/"):] if "benchmarks/" in uri else uri
    line = loc.get("region", {}).get("startLine", "-")
    print(f'{r["level"]:8} {r["ruleId"]:16} {uri}:{line}')
errors = [r for r in run["results"] if r["level"] == "error"]
assert sarif["version"] == "2.1.0" and run["properties"]["verdict"] == "REFUTED"
assert len(errors) == 1 and errors[0]["ruleId"] == "V-O4"
error    V-O4             benchmarks/families/teleportation/tp_sync.qasm:17
note     V-ASSUME         program:-
warning  E-LINT-IBM-BOX   benchmarks/families/teleportation/tp_sync.qasm:14

The same finding drawn as a code-scanning annotation, built from the real SARIF above (not a screenshot of GitHub):

error · V-O4
O4: idle gap on q2 must not vary with outcomes or latencies
benchmarks/families/teleportation/tp_sync.qasm:17:8
Counterexample: outcomes {"c[1]@m6": 1}, latencies {"ff.default@m5": "0", "ff.default@m6": "1/2"} (dt)
Tier 2, policy sync, fingerprint 84c7fe676e9c

Example workflow#

Shown as text; this repository does not ship it under .github. continue-on-error lets the SARIF upload run even when the check fails, then a final step re-applies the failure.

WORKFLOW = """\
name: timing
on: [pull_request]
permissions:
  contents: read
  security-events: write
jobs:
  qtiming:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with: { python-version: "3.12" }
      - run: pip install "qtiming[z3]"
      - id: check
        run: qtiming check circuits/tp_sync.qasm --contract ibm_heron --format sarif --out qtiming.sarif
        continue-on-error: true
      - uses: github/codeql-action/upload-sarif@v3
        with: { sarif_file: qtiming.sarif }
      - if: steps.check.outcome == 'failure'
        run: exit 1
"""
print(WORKFLOW)
assert "--format sarif" in WORKFLOW
name: timing
on: [pull_request]
permissions:
  contents: read
  security-events: write
jobs:
  qtiming:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with: { python-version: "3.12" }
      - run: pip install "qtiming[z3]"
      - id: check
        run: qtiming check circuits/tp_sync.qasm --contract ibm_heron --format sarif --out qtiming.sarif
        continue-on-error: true
      - uses: github/codeql-action/upload-sarif@v3
        with: { sarif_file: qtiming.sarif }
      - if: steps.check.outcome == 'failure'
        run: exit 1

What just happened#

  • Exit code 1 for REFUTED (and, with --strict-proved, for PROVED-UNDER), 2 for a usage error: a CI step needs no output parsing.
  • SARIF carries the REFUTED obligation as an error result at the offending source line, plus the vendor assumption as a note.
  • Z3 (the z3 extra) is needed for Tier 2 refutations; with --no-tier2 what Tier 1 cannot prove is UNKNOWN (exit 3).

See also: Command reference. Next: the contract tutorials.

Page source: tutorials/10-ci.md qtiming 0.1.0, Apache-2.0 · by Pratul Deshpande