Allow inserting DD sequences with non-Cirq rules#3065
Open
natestemen wants to merge 2 commits into
Open
Conversation
Convert DDD rule output to Cirq inside `_insert_ddd_sequences`, so rules returning any QPROGRAM (e.g. Qiskit QuantumCircuit) work correctly instead of failing at Cirq-specific method calls.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3065 +/- ##
=======================================
Coverage 98.40% 98.40%
=======================================
Files 112 112
Lines 4940 4946 +6
=======================================
+ Hits 4861 4867 +6
Misses 79 79 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Summary
The DDD rule functions (e.g.
xx,xyxy) are typed as returningQPROGRAM, and the public API (insert_ddd_sequences,execute_with_ddd, etc.) acceptsCallable[[int], QPROGRAM]. However, the internal implementation ofinsert_ddd_sequencescalled Cirq-specific methods directly on the rule's return value, so any rule returning a non-Cirq circuit would fail at runtime:ruleparameter type fromCallable[[int], Circuit]toCallable[[int], QPROGRAM]ininsert_ddd_sequences/_insert_ddd_sequencescirq_rulewrapper that converts the rule output to a CirqCircuit(viaconvert_to_mitiq) and normalizes qubit indexing toLineQubits before the Cirq-specific DDD insertion logic runsTest plan
test_insert_sequences_with_qiskit_ruleverifies a Qiskit-returning rule produces the same result as the equivalent Cirq ruleAI was used in helping create this PR.