@@ -928,7 +928,10 @@ def test_move_measurements(self):
928928 circ = QuantumCircuit .from_qasm_file (os .path .join (qasm_dir , "move_measurements.qasm" ))
929929
930930 lay = [0 , 1 , 15 , 2 , 14 , 3 , 13 , 4 , 12 , 5 , 11 , 6 ]
931- out = transpile (circ , initial_layout = lay , coupling_map = cmap , routing_method = "stochastic" )
931+ with self .assertWarns (DeprecationWarning ):
932+ out = transpile (
933+ circ , initial_layout = lay , coupling_map = cmap , routing_method = "stochastic"
934+ )
932935 out_dag = circuit_to_dag (out )
933936 meas_nodes = out_dag .named_nodes ("measure" )
934937 for meas_node in meas_nodes :
@@ -3498,7 +3501,7 @@ def _visit_block(circuit, qubit_mapping=None):
34983501 )[0 ]
34993502 self .assertIn (qubit_map [op_node .qargs [0 ]], components [2 ])
35003503
3501- @data ("sabre" , "stochastic" , " basic" , "lookahead" )
3504+ @data ("sabre" , "basic" , "lookahead" )
35023505 def test_basic_connected_circuit_dense_layout (self , routing_method ):
35033506 """Test basic connected circuit on disjoint backend"""
35043507 qc = QuantumCircuit (5 )
@@ -3522,8 +3525,34 @@ def test_basic_connected_circuit_dense_layout(self, routing_method):
35223525 continue
35233526 self .assertIn (qubits , self .backend .target [op_name ])
35243527
3528+ @data ("stochastic" )
3529+ def test_basic_connected_circuit_dense_layout_stochastic (self , routing_method ):
3530+ """Test basic connected circuit on disjoint backend for deprecated stochastic swap"""
3531+ # TODO: Remove when StochasticSwap is removed
3532+ qc = QuantumCircuit (5 )
3533+ qc .h (0 )
3534+ qc .cx (0 , 1 )
3535+ qc .cx (0 , 2 )
3536+ qc .cx (0 , 3 )
3537+ qc .cx (0 , 4 )
3538+ qc .measure_all ()
3539+ with self .assertWarns (DeprecationWarning ):
3540+ tqc = transpile (
3541+ qc ,
3542+ self .backend ,
3543+ layout_method = "dense" ,
3544+ routing_method = routing_method ,
3545+ seed_transpiler = 42 ,
3546+ )
3547+ for inst in tqc .data :
3548+ qubits = tuple (tqc .find_bit (x ).index for x in inst .qubits )
3549+ op_name = inst .operation .name
3550+ if op_name == "barrier" :
3551+ continue
3552+ self .assertIn (qubits , self .backend .target [op_name ])
3553+
35253554 # Lookahead swap skipped for performance
3526- @data ("sabre" , "stochastic" , " basic" )
3555+ @data ("sabre" , "basic" )
35273556 def test_triple_circuit_dense_layout (self , routing_method ):
35283557 """Test a split circuit with one circuit component per chip."""
35293558 qc = QuantumCircuit (30 )
@@ -3572,7 +3601,58 @@ def test_triple_circuit_dense_layout(self, routing_method):
35723601 continue
35733602 self .assertIn (qubits , self .backend .target [op_name ])
35743603
3575- @data ("sabre" , "stochastic" , "basic" , "lookahead" )
3604+ @data ("stochastic" )
3605+ def test_triple_circuit_dense_layout_stochastic (self , routing_method ):
3606+ """Test a split circuit with one circuit component per chip for deprecated StochasticSwap."""
3607+ # TODO: Remove when StochasticSwap is removed
3608+ qc = QuantumCircuit (30 )
3609+ qc .h (0 )
3610+ qc .h (10 )
3611+ qc .h (20 )
3612+ qc .cx (0 , 1 )
3613+ qc .cx (0 , 2 )
3614+ qc .cx (0 , 3 )
3615+ qc .cx (0 , 4 )
3616+ qc .cx (0 , 5 )
3617+ qc .cx (0 , 6 )
3618+ qc .cx (0 , 7 )
3619+ qc .cx (0 , 8 )
3620+ qc .cx (0 , 9 )
3621+ qc .ecr (10 , 11 )
3622+ qc .ecr (10 , 12 )
3623+ qc .ecr (10 , 13 )
3624+ qc .ecr (10 , 14 )
3625+ qc .ecr (10 , 15 )
3626+ qc .ecr (10 , 16 )
3627+ qc .ecr (10 , 17 )
3628+ qc .ecr (10 , 18 )
3629+ qc .ecr (10 , 19 )
3630+ qc .cy (20 , 21 )
3631+ qc .cy (20 , 22 )
3632+ qc .cy (20 , 23 )
3633+ qc .cy (20 , 24 )
3634+ qc .cy (20 , 25 )
3635+ qc .cy (20 , 26 )
3636+ qc .cy (20 , 27 )
3637+ qc .cy (20 , 28 )
3638+ qc .cy (20 , 29 )
3639+ qc .measure_all ()
3640+ with self .assertWarns (DeprecationWarning ):
3641+ tqc = transpile (
3642+ qc ,
3643+ self .backend ,
3644+ layout_method = "dense" ,
3645+ routing_method = routing_method ,
3646+ seed_transpiler = 42 ,
3647+ )
3648+ for inst in tqc .data :
3649+ qubits = tuple (tqc .find_bit (x ).index for x in inst .qubits )
3650+ op_name = inst .operation .name
3651+ if op_name == "barrier" :
3652+ continue
3653+ self .assertIn (qubits , self .backend .target [op_name ])
3654+
3655+ @data ("sabre" , "basic" , "lookahead" )
35763656 def test_triple_circuit_invalid_layout (self , routing_method ):
35773657 """Test a split circuit with one circuit component per chip."""
35783658 qc = QuantumCircuit (30 )
@@ -3616,8 +3696,54 @@ def test_triple_circuit_invalid_layout(self, routing_method):
36163696 seed_transpiler = 42 ,
36173697 )
36183698
3619- # Lookahead swap skipped for performance reasons
3620- @data ("sabre" , "stochastic" , "basic" )
3699+ @data ("stochastic" )
3700+ def test_triple_circuit_invalid_layout_stochastic (self , routing_method ):
3701+ """Test a split circuit with one circuit component per chip for deprecated ``StochasticSwap``"""
3702+ # TODO: Remove when StochasticSwap is removed
3703+ qc = QuantumCircuit (30 )
3704+ qc .h (0 )
3705+ qc .h (10 )
3706+ qc .h (20 )
3707+ qc .cx (0 , 1 )
3708+ qc .cx (0 , 2 )
3709+ qc .cx (0 , 3 )
3710+ qc .cx (0 , 4 )
3711+ qc .cx (0 , 5 )
3712+ qc .cx (0 , 6 )
3713+ qc .cx (0 , 7 )
3714+ qc .cx (0 , 8 )
3715+ qc .cx (0 , 9 )
3716+ qc .ecr (10 , 11 )
3717+ qc .ecr (10 , 12 )
3718+ qc .ecr (10 , 13 )
3719+ qc .ecr (10 , 14 )
3720+ qc .ecr (10 , 15 )
3721+ qc .ecr (10 , 16 )
3722+ qc .ecr (10 , 17 )
3723+ qc .ecr (10 , 18 )
3724+ qc .ecr (10 , 19 )
3725+ qc .cy (20 , 21 )
3726+ qc .cy (20 , 22 )
3727+ qc .cy (20 , 23 )
3728+ qc .cy (20 , 24 )
3729+ qc .cy (20 , 25 )
3730+ qc .cy (20 , 26 )
3731+ qc .cy (20 , 27 )
3732+ qc .cy (20 , 28 )
3733+ qc .cy (20 , 29 )
3734+ qc .measure_all ()
3735+ with self .assertWarns (DeprecationWarning ):
3736+ with self .assertRaises (TranspilerError ):
3737+ transpile (
3738+ qc ,
3739+ self .backend ,
3740+ layout_method = "trivial" ,
3741+ routing_method = routing_method ,
3742+ seed_transpiler = 42 ,
3743+ )
3744+
3745+ # Lookahead swap skipped for performance reasons, stochastic moved to new test due to deprecation
3746+ @data ("sabre" , "basic" )
36213747 def test_six_component_circuit_dense_layout (self , routing_method ):
36223748 """Test input circuit with more than 1 component per backend component."""
36233749 qc = QuantumCircuit (42 )
@@ -3678,6 +3804,71 @@ def test_six_component_circuit_dense_layout(self, routing_method):
36783804 continue
36793805 self .assertIn (qubits , self .backend .target [op_name ])
36803806
3807+ # Lookahead swap skipped for performance reasons
3808+ @data ("stochastic" )
3809+ def test_six_component_circuit_dense_layout_stochastic (self , routing_method ):
3810+ """Test input circuit with more than 1 component per backend component
3811+ for deprecated ``StochasticSwap``."""
3812+ # TODO: Remove when StochasticSwap is removed
3813+ qc = QuantumCircuit (42 )
3814+ qc .h (0 )
3815+ qc .h (10 )
3816+ qc .h (20 )
3817+ qc .cx (0 , 1 )
3818+ qc .cx (0 , 2 )
3819+ qc .cx (0 , 3 )
3820+ qc .cx (0 , 4 )
3821+ qc .cx (0 , 5 )
3822+ qc .cx (0 , 6 )
3823+ qc .cx (0 , 7 )
3824+ qc .cx (0 , 8 )
3825+ qc .cx (0 , 9 )
3826+ qc .ecr (10 , 11 )
3827+ qc .ecr (10 , 12 )
3828+ qc .ecr (10 , 13 )
3829+ qc .ecr (10 , 14 )
3830+ qc .ecr (10 , 15 )
3831+ qc .ecr (10 , 16 )
3832+ qc .ecr (10 , 17 )
3833+ qc .ecr (10 , 18 )
3834+ qc .ecr (10 , 19 )
3835+ qc .cy (20 , 21 )
3836+ qc .cy (20 , 22 )
3837+ qc .cy (20 , 23 )
3838+ qc .cy (20 , 24 )
3839+ qc .cy (20 , 25 )
3840+ qc .cy (20 , 26 )
3841+ qc .cy (20 , 27 )
3842+ qc .cy (20 , 28 )
3843+ qc .cy (20 , 29 )
3844+ qc .h (30 )
3845+ qc .cx (30 , 31 )
3846+ qc .cx (30 , 32 )
3847+ qc .cx (30 , 33 )
3848+ qc .h (34 )
3849+ qc .cx (34 , 35 )
3850+ qc .cx (34 , 36 )
3851+ qc .cx (34 , 37 )
3852+ qc .h (38 )
3853+ qc .cx (38 , 39 )
3854+ qc .cx (39 , 40 )
3855+ qc .cx (39 , 41 )
3856+ qc .measure_all ()
3857+ with self .assertWarns (DeprecationWarning ):
3858+ tqc = transpile (
3859+ qc ,
3860+ self .backend ,
3861+ layout_method = "dense" ,
3862+ routing_method = routing_method ,
3863+ seed_transpiler = 42 ,
3864+ )
3865+ for inst in tqc .data :
3866+ qubits = tuple (tqc .find_bit (x ).index for x in inst .qubits )
3867+ op_name = inst .operation .name
3868+ if op_name == "barrier" :
3869+ continue
3870+ self .assertIn (qubits , self .backend .target [op_name ])
3871+
36813872 @data (0 , 1 , 2 , 3 )
36823873 def test_transpile_target_with_qubits_without_ops (self , opt_level ):
36833874 """Test qubits without operations aren't ever used."""
0 commit comments