-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[WIP] Pulse-efficient Transpiler Passes #6653
Open
catornow
wants to merge
78
commits into
Qiskit:main
Choose a base branch
from
catornow:CalibrationBuilderNoEcho
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 76 commits
Commits
Show all changes
78 commits
Select commit
Hold shift + click to select a range
8df6123
Added the class RZXCalibrationBuilderNoEcho
catornow 51a3caf
Fixed style and lint error in line 20
catornow aad1389
Fixed style and lint errors
catornow 7ae864a
Corrected code by implementing new filter_funcs
catornow 271093e
Implemented Daniel's suggestions
catornow b0e1527
Added tests for the RZXCalibrationBuilderNoEcho
catornow d37ee2a
Fixed style and lint error
catornow 28ea533
Formatted the code
catornow e31cc56
Reformatted calibration_creators.py
catornow 1f825ac
Merge branch 'main' into CalibrationBuilderNoEcho
catornow 226ca84
Apply suggestions from code review
catornow 63ed1e9
Reformatted the code
catornow a2ed887
Fixed Pylint no-member error
catornow e7a2445
Merge branch 'main' into CalibrationBuilderNoEcho
catornow b078705
Merge branch 'main' into CalibrationBuilderNoEcho
eggerdj 1b5cf50
Added NativeCXDirection Transpiler Pass, added RZX decompositions of …
catornow 6eca945
Merge branch 'CalibrationBuilderNoEcho' of github.com:catornow/qiskit…
catornow 448f94f
Added NativeCXDirection Transpiler Pass.
catornow b589c86
Added EchoRZXWeylDecomposition Transpiler Pass.
catornow d704b5a
Small change
catornow 60f5b41
Removed changes to Equivalence Library
catornow c17c534
Minor changes
catornow b4d81d7
Removed bug due to simplified=True and modified _weyl_gate in class T…
catornow ec5df30
Changed name of NativeCXGateDirection to NativeCRGateDirection
catornow 23d3ca7
Merge branch 'main' into CalibrationBuilderNoEcho
eggerdj aa970c6
Update qiskit/quantum_info/synthesis/two_qubit_decompose.py
catornow 2d27040
Update qiskit/quantum_info/synthesis/two_qubit_decompose.py
catornow 992a158
Update qiskit/quantum_info/synthesis/two_qubit_decompose.py
catornow d64a7f8
Update qiskit/transpiler/passes/optimization/echo_rzx_weyl_decomposit…
catornow 9dd97c2
Update qiskit/transpiler/passes/optimization/echo_rzx_weyl_decomposit…
catornow 2b0c698
Update qiskit/transpiler/passes/utils/native_cr_direction.py
catornow 2ea238f
Update qiskit/transpiler/passes/utils/native_cr_direction.py
catornow 764d0ee
Update qiskit/quantum_info/synthesis/two_qubit_decompose.py
catornow 2c0aee8
Update qiskit/quantum_info/synthesis/two_qubit_decompose.py
catornow d944a47
Update qiskit/transpiler/passes/optimization/echo_rzx_weyl_decomposit…
catornow 90f0f35
Update qiskit/transpiler/passes/optimization/echo_rzx_weyl_decomposit…
catornow ee2f6bf
Update qiskit/quantum_info/synthesis/two_qubit_decompose.py
catornow 882b178
Update qiskit/transpiler/passes/utils/native_cr_direction.py
catornow 9615d24
Minor changes
catornow 2c3c4ca
Added "backend" to passmanager_config and transpiler to use it in pas…
catornow ed5c0aa
Added new pulse-efficient preset pass manager
catornow b501631
Added new pulse-efficient preset pass manager
catornow a4e28d5
Added tests for the EchoRZXWeylDecomposition pass and the TwoQubitWey…
catornow f38fad2
Update qiskit/transpiler/passes/optimization/echo_rzx_weyl_decomposit…
catornow b67fb0a
Update test/python/transpiler/test_echo_rzx_weyl_decomposition.py
catornow 4aa7da9
Update qiskit/quantum_info/synthesis/two_qubit_decompose.py
catornow 8dd4556
Update qiskit/transpiler/passes/optimization/echo_rzx_weyl_decomposit…
catornow 8e01158
Update qiskit/transpiler/passes/optimization/echo_rzx_weyl_decomposit…
catornow 33439a9
Update qiskit/transpiler/preset_passmanagers/pulse_efficient.py
catornow 5922469
Use instruction schedule map as variable instead of backend, added _a…
catornow e335416
Added instruction schedule map as variable to pass manager config and…
catornow 65262d7
Merge branch 'CalibrationBuilderNoEcho' of github.com:catornow/qiskit…
catornow 67690da
Use instruction schedule map in pass manager, modification in pulse-e…
catornow 093ab18
Allow for str expression as optimization_level
catornow b274b84
Added instruction schedule map as variable for RZXCalibrationBuilder
catornow e00eeac
Added tests for pulse-efficient transpiler pass and pass manager
catornow 3cbb40f
black
catornow 81cd58d
Minor change
catornow a8f9ea5
Update test/python/transpiler/test_echo_rzx_weyl_decomposition.py
catornow 5d9d582
Update test/python/transpiler/test_echo_rzx_weyl_decomposition.py
catornow 4c85977
Update test/python/transpiler/test_echo_rzx_weyl_decomposition.py
catornow 70d5c52
Update test/python/transpiler/test_echo_rzx_weyl_decomposition.py
catornow b0f8700
Update test/python/transpiler/test_pulse_efficient_passmanager.py
catornow 7f4b2df
Update qiskit/transpiler/preset_passmanagers/pulse_efficient.py
catornow b79aed7
Update test/python/transpiler/test_pulse_efficient_passmanager.py
catornow 17ea8a8
Update test/python/transpiler/test_pulse_efficient_passmanager.py
catornow 261ba12
Update test/python/transpiler/test_pulse_efficient_passmanager.py
catornow a34a297
Update qiskit/transpiler/preset_passmanagers/pulse_efficient.py
catornow f0e03c4
Update qiskit/transpiler/passes/optimization/echo_rzx_weyl_decomposit…
catornow 598f7ec
Implement suggestions of Luciano
catornow 2f675ed
Included optimization_level 3 in pulse efficient pass manager
catornow 6b54311
Update qiskit/quantum_info/synthesis/two_qubit_decompose.py
catornow 7f909ad
Update qiskit/quantum_info/synthesis/two_qubit_decompose.py
catornow fa5e961
Update qiskit/quantum_info/synthesis/two_qubit_decompose.py
catornow 45ad417
Update qiskit/quantum_info/synthesis/two_qubit_decompose.py
catornow e58d5b2
Merge branch 'main' into CalibrationBuilderNoEcho
catornow 48a3a53
Added function specialize in class TwoQubitWeylEchoRZX again
catornow 176b228
Merge branch 'CalibrationBuilderNoEcho' of github.com:catornow/qiskit…
catornow 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
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
84 changes: 84 additions & 0 deletions
84
qiskit/transpiler/passes/optimization/echo_rzx_weyl_decomposition.py
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 |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# This code is part of Qiskit. | ||
# | ||
# (C) Copyright IBM 2017, 2021. | ||
# | ||
# This code is licensed under the Apache License, Version 2.0. You may | ||
# obtain a copy of this license in the LICENSE.txt file in the root directory | ||
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. | ||
# | ||
# Any modifications or derivative works of this code must retain this | ||
# copyright notice, and modified files need to carry a notice indicating | ||
# that they have been altered from the originals. | ||
|
||
"""Weyl decomposition of two-qubit gates in terms of echoed cross-resonance gates.""" | ||
|
||
from qiskit.transpiler.basepasses import TransformationPass | ||
from qiskit.transpiler.exceptions import TranspilerError | ||
|
||
from qiskit.dagcircuit import DAGCircuit | ||
from qiskit.converters import circuit_to_dag | ||
|
||
from qiskit.transpiler.layout import Layout | ||
|
||
import qiskit.quantum_info as qi | ||
|
||
from qiskit.quantum_info.synthesis.two_qubit_decompose import TwoQubitWeylEchoRZX | ||
|
||
|
||
class EchoRZXWeylDecomposition(TransformationPass): | ||
"""Rewrite two-qubit gates using the Weyl decomposition. | ||
|
||
This transpiler pass rewrites two-qubit gates in terms of echoed cross-resonance gates according | ||
to the Weyl decomposition. A two-qubit gate will be replaced with at most six non-echoed RZXGates. | ||
Each pair of RZXGates forms an echoed RZXGate. | ||
""" | ||
|
||
def __init__(self, inst_map): | ||
"""EchoRZXWeylDecomposition pass.""" | ||
self.inst_map = inst_map | ||
super().__init__() | ||
|
||
def run(self, dag): | ||
"""Run the EchoRZXWeylDecomposition pass on `dag`. | ||
|
||
Rewrites two-qubit gates in an arbitrary circuit in terms of echoed cross-resonance | ||
gates by computing the Weyl decomposition of the corresponding unitary. Modifies the | ||
input dag. | ||
|
||
Args: | ||
dag (DAGCircuit): DAG to map. | ||
|
||
Returns: | ||
DAGCircuit: The rearranged dag. | ||
|
||
Raises: | ||
TranspilerError: If the circuit cannot be mapped. | ||
""" | ||
|
||
if len(dag.qregs) > 1: | ||
raise TranspilerError( | ||
"EchoRZXWeylDecomposition expects a single qreg input DAG," | ||
f"but input DAG had qregs: {dag.qregs}." | ||
) | ||
|
||
trivial_layout = Layout.generate_trivial_layout(*dag.qregs.values()) | ||
|
||
for node in dag.two_qubit_ops(): | ||
if node.type == "op": | ||
control = node.qargs[0] | ||
target = node.qargs[1] | ||
|
||
physical_q0 = trivial_layout[control] | ||
physical_q1 = trivial_layout[target] | ||
|
||
qubit_pair = (physical_q0, physical_q1) | ||
|
||
unitary = qi.Operator(node.op).data | ||
dag_weyl = circuit_to_dag( | ||
TwoQubitWeylEchoRZX( | ||
unitary, inst_map=self.inst_map, qubit_pair=qubit_pair | ||
).circuit() | ||
) | ||
dag.substitute_node_with_dag(node, dag_weyl) | ||
|
||
return dag |
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
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
Oops, something went wrong.
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.
For the algorithms, that create circuits and execute them, this is presently done via a QuantumInstance that wraps a backend and has common circuit support for the algorithms, that also allows an end user to set circuit aspects such as transpiler options. See here https://github.com/Qiskit/qiskit-terra/blob/3bb72d340fcf9552d4a6bd54b675399578c726db/qiskit/utils/quantum_instance.py#L71
So if this is introduced as a string I think the above should follow suit and be changed likewise. As the code just stores and passes this on I think its a minor change there just for the typehint.
As a very minor comment I think the typehint can be written more simply as
Optional[Union[int, str]] = None
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 actually think a better interface for this is the
FullPassManager
being introduced in: #6403 with for the extra passes the user just builds a post-optimization pass manager that runs these additional passes and sets that on level 3. I don't think we want to use optimization level like this.