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

Under the hood#

Question: what does check actually build and run, and what do the knobs --no-tier1, --no-tier2, --timeout and --no-window change?

The example is a distance-3 repetition code (qec/rep_d3_r3 and rep_d3_r100, three and a hundred syndrome rounds) on IBM Heron. Reference: Command reference, Obligations, Windowing (T4).

R3 = _show.FAMILIES / "qec/rep_d3_r3.qasm"
R100 = _show.FAMILIES / "qec/rep_d3_r100.qasm"

The program#

One syndrome round: entangle, measure two ancillas, apply a correction chosen by the outcomes, reset. rep_d3_r100 is the same text with for int i in [0:99].

_show.source("qec/rep_d3_r3.qasm")
OPENQASM 3.0;
// rep_d3_r3: distance-3 repetition code, 3 syndrome round(s), toy lookup decoder
qubit[5] q;
bit[2] c;

for int i in [0:2] {
barrier q;
cx q[0], q[3];
cx q[1], q[3];
cx q[1], q[4];
cx q[2], q[4];
c[0] = measure q[3];
c[1] = measure q[4];
if (c[0] && !c[1]) {
    x q[0];
}
if (c[0] && c[1]) {
    x q[1];
}
if (!c[0] && c[1]) {
    x q[2];
}
reset q[3];
reset q[4];
barrier q;
}

1. The event graph#

explain shows the pipeline's size summary: nodes are timed events (start, end, valid, join...), edges are ordering constraints with latency intervals, obligations are the claims to discharge.

code, out = _show.run("explain", R3, "--contract", "ibm_heron")
assert code == 0 and "115 nodes" in out and "44 obligations" in out
ibm_heron (ibm): 115 nodes, 168 edges, 6 latency variables, 44 obligations
  facts[block]: 9
  facts[blockend]: 9
  facts[eqbar]: 6
  facts[gap]: 45
  facts[ready]: 9
[exit 0]

--graph dot prints the whole graph in Graphviz DOT. The three-round graph is too big to read, so this draws the one-round program (rep_d3_r1):

code, dot = _show.run("explain", _show.FAMILIES / "qec/rep_d3_r1.qasm", "--contract", "ibm_heron", "--graph", "dot", show=False)
assert code == 0 and dot.startswith("digraph lteg")
print(dot.count("->"), "edges")
_show.dot(dot, "Timed event graph of rep_d3_r1 on IBM Heron: nodes are start, end and join events, "
          "edges carry their minimum delay in dt", height=500)
46 edges

2. Solver tiers#

Obligations go through up to three solvers: Tier 0 exact evaluation, Tier 1 interval abstraction (can only prove), Tier 2 the Z3 SMT solver (proves or refutes). This uses --policy eq (every branch must take equal time), which this program satisfies under the vendor latency assumption, and count which tier closed each obligation.

def tiers(prog, *opts, policy="eq"):
    code, out = _show.run("check", prog, "--contract", "ibm_heron", "--policy", policy,
                          "--format", "json", *opts, show=False)
    d = json.loads(out)
    return code, d["verdict"], Counter(
        "unknown" if o["result"] == "unknown" else f"tier {o['tier']}" for o in d["obligations"])

cases = [("default", ()), ("--no-tier1", ("--no-tier1",)), ("--no-tier2", ("--no-tier2",)),
         ("--no-tier1 --no-tier2", ("--no-tier1", "--no-tier2"))]
rows = {name: tiers(R3, *o) for name, o in cases}
for name, (code, verdict, c) in rows.items():
    print(f"{name:24} exit {code}  {verdict:13} {dict(sorted(c.items()))}")
default                  exit 0  PROVED-UNDER  {'tier 0': 14, 'tier 1': 66}
--no-tier1               exit 0  PROVED-UNDER  {'tier 0': 14, 'tier 2': 66}
--no-tier2               exit 0  PROVED-UNDER  {'tier 0': 14, 'tier 1': 66}
--no-tier1 --no-tier2    exit 3  UNKNOWN       {'tier 0': 14, 'unknown': 66}
assert rows["default"][1] == "PROVED-UNDER" and rows["default"][2]["tier 1"] > 0
assert rows["--no-tier1"][1] == "PROVED-UNDER" and rows["--no-tier1"][2]["tier 1"] == 0 and rows["--no-tier1"][2]["tier 2"] > 0
assert rows["--no-tier2"][1] == "PROVED-UNDER"
assert rows["--no-tier1 --no-tier2"][0] == 3 and rows["--no-tier1 --no-tier2"][1] == "UNKNOWN"

