Closed yapolyak closed 3 months ago
Oh I've just managed to reproduce the result the State.compute()
is giving me! If I transpose the unitary, I get the same result! But why is this the case, and should I transpose every unitary that goes into State
?
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?
Another update - if I try and provide gate_ry
strides explicitly (by using cupy.ndarray.strides()
(accounted for the data type byte length) to cutn.state_apply_tensor()
, it gives me a wrong result anyway, unless I transpose the array.
However, if I use order='C'
, don't transpose and Don't provide strides (pass 0
) I get the right result. I think I understand why this would work (order='C'
is doing the same thing as transposing here), but why if I provide explicit strides it fails? Specifically, I calculate the strides as follows:
gate_ry = cp.asarray([[ 0.33873792+0.j, -0.94088077+0.j],
[ 0.94088077+0.j, 0.33873792+0.j]]).astype(dtype='complex128', order='C')
gate_ry_strides = tuple(int(stride/16) for stride in gate_ry.strides)
Hi,
I stumbled upon a strange case of
State
object returning a seemingly wrong statevector on compute, for a two-qubit circuit with a single (single-qubit) gate. The gate in question is a parameterised Ry gate (such as described here, and I am anyway providing a specific unitary for it, so the nature of the gate should not matter.First, I calculate statevector manually as follows:
and get the following result:
(I get the same result if I use
cupy
instead ofnumpy
, and also with the pytket package).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
State
?Many thanks! Iakov