-
I initialized the state in cuquantum (2nd code block below) with the state from Qiskit after applying the first HGate, then applied the CXGate to the state in cuquantum, somehow the final resulting state differs from the one obtained from Qiskit? Is there anything not looking right in the 2nd code block blow, anything obviously incorrect/missing etc?
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 13 replies
-
Hi @wcqc I've annotated your code with
To fix this, you have a couple of options:
To illustrate (2), I've written a gist and posted it here. I wrote it somewhat hastily, so let me know if you run into problems. Edit: the Python gist should print this:
|
Beta Was this translation helpful? Give feedback.
-
@wcqc let me clarify something which is alluded to by our multi-GPU documentation. Please note that With these observations, This means that you can implement a 2-qubit Bell state via:
(1) |
Beta Was this translation helpful? Give feedback.
@wcqc yes. When the gate is not decomposed, you must provide both controls and targets to
targets=[]
where you’ve taken care in the relative qubit index ordering to preserve the role of the controls.We tend to prefer option 2 as it provides more composability— gates can be fused, reordered, etc..
The assumption we make in the
apply_matrix
API is that the gate is numerically dense. We have other APIs for when the gate takes a special form (e.g.) Pauli matrices, diagonal gates, rotations, etc.I’ll add that there are cases when fusing the control in this fashion can be advantageous. It allows you to fuse 1-qubit gates on either qubit before and after the CX. Fusion is useful because it inc…