The tier mix as a bar (hand-made SVG; one bar per run):

defaulttier 0: 14tier 0: 14tier 1: 66tier 1: 66--no-tier1tier 0: 14tier 0: 14tier 2: 66tier 2: 66--no-tier2tier 0: 14tier 0: 14tier 1: 66tier 1: 66--no-tier1 --no-tier2tier 0: 14tier 0: 14unknown: 66unknown: 66

Turning Tier 1 off pushes its obligations to Z3: same verdict, different workhorse. Turning Tier 2 off is only safe when Tier 1 is enough; where it is not, the obligation is UNKNOWN, never guessed. Turning both off leaves just exact Tier 0, so the verdict is UNKNOWN (exit 3).

Tier 2 is also what produces counterexamples. Under the default sync policy the same program is refuted, and without Tier 2 that refutation becomes UNKNOWN:

for name, o in [("default", ()), ("--no-tier2", ("--no-tier2",))]:
    code, verdict, c = tiers(R3, *o, policy="sync")
    print(f"sync {name:12} exit {code}  {verdict:8} {dict(sorted(c.items()))}")
    if name == "default":
        assert (code, verdict) == (1, "REFUTED")
    else:
        assert (code, verdict) == (3, "UNKNOWN")
sync default      exit 1  REFUTED  {'tier 0': 11, 'tier 1': 18, 'tier 2': 15}


sync --no-tier2   exit 3  UNKNOWN  {'tier 0': 11, 'tier 1': 18, 'unknown': 15}

3. --timeout#

--timeout S bounds each SMT query (default 10 s). A query that runs out of time is UNKNOWN, not a guess. With an absurdly small budget:

code, verdict, c = tiers(R3, "--no-tier1", "--timeout", "0.001")
assert (code, verdict) == (3, "UNKNOWN") and c["unknown"] > 0  # exact split depends on machine speed, so not printed
print(code, verdict)
3 UNKNOWN

4. Windowing#

Unrolling a hundred rounds would build a graph about thirty times the size of the three-round one. For IBM, qtiming instead checks one iteration window, provided the loop is bracketed by full joins (the cut rules of T4). The three-round loop is small enough to unroll; the hundred-round loop exceeds the unroll limit of 64 and is windowed.

code, out = _show.run("check", R100, "--contract", "ibm_heron", "--policy", "eq")
assert code == 0 and out.startswith("PROVED-UNDER") and "window: loop of 100 iterations" in out
PROVED-UNDER  (contract ibm_heron, policy eq, 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: 3 obligation(s): proved (tier 1, margin 0 ns)
  O4: 20 obligation(s): proved (tier 0, margin 0 ns); proved (tier 1, margin 0 ns)
  O7: 3 obligation(s): proved (tier 1, margin 0 ns)
  note: window: loop of 100 iterations summarised by one iteration window (cut rules 1, 3, 4, 5 hold)
  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]

Same verdict as the 3-round program, with 20 O4 obligations instead of 62. Now forbid windowing:

code, out = _show.run("check", R100, "--contract", "ibm_heron", "--policy", "eq", "--no-window")
assert code == 2 and "E-ELAB-LOOP-LIMIT" in out
error: E-ELAB-LOOP-LIMIT: for loop of 100 > unroll limit 64
  hint: raise the unroll limit, or omit --no-window (IBM windowing)
[exit 2]

Without windowing a long loop is not silently truncated: it fails with a usage error (exit 2). Windowing is only sound for IBM; other personalities refuse to window and report UNKNOWN (E-GRAPH-CUT).

Note explain does not window: asking it for the 100-round graph gives the same error.

code, out = _show.run("explain", R100, "--contract", "ibm_heron")
assert code == 2 and "E-ELAB-LOOP-LIMIT" in out
error: E-ELAB-LOOP-LIMIT: for loop of 100 > unroll limit 64
  hint: raise the unroll limit, or omit --no-window (IBM windowing)
[exit 2]

What just happened#

  • The event graph is the shared intermediate form; explain --graph dot exposes it.
  • Obligations are discharged by the cheapest solver that can: exact, interval, then SMT. Interval only proves; only exact and SMT refute.
  • Disabling a tier trades speed for UNKNOWNs, never for wrong answers.
  • Windowing lets rep_d3_r100 be checked in about the cost of one round, under the IBM cut rules.

Next: Reference: CLI.

Page source: tutorials/11-under-the-hood.md qtiming 0.1.0, Apache-2.0 · by Pratul Deshpande