Replies: 5 comments 7 replies
-
@BoxiLi Thanks for this ! I haven't started working in this yet but looking at your function - there needs to be an option for multiple control value options for larger number of qubits with some way to specify the qubits. For example : Below is an example 3 qubit gate with target on B controlled by 0 on A and 1 on C. I will add more options as I go about defining the gate and list them here. |
Beta Was this translation helpful? Give feedback.
-
@BoxiLi @hodgestar I don't think I will be able to finish off two-qubit decomposition PR by today because of the issues discussed below. I have been able to get the correct numpy array output but I still need to work on the circuit diagram. I have two questions about using
Warning : Should I ignore/suppress it and move on if there will be a custom gate label for each iteration of the gray code function ?
For example, following will output the correct circuit matrix but incorrect diagram with a warning for the gate label. # U3 definition
def user_gate1():
H_CNOT = Qobj([[1,0,0,0],[0,1/np.sqrt(2), 0, 1/np.sqrt(2)],[0,0,1,0],[0,1/np.sqrt(2), 0, -1/np.sqrt(2)]])
return Qobj(H_CNOT, dims=[[2, 2], [2, 2]])
qc1 = QubitCircuit(2, reverse_states=False)
qc1.user_gates = {"CNOT_H" : user_gate1}
new_gate = Gate("CNOT_H", targets=[0,1])
paulix = Gate("X",targets=0, classical_controls=[0])
cnot1 = Gate("CNOT", controls=0, targets=1)
gate_list = [paulix,cnot1,paulix,new_gate,paulix,cnot1,paulix]
qc1.add_gates(gate_list)
qc1.png Expected matrix of the entire circuit is correctly output though : In the circuit,
|
Beta Was this translation helpful? Give feedback.
-
Yeah... if you look at the error message it is from |
Beta Was this translation helpful? Give feedback.
-
In general, it doesn't matter which one is the target which one is the control if a Allowing a |
Beta Was this translation helpful? Give feedback.
-
Now looking at this discussion, and our meeting yesterday. I realize that the title was wrong. My definition here is for Controlled gates, not two-level matrix. The latter needs a different definition, with arg_value including: |
Beta Was this translation helpful? Give feedback.
-
@purva-thakre
This is a quick implementation of the controlled gate I described in the meeting agenda. You could work further on it, adding a few more tests and use it as your two-level gates. I tested with some simple cases but I'm not sure if there are still some bugs.
Notice that to use it as a
Gate
, you also need to define the capital gate name, likeCGATE
for it inQubitCircuit.propagators()
and ``QubitCircuit.propagators_no_expand()`. Let me know if you have questions.With some quick tests
Beta Was this translation helpful? Give feedback.
All reactions