-
Hi, I stumbled upon a strange case of First, I calculate statevector manually as follows:
and get the following result:
(I get the same result if I use Now, I try running the following script (as per your example, also discussed in another discussion previously with you):
and I am getting the following vector:
As you can see, the third element sign is different to the reference result. It puzzles me a lot, because the same script (and a more structured API interface that I've done) give correct results for other types of gates. Am I missing something, or is there a strange bug in Many thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
Oh I've just managed to reproduce the result the |
Beta Was this translation helpful? Give feedback.
-
I now recall that you do transpose Pauli unitaries in your example, and have been ignoring that... This probably is due to necessity of using 'F'-style ordering, right? |
Beta Was this translation helpful? Give feedback.
-
Another update - if I try and provide However, if I use
|
Beta Was this translation helpful? Give feedback.
-
Hello Iakov, The expected input form is described in our documentation here. If this is unclear to python users working on tensor objects, let's use an example here: If you have a n-qubit gate acting on qubit Going back your case, in your reference code, essentially what you're computing as reference amounts to sv = np.einsum('ab,Aa->Ab', sv_vacuum, gate_rx) So you see that the gate_ry = cp.asarray([[ 0.33873792+0.j, -0.94088077+0.j],
[ 0.94088077+0.j, 0.33873792+0.j]], dtype='complex128', order='F')
gate_ry = gate_ry.T.astype(gate_ry.dtype, order='F')
gate_ry_strides = 0 Note that here I'm using gate_ry = .... # Aa notation
gate_ry = gate_ry.T # not enforcing any order
gate_ry_strides = tuple(int(stride/gate_ry.itemsize) for stride in gate_ry.strides) # view will work too Let me know if you have other questions. |
Beta Was this translation helpful? Give feedback.
Hello Iakov,
The expected input form is described in our documentation here.
If this is unclear to python users working on tensor objects, let's use an example here: If you have a n-qubit gate acting on qubit
(a,b,c,...)
, the APIstate_apply_tensor
is expecting an operand with mode indices...cba...CBA
where...cba
are the contracted ket indices and...CBA
are the un-contracted bra indices. The reason why we picked this convention is explain in the documentation but we do understand that this felt less intuitive for python users.Going back your case, in your reference code, essentially what you're computing as reference amounts to
So you se…