Skip to content

tket_wrapper: fix pytket export of single-bit conditions; honour no_reduce - #74

Merged
quantum-osiris merged 1 commit into
mainfrom
claude/fix-tket-conditionals
Nov 22, 2026
Merged

quantum-osiris merged 1 commit into
mainfrom
claude/fix-tket-conditionals

Conversation

@quantum-osiris

Copy link
Copy Markdown
Owner

Fixes the 12 tests in tests/test_quantinuum_client.py that fail on main whenever pytket is installed. CI doesn't install pytket, so it only ever exercised the static fallback and didn't catch them.

Bugs fixed

  1. Export crash. circuit_to_qasm_str with the qelib1 header raises QASMUnsupportedError on single-bit conditions (if(c[0]==1) x q[1];), which mid-circuit feed-forward needs. The wrapper now retries with Quantinuum's hqslib1 header, which allows them.
  2. no_reduce ignored. no_reduce and tket_opt_level=0 were ignored on the pytket path, so FullPeepholeOptimise still ran. The static path already skips all reduction in these cases; now both paths behave the same.
  3. New guard. If pytket output changes the number of measurements, resets or conditionals, it is rejected and the static fallback is used.

Test changes: two tests compared exact gate text after compilation. pytket legitimately rewrites x and h as u3, so those text checks now run on the lowering output, and the compiled output is checked by structure: every if(syn==k) correction must still target the right qubit. Two new tests cover the pytket path and no_reduce.

Verification

  • Full suite with pytket 2.18.5: 3085 passed, 26 skipped, 0 failed.
  • Quantinuum tests with pytket blocked, as in CI: 26 passed, 1 skipped.
  • bootstrap --verify-only, py_compile and git diff --check all pass.

🤖 Generated with Claude Code

…uce on the pytket path

With pytket installed (2.18.5), 12 tests in test_quantinuum_client.py failed:
- circuit_to_qasm_str(qelib1) raises QASMUnsupportedError on single-bit
  conditions such as if(c[0]==1); retry with Quantinuum's hqslib1 header.
- no_reduce / level 0 were ignored on the pytket path (the static path skips
  all reduction); now both paths behave the same.
- Guard: pytket output is rejected (static fallback used) if it changes the
  number of measurements, resets or conditionals.
Text-matching tests now check the lowering output; the compiled output is
checked structurally (pytket legitimately rewrites x as u3). Two new tests.

Full suite with pytket: 3085 passed, 26 skipped, 0 failed. Quantinuum tests
with pytket blocked (as in CI): 26 passed, 1 skipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@quantum-osiris
quantum-osiris merged commit ba01d2e into main Nov 22, 2026
10 checks passed
@quantum-osiris
quantum-osiris deleted the claude/fix-tket-conditionals branch November 22, 2026 04:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant