@@ -91,6 +91,7 @@ def __init__(self, num_qubits, params):
9191 "RY" : self .ry_compiler ,
9292 "RX" : self .rx_compiler ,
9393 "CNOT" : self .cnot_compiler ,
94+ "RZX" : self .rzx_compiler ,
9495 }
9596 )
9697 self .args = { # Default configuration
@@ -130,10 +131,22 @@ def _rotation_compiler(self, gate, op_label, param_label, args):
130131 maximum = self .params [param_label ][targets [0 ]],
131132 area = gate .arg_value / 2.0 / np .pi ,
132133 )
134+ f = 2 * np .pi * self .params ["wq" ][targets [0 ]]
133135 if args ["DRAG" ]:
134136 pulse_info = self ._drag_pulse (op_label , coeff , tlist , targets [0 ])
137+ elif op_label == "sx" :
138+ pulse_info = [
139+ ("sx" + str (targets [0 ]), coeff ),
140+ # Add zero here just to make it easier to add the driving frequency later.
141+ ("sy" + str (targets [0 ]), np .zeros (len (coeff ))),
142+ ]
143+ elif op_label == "sy" :
144+ pulse_info = [
145+ ("sx" + str (targets [0 ]), np .zeros (len (coeff ))),
146+ ("sy" + str (targets [0 ]), coeff ),
147+ ]
135148 else :
136- pulse_info = [( op_label + str ( targets [ 0 ]), coeff )]
149+ raise RuntimeError ( "Unknown label." )
137150 return [Instruction (gate , tlist , pulse_info )]
138151
139152 def _drag_pulse (self , op_label , coeff , tlist , target ):
@@ -198,6 +211,41 @@ def rx_compiler(self, gate, args):
198211 """
199212 return self ._rotation_compiler (gate , "sx" , "omega_single" , args )
200213
214+ def rzx_compiler (self , gate , args ):
215+ """
216+ Cross-Resonance RZX rotation, building block for the CNOT gate.
217+
218+ Parameters
219+ ----------
220+ gate : :obj:`~.operations.Gate`:
221+ The quantum gate to be compiled.
222+ args : dict
223+ The compilation configuration defined in the attributes
224+ :obj:`.GateCompiler.args` or given as a parameter in
225+ :obj:`.GateCompiler.compile`.
226+
227+ Returns
228+ -------
229+ A list of :obj:`.Instruction`, including the compiled pulse
230+ information for this gate.
231+ """
232+ result = []
233+ q1 , q2 = gate .targets
234+ if q1 < q2 :
235+ zx_coeff = self .params ["zx_coeff" ][2 * q1 ]
236+ else :
237+ zx_coeff = self .params ["zx_coeff" ][2 * q1 - 1 ]
238+ area = 0.5
239+ coeff , tlist = self .generate_pulse_shape (
240+ args ["shape" ], args ["num_samples" ], maximum = zx_coeff , area = area
241+ )
242+ area_rescale_factor = np .sqrt (np .abs (gate .arg_value ) / (np .pi / 2 ))
243+ tlist *= area_rescale_factor
244+ coeff *= area_rescale_factor
245+ pulse_info = [("zx" + str (q1 ) + str (q2 ), coeff )]
246+ result += [Instruction (gate , tlist , pulse_info )]
247+ return result
248+
201249 def cnot_compiler (self , gate , args ):
202250 """
203251 Compiler for CNOT gate using the cross resonance iteraction.
@@ -226,13 +274,8 @@ def cnot_compiler(self, gate, args):
226274 gate1 = Gate ("RX" , q2 , arg_value = - np .pi / 2 )
227275 result += self .gate_compiler [gate1 .name ](gate1 , args )
228276
229- zx_coeff = self .params ["zx_coeff" ][q1 ]
230- area = 1 / 2
231- coeff , tlist = self .generate_pulse_shape (
232- args ["shape" ], args ["num_samples" ], maximum = zx_coeff , area = area
233- )
234- pulse_info = [("zx" + str (q1 ) + str (q2 ), coeff )]
235- result += [Instruction (gate , tlist , pulse_info )]
277+ gate2 = Gate ("RZX" , targets = [q1 , q2 ], arg_value = np .pi / 2 )
278+ result += self .rzx_compiler (gate2 , args )
236279
237280 gate3 = Gate ("RX" , q1 , arg_value = - np .pi / 2 )
238281 result += self .gate_compiler [gate3 .name ](gate3 , args )
0 commit comments