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

Two registers #570

Open
juliabarbera opened this issue Apr 4, 2022 · 2 comments
Open

Two registers #570

juliabarbera opened this issue Apr 4, 2022 · 2 comments

Comments

@juliabarbera
Copy link

I want to create two different registers with different number of qubits ( i.e. the first one with N qubits and the second one with M) to compute later CZ gate between the M qubits of M and the first M qubits of N.

How could this registers be created in Qibo?

@stavros11
Copy link
Member

Thanks for opening this issue. Could you please describe in more detail which are the control and target qubits of the CZ gates?

In qibo we use the register terminology only when doing measurements. For example

circuit.add(gates.M(0))
circuit.add(gates.M(1))
circuit.add(gates.M(2))

can be grouped to a single register using

circuit.add(gates.M(0, 1, 2))

which changes slightly how the measurement results are returned after simulation (see the documentation for more details). But I believe this is not relevant in your case.

Moreovoer, you can create CZ gates with multiple control qubits using .controlled_by, eg.:

circuit.add(gates.Z(4).controlled_by(0, 1, 2, 3))

which applies a Z gate to qubit 4 when 0, 1, 2 and 3 are all in the |1> state. You can have an arbitrary number of controls but there is still a single target qubit.

@igres26
Copy link
Contributor

igres26 commented Apr 6, 2022

There is no specific qubit or register object in Qibo. The qubits are numbered from most significant to least by an int value from 0 to nqubits-1. To keep track of registers in a tidy way, I recommend using native python lists. If I understood well your issue, it could look like this:

c = Circuit(18)
m = [i for i in range(8)]
n = [i for i in range(8, 18)]

for i in range(len(m)):
    c.add(gates.CZ(m[i], n[i]))

c.add(gates.M(*m))

This way you can keep track of different qubit registers in the same circuit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants