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

CNOT gate issue #6

Open
marionsilv opened this issue Aug 17, 2022 · 2 comments
Open

CNOT gate issue #6

marionsilv opened this issue Aug 17, 2022 · 2 comments

Comments

@marionsilv
Copy link

Hello,

I have been trying to build a circuit with a CNOT gate acting on non-contiguous qubits (e.g., qubit 1 and 4), but I am finding strange results.

For example, if I choose an initial state [1,0,0,0]

and apply the unitary
uni = tlq.Unitary([tlq.CNOTL(device=device, dtype=dtype), tlq.CNOTR(device=device, dtype=dtype), tlq.IDENTITY(dtype=dtype, device=device), tlq.IDENTITY(dtype=dtype, device=device)], nqubits, ncontraq, device=device, dtype=dtype)

I get (for the expected value of Sz): tensor([-1., -1., 1., 1.])

However, if I apply the CNOT cores to non-adjacent qubits in the same initial state, with
uni = tlq.Unitary([tlq.CNOTL(device=device, dtype=dtype), tlq.IDENTITY(dtype=dtype, device=device), tlq.IDENTITY(dtype=dtype, device=device), tlq.CNOTR(device=device, dtype=dtype)], nqubits, ncontraq, device=device, dtype=dtype)

I find, again for the expected value of Sz: tensor([-2., 2., 2., 0.])

Is there any limitation regarding the CNOT cores that make it only valid for adjacent qubits, or am I doing something wrong? I am attaching a file with the full code for running: code.txt

Thanks for the help,
Marion Silvestrini.

@taylorpatti
Copy link
Collaborator

Hi Marion,

Good to hear from you. Yes indeed, with our standard tensor network gates the two-qubit gates like CNOT are supposed to be next to each other.

We do have a tensor ring structure, so you can act a CNOT from the last qubit to the first qubit (as they are next to each other on the ring), but distant qubits cannot be connected in this way.

That being said, you can write an extension of gates that interact non-adjacent qubits by writing your own Unitary. If you write some test functions for this, I'd be happy to merge it into the general library. Something to keep in mind is that the size of the matrices that you will need in your tensor core will roughly grow as 2^{n+1}, where n is the number of qubits between the two qubits that you're interacting, so this distance can't go on forever.

@rafaeleb
Copy link

rafaeleb commented Sep 2, 2022

Hello all,

This is not a solution to the above issue, but it could be of interest anyway: a CNOT where the right qubit is the control. You can find the class here: https://github.com/rafaeleb/TLQ-cont
I have not extensively tested it, but I think it works fine.

I am also interested in the class for non-adjacent qubits. I could not figure out the proper dimensionality of the left and right cores though, so any tip is welcome.

Rafael

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