Fix LogicalCircuit-pytket/Quantinuum compatibility (RESOLVED - REQUIRES PEER REVIEW)#19
Open
conorfitzmaurice wants to merge 5 commits into
Conversation
Author
|
Demo works on Quantinuum H1-1LE (someone please verify this). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(AerSimulator verifies that it replicates the results in LogicalCircuit_Demo.ipynb)
*(Do so by linking your pytket session 1. through cloud (more robust for later testing) with QIR or OpenQASM 2.0 using the respective API, or 2. locally (preferred for fast testing) with pytket built-in packages using
pip install pytket-quantinuum)Update 2/02: Works on Quantinuum local conversions.
The existing
Execution.pyin compat-qtm had a broken_transpilefunction for QuantinuumBackend.This produces errors like:
This demo fixes it by:
pytket_compat.py- provides monkey-patch and correct transpilationExecution.py- uses the new module for future Quantinuum conversionProblem 1: Missing UnBoxTask():
Problem 2: Missing FlattenIfElseOpsTask():
Problem 3: qiskit_to_tk() can't handle Binary/Unary expressions:
expr.Binary(expr.Binary.Op.BIT_AND, condition1, condition2, types.Bool())The pytket-qiskit converter doesn't recognize these expression types. It only handles simple (Clbit, value) tuples. This is a known limitation. As Rasmit explained, pytket qiskit_to_tk doesn't allow binary conditions - he has a patched pytket at https://github.com/RasmitDevkota/pytket/tree/main.
Problem 4: Missing DecomposeClassicalExp() for Quantinuum:
Also, fidelity verification compares statevectors before and after conversion to prove correctness (you can run this yourself). During development, this required a workaround: pytket sorts quantum registers alphabetically during conversion, while qiskit preserves insertion order. This caused statevector indices to be permuted, giving false fidelity of 1/256 instead of 1.0. The fix tracks original qubit ordering and applies inverse permutation before comparison.
Lastly, previous QEC decoding generated complex boolean expressions that require many scratch bits. The fix includes a boolean algebra simplifier that reduces scratch-bit usage by 80% (10 -> 2 bits in typical cases) using rules like x & x -> x, x | 0 -> x, ~~x -> x.
Please someone test this on Quantinuum hardware (especially if you have credentials), thanks.
This pull request must be satisfied before merging #3.