-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Pauli X, Y, Z measurement instructions #9269
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
Open
pedrorrivero
wants to merge
14
commits into
Qiskit:main
Choose a base branch
from
pedrorrivero:pauli-measurement
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 9 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
43b702b
Add MeasureX, MeasureY, and MeasureZ instructions
pedrorrivero 0f796bd
Fix lint
pedrorrivero 7c04baa
Update dagdependency
pedrorrivero 2bc2c92
Add text visualization
pedrorrivero 882dad9
Add matplotlib visualization
pedrorrivero 49c608e
Fix cregbundle visualization
pedrorrivero 125e5fc
Remove unused imports
pedrorrivero de2df75
Fix lint
pedrorrivero b3fd53e
Fix MeasureZ.__init__ docstring position
pedrorrivero d34b69b
Add missing display colors
pedrorrivero 0e50b05
Add latex visualization
pedrorrivero 8ec2965
Remove deprecation TODO
pedrorrivero 6421275
Rename LATEX_METER to PAULI_METER
pedrorrivero 7144f26
Update RemoveFinalMeasurements
pedrorrivero 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 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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,9 +21,10 @@ | |
|
|
||
| from qiskit.circuit.quantumregister import QuantumRegister, Qubit | ||
| from qiskit.circuit.classicalregister import ClassicalRegister, Clbit | ||
| from qiskit.circuit.commutation_checker import CommutationChecker | ||
| from qiskit.circuit.measure import Measure | ||
| from qiskit.dagcircuit.exceptions import DAGDependencyError | ||
| from qiskit.dagcircuit.dagdepnode import DAGDepNode | ||
| from qiskit.circuit.commutation_checker import CommutationChecker | ||
|
|
||
|
|
||
| # ToDo: DagDependency needs to be refactored: | ||
|
|
@@ -382,8 +383,12 @@ def _create_op_node(self, operation, qargs, cargs): | |
| Returns: | ||
| DAGDepNode: the newly added node. | ||
| """ | ||
| directives = ["measure"] | ||
| if not getattr(operation, "_directive", False) and operation.name not in directives: | ||
| directives = [] | ||
| if ( | ||
| not getattr(operation, "_directive", False) | ||
| and not isinstance(operation, Measure) | ||
| and operation.name not in directives | ||
| ): | ||
|
Comment on lines
-385
to
+391
Member
Author
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. After introducing the |
||
| qindices_list = [] | ||
| for elem in qargs: | ||
| qindices_list.append(self.qubits.index(elem)) | ||
|
|
||
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
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
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
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
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.
It's possible that we could accept an inheritance relationship here, but I don't think it's for certain the correct way of doing things, over (for example) a set of flags defined
InstructionorOperation. This particular inheritance is definitely not safe, though -Measureis, and needs to remain, a measure in the Z basis, soMeasureXisn't an instance of it. There's also the false abstraction here that the base class is only abstract as far as a single-qubit Pauli-basis measurement, which isn't the most general type.Aside from those abstraction/false-hierarchy issues, another thing to consider with inheritance is that we would need to work out how external / further subclasses of
BaseMeasure(or whatever) would be safely serialised/deserialised by QPY - this PR adds an inheritance structure to instructions that is deliberately avoided in our data model elsewhere. This has some wide-ranging implications that I'm too "on holiday" to think through properly right now (sorry).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 see 🤔 let's pick this up again once you come back then! Thanks for the detailed explanation