Skip to content
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

Support target and basis gates in Unroll3qOrMore transpiler pass #7997

Merged
merged 6 commits into from
May 4, 2022

Conversation

mtreinish
Copy link
Member

Summary

This commit adds two new constructor arguments to the Unroll3qOrMore
transpiler pass, target and basis_gates, which are used to specify a
backend target and basis gate list respectively. If these are specified
the pass will not decompose any multiqubit operations present in the
circuit if they are in the target or basis_gates list.

Details and comments

Fixes #5518
Related to #7812
Part of #7113

This commit adds two new constructor arguments to the Unroll3qOrMore
transpiler pass, target and basis_gates, which are used to specify a
backend target and basis gate list respectively. If these are specified
the pass will not decompose any multiqubit operations present in the
circuit if they are in the target or basis_gates list.

Fixes Qiskit#5518
Related to Qiskit#7812
Part of Qiskit#7113
@mtreinish mtreinish added the Changelog: New Feature Include in the "Added" section of the changelog label Apr 28, 2022
@mtreinish mtreinish added this to the 0.21 milestone Apr 28, 2022
@mtreinish mtreinish requested a review from a team as a code owner April 28, 2022 21:08
@qiskit-bot
Copy link
Collaborator

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

One or more of the the following people are requested to review this:

  • @Qiskit/terra-core

@coveralls
Copy link

coveralls commented Apr 28, 2022

Pull Request Test Coverage Report for Build 2269842804

  • 11 of 11 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.003%) to 84.352%

Totals Coverage Status
Change from base Build 2266810353: 0.003%
Covered Lines: 54478
Relevant Lines: 64584

💛 - Coveralls

releasenotes/notes/unroll3q-target-bf57cc4365808862.yaml Outdated Show resolved Hide resolved
"""
super().__init__()
self.target = target
self.basis_gates = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.basis_gates = None
self.basis_gates = set(basis_gates) if basis_gates is not None or target

Why we need to keep target? Seems like both define __contains__ thus we can simplify. This doesn't block your PR. Just my curiosity.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's mostly leftover from an earlier local attempt. I originally wanted to use target.instruction_supported(node.name, qargs) to check that the multiqubit gate is defined on the qubits in the circuit. But the problem with that was when this pass is run before the layout phase we don't actually know which physical device qubits the gate will run on so we can't check that in the target.

I think longer term it makes sense to keep them separate because after #7807 merges we can use instruction_supported() to check based on gate class and potentially parameterizations too instead of just using the name.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this PR looks good to me.

mtreinish and others added 2 commits April 28, 2022 18:13
Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com>
Copy link
Member

@jakelishman jakelishman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, typo aside.

releasenotes/notes/unroll3q-target-bf57cc4365808862.yaml Outdated Show resolved Hide resolved
@mergify mergify bot merged commit e7fdcc8 into Qiskit:main May 4, 2022
@mtreinish mtreinish deleted the unroll3q-target-aware branch May 10, 2022 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: New Feature Include in the "Added" section of the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Qiskit transpiler cannot handle custom multi-qubit gates
5 participants