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

Implementing the bridge gate. #6718

Open
wants to merge 46 commits into
base: main
Choose a base branch
from
Open

Implementing the bridge gate. #6718

wants to merge 46 commits into from

Conversation

Djakam
Copy link

@Djakam Djakam commented Jul 12, 2021

Added a new gate which is the bridge gate, it is named brg

Summary

Details and comments

Added a new gate which is the bridge gate, it is named brg
@Djakam Djakam requested a review from a team as a code owner July 12, 2021 12:58
@CLAassistant
Copy link

CLAassistant commented Jul 12, 2021

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@kdk kdk left a comment

Choose a reason for hiding this comment

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

Thanks @Djakam , this looks great so far! A few minor comments below.

for instr, qargs, cargs in rules:
qc._append(instr, qargs, cargs)

self.definition = qc
Copy link
Member

Choose a reason for hiding this comment

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

If you know the __array__ representation, it would be good to add this as a case to TestGateDefinitions in test/python/circuit/test_gate_definitions.py (and even if not, it can be added to TestStandardGates.test_definition_parameters in the same file to ensure the definition and equivalence library entires remain in sync).

Copy link
Author

Choose a reason for hiding this comment

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

Thanks, @kdk. I will change the code accordingly before pushing it again.

Copy link
Member

@kdk kdk left a comment

Choose a reason for hiding this comment

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

Thanks for the updates here @Djakam , this looks great! The lass piece will be to expand the gate name from brg to bridge (and likewise for the class name).

@ajavadia
Copy link
Member

ajavadia commented Aug 3, 2021

should probably expand this to long-range CNOT on more than 3 qubits. e.g. for 4 qubits it would look like this:

image

@Djakam Djakam closed this Aug 3, 2021
@Djakam Djakam reopened this Aug 3, 2021
@Djakam
Copy link
Author

Djakam commented Aug 3, 2021

@ajavadia , thanks for your input. What could be the name for the 4 qubits? what about the 5 ? Any propositions?

@ajavadia
Copy link
Member

ajavadia commented Aug 5, 2021

I'm just trying to make this a bit more general than this very specific use case. I'm certainly not suggesting making a 3, 4, 5, qubit version of this gate.

So the Bridge gate implemented thus far in your PR is a synthesis of a CNOT on 2 qubits separated by one qubit, on a line. The more general thing is you want to synthesize a CNOT on 2 qubits that are distant on some coupling_map. I think there are algorithms that can do this efficiently for the general case, and give you the bridge gate for this specific case.

On the other hand if you want to do the circuit optimization suggested in #6656, then I think a better approach is to use the template optimizations in Qiskit. Just define a template and the template optimization pass will do it, no need to write a separate pass.

@HuangJunye HuangJunye added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label Jun 21, 2022
from qiskit.exceptions import QiskitError


class BridgeGate(QuantumCircuit):
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this inherit from QuantumCircuit instead of Gate?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community PR PRs from contributors that are not 'members' of the Qiskit repo
Projects
Status: Waiting for maintainer response
Development

Successfully merging this pull request may close these issues.

6 participants