-
-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix converting Rxx and similar Qiskit gates #2579
Merged
Merged
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
86000b6
modified the from_qiskit
gluonhiggs e4a5d72
Added myself / the copyright holder to the AUTHORS file
gluonhiggs 566cea1
removed unused import
gluonhiggs 138839c
undo styling
gluonhiggs 23ab614
modified from_qiskit function, added test for convert_to_mitiq
gluonhiggs 2505255
removed unused import
gluonhiggs 91148ea
make format
gluonhiggs 54446a4
changed gates_to_decompose
gluonhiggs 7db464f
black
gluonhiggs 3b81eb2
added QFT to gates_to_decompose
gluonhiggs 828fdf2
removed reps and changed constant name
gluonhiggs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,3 +59,4 @@ Vladimir Kozhukalov | |
Francesc Sabater | ||
Emiliano Godinez | ||
Tommy Nguyen | ||
Duong H. D. Tran |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -249,14 +249,19 @@ def from_qiskit(circuit: qiskit.QuantumCircuit) -> cirq.Circuit: | |
Returns: | ||
Mitiq circuit representation equivalent to the input Qiskit circuit. | ||
""" | ||
|
||
try: | ||
mitiq_circuit = from_qasm(qasm2.dumps(circuit)) | ||
except QasmException: | ||
# Try to decompose circuit before running | ||
# This is necessary for converting qiskit circuits with | ||
# custom packaged gates, e.g., QFT gates | ||
circuit = circuit.decompose() | ||
gates_to_decompose = ["rxx", "rzz", "rzx", "ryy", "QFT"] | ||
circuit = circuit.decompose( | ||
gates_to_decompose=gates_to_decompose, reps=10 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. from what I understand of decompose, we shouldn't need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes. I agree! |
||
) | ||
mitiq_circuit = from_qasm(qasm2.dumps(circuit)) | ||
|
||
return mitiq_circuit | ||
|
||
|
||
|
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this should be capitalized as we want to treat it as a constant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated the code. Thank you!