-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Delegate BasePass.__call__ to PassManager.run
#13820
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
42102fd
Delegate `BasePass.__call__` to `PassManager.run`
jakelishman a45e816
Correctly propagate exceptions through `PassManager.run`
jakelishman 975769e
Fix lint
jakelishman 390fa85
Merge remote-tracking branch 'ibm/main' into direct-pass-call
jakelishman 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
24 changes: 24 additions & 0 deletions
24
releasenotes/notes/pass-call-as-passmanager-7f874917b9b303f0.yaml
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 |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| --- | ||
| features_transpiler: | ||
| - | | ||
| :meth:`.PassManager.run` now accepts a ``property_set`` argument, which can be set to a | ||
| :class:`~collections.abc.Mapping`-like object to provide the initial values of the pipeline's | ||
| :class:`.PropertySet`. This can be used to recommence a partially applied compilation, or to | ||
| reuse certain analysis from a prior compilation in a new place. | ||
| upgrade_transpiler: | ||
| - | | ||
| The keyword argument ``property_set`` is now reserved in :meth:`.BasePassManager.run`, and | ||
| cannot be used as a ``kwarg`` that will be forwarded to the subclass's conversion from the | ||
| front-end representation to the internal representation. | ||
| fixes: | ||
| - | | ||
| Calling an :class:`.AnalysisPass` or a :class:`.TransformationPass` like a function (as in | ||
| ``pass_ = MyPass(); pass_(qc)``) will now respect any requirements that the pass might have. | ||
| For example, scheduling passes such as :class:`.ALAPScheduleAnalysis` require that | ||
| :class:`.TimeUnitConversion` runs before them. Running the pass via a :class:`.PassManager` | ||
| always respected this requirement, but until this note, it was not respected by calling the | ||
| pass directly. | ||
| - | | ||
| When a :exc:`.TranspilerError` subclass is raised by a pass inside a call to | ||
| :meth:`.PassManger.run`, the exception will now be propagated through losslessly, rather than | ||
| becoming a chained exception with an erased type. |
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 |
|---|---|---|
|
|
@@ -225,8 +225,7 @@ def test_partial_permutation_in_middle(self): | |
|
|
||
| # Make sure that the transpiled circuit *with* the final permutation | ||
| # is equivalent to the original circuit | ||
| perm = pass_.property_set["virtual_permutation_layout"].to_permutation(qc.qubits) | ||
| res.append(PermutationGate(perm), [0, 1, 2, 3, 4]) | ||
| res.append(PermutationGate(res.layout.routing_permutation()), [0, 1, 2, 3, 4]) | ||
|
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.
|
||
| self.assertEqual(Operator(res), Operator(qc)) | ||
|
|
||
| def test_permutation_at_beginning(self): | ||
|
|
||
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.
I remember discussing this offline, but
TranspilerErrorbeing a subclass ofPassManagerErrorseems so weird. But it's hard to change this now so this makes sense.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 assume it was intended as a backwards-compatibility shim for a move to
PassManagerErrorduring the genericisation ofPassManager, but I don't really know.