@@ -17,7 +17,7 @@ use qiskit_circuit::imports::PAULI_EVOLUTION_GATE;
1717use qiskit_circuit:: instruction:: Parameters ;
1818use qiskit_circuit:: operations:: {
1919 Operation , OperationRef , Param , PauliBased , PauliProductMeasurement , PauliProductRotation ,
20- PyInstruction , PyOperationTypes , StandardGate , StandardInstruction , multiply_param,
20+ PyInstruction , PyOperationTypes , StandardGate , StandardInstruction , multiply_param, radd_param ,
2121} ;
2222use qiskit_circuit:: packed_instruction:: PackedInstruction ;
2323use qiskit_circuit:: { BlocksMode , Qubit , VarsMode } ;
@@ -28,18 +28,18 @@ use qiskit_quantum_info::clifford::Clifford;
2828use qiskit_quantum_info:: sparse_observable:: { BitTerm , SparseObservable } ;
2929
3030use smallvec:: smallvec;
31- use std:: f64:: consts:: PI ;
31+ use std:: f64:: consts:: { FRAC_PI_4 , FRAC_PI_8 } ;
3232
3333// List of gate/instruction names supported by the pass: the pass raises an error if the circuit
3434// contains instruction with names outside of this list.
35- static SUPPORTED_INSTRUCTION_NAMES : [ & str ; 20 ] = [
35+ static SUPPORTED_INSTRUCTION_NAMES : [ & str ; 22 ] = [
3636 "id" , "x" , "y" , "z" , "h" , "s" , "sdg" , "sx" , "sxdg" , "cx" , "cz" , "cy" , "swap" , "iswap" , "ecr" ,
37- "dcx" , "t" , "tdg" , "rz" , "measure" ,
37+ "dcx" , "t" , "tdg" , "rz" , "p" , "u1" , " measure",
3838] ;
3939
4040// List of instruction names which are modified by the pass: the pass is skipped if the circuit
4141// contains no instructions with names in this list.
42- static HANDLED_INSTRUCTION_NAMES : [ & str ; 4 ] = [ "t" , "tdg" , "rz" , "measure" ] ;
42+ static HANDLED_INSTRUCTION_NAMES : [ & str ; 6 ] = [ "t" , "tdg" , "rz" , "p" , "u1 ", "measure" ] ;
4343
4444#[ pyfunction]
4545#[ pyo3( signature = ( dag, fix_clifford=true , insert_barrier=false , use_ppr=false ) ) ]
@@ -88,7 +88,7 @@ pub fn run_litinski_transformation(
8888
8989 // Keep track of the update to the global phase (produced when converting T/Tdg gates
9090 // to RZ-rotations).
91- let mut global_phase_update = 0. ;
91+ let mut global_phase_update = Param :: Float ( 0. ) ;
9292
9393 // Keep track of the clifford operations in the circuit.
9494 let mut clifford_ops: Vec < & PackedInstruction > = Vec :: with_capacity ( clifford_count) ;
@@ -218,24 +218,33 @@ pub fn run_litinski_transformation(
218218 }
219219 OperationRef :: StandardGate ( StandardGate :: T )
220220 | OperationRef :: StandardGate ( StandardGate :: Tdg )
221- | OperationRef :: StandardGate ( StandardGate :: RZ ) => {
221+ | OperationRef :: StandardGate ( StandardGate :: RZ )
222+ | OperationRef :: StandardGate ( StandardGate :: Phase )
223+ | OperationRef :: StandardGate ( StandardGate :: U1 ) => {
222224 // Convert T and Tdg gates to RZ rotations
223225 let ( angle, phase_update) = match inst. op . view ( ) {
224226 OperationRef :: StandardGate ( StandardGate :: T ) => {
225- ( Param :: Float ( PI / 4. ) , PI / 8. )
227+ ( Param :: Float ( FRAC_PI_4 ) , Param :: Float ( FRAC_PI_8 ) )
226228 }
227229 OperationRef :: StandardGate ( StandardGate :: Tdg ) => {
228- ( Param :: Float ( -PI / 4.0 ) , - PI / 8. )
230+ ( Param :: Float ( -FRAC_PI_4 ) , Param :: Float ( - FRAC_PI_8 ) )
229231 }
230232 OperationRef :: StandardGate ( StandardGate :: RZ ) => {
231233 let param = & inst. params_view ( ) [ 0 ] ;
232- ( param. clone ( ) , 0. )
234+ ( param. clone ( ) , Param :: Float ( 0. ) )
235+ }
236+ OperationRef :: StandardGate ( StandardGate :: Phase )
237+ | OperationRef :: StandardGate ( StandardGate :: U1 ) => {
238+ let param = & inst. params_view ( ) [ 0 ] ;
239+ ( param. clone ( ) , multiply_param ( param, 0.5 ) )
233240 }
234241 _ => {
235- unreachable ! ( "We cannot have gates other than T/Tdg/RZ at this point." ) ;
242+ unreachable ! (
243+ "We cannot have gates other than T/Tdg/RZ/P/U1 at this point."
244+ ) ;
236245 }
237246 } ;
238- global_phase_update += phase_update;
247+ global_phase_update = radd_param ( global_phase_update , phase_update) ;
239248
240249 // Evolve the single-qubit Pauli-Z with Z on the given qubit.
241250 // Returns the evolved Pauli in the sparse format: (sign, pauli z, pauli x, indices),
@@ -317,7 +326,7 @@ pub fn run_litinski_transformation(
317326 }
318327 }
319328
320- new_dag. add_global_phase ( & Param :: Float ( global_phase_update) ) ?;
329+ new_dag. add_global_phase ( & global_phase_update) ?;
321330
322331 // Add Clifford gates to the Qiskit circuit (when required).
323332 // Since we aim to preserve the global phase of the circuit, we add the Clifford operations from
0 commit comments