diff --git a/src/mqt/qudits/compiler/dit_manager.py b/src/mqt/qudits/compiler/dit_manager.py index ad7f884..649b3e4 100644 --- a/src/mqt/qudits/compiler/dit_manager.py +++ b/src/mqt/qudits/compiler/dit_manager.py @@ -1,7 +1,6 @@ from __future__ import annotations -from .onedit import LogLocAdaPass, LogLocQRPass, PhyLocAdaPass, PhyLocQRPass, ZPropagationPass, ZRemovalPass -from .twodit import LogEntQRCEXPass +from .onedit import LogLocQRPass, PhyLocAdaPass, PhyLocQRPass, ZPropagationPass, ZRemovalPass class QuditCompiler: @@ -10,9 +9,7 @@ class QuditCompiler: "PhyLocAdaPass": PhyLocAdaPass, "LocQRPass": PhyLocQRPass, "LocAdaPass": PhyLocAdaPass, - "LogLocAdaPass": LogLocAdaPass, "LogLocQRPass": LogLocQRPass, - "LogEntQRCEXPass": LogEntQRCEXPass, "ZPropagationPass": ZPropagationPass, "ZRemovalPass": ZRemovalPass, } diff --git a/src/mqt/qudits/compiler/onedit/mapping_un_aware_transpilation/log_local_adaptive_decomp.py b/src/mqt/qudits/compiler/onedit/mapping_un_aware_transpilation/log_local_adaptive_decomp.py index 2af73f0..c154beb 100644 --- a/src/mqt/qudits/compiler/onedit/mapping_un_aware_transpilation/log_local_adaptive_decomp.py +++ b/src/mqt/qudits/compiler/onedit/mapping_un_aware_transpilation/log_local_adaptive_decomp.py @@ -9,13 +9,6 @@ from ....quantum_circuit import gates from ....quantum_circuit.components.extensions.gate_types import GateTypes from ... import CompilerPass -from ...compilation_minitools import new_mod -from ..local_operation_swap import ( - cost_calculator, - gate_chain_condition, - graph_rule_ongate, - graph_rule_update, -) from ..mapping_aware_transpilation import PhyQrDecomp np.seterr(all="ignore") @@ -90,10 +83,9 @@ def execute(self): matrices_decomposed, best_cost, final_graph = self.TREE.retrieve_decomposition(self.TREE.root) if matrices_decomposed != []: - pass - # matrices_decomposed, final_graph = self.Z_extraction( - # matrices_decomposed, final_graph, self.phase_propagation - # ) + matrices_decomposed, final_graph = self.z_extraction( + matrices_decomposed, final_graph, self.phase_propagation + ) else: pass @@ -131,40 +123,11 @@ def z_extraction(self, decomposition, placement, phase_propagation): for i in range(dimension): if abs(np.angle(diag_U[i])) > 1.0e-4: - if phase_propagation: - inode = placement._1stInode - if "phase_storage" in placement.nodes[inode]: - placement.nodes[i]["phase_storage"] += np.angle(diag_U[i]) - placement.nodes[i]["phase_storage"] = new_mod(placement.nodes[i]["phase_storage"]) - else: - n_i = placement.nodes[i] # ["lpmap"] - - phase_gate = gates.VirtRz( - self.circuit, "VRz", self.qudit_index, [n_i, np.angle(diag_U[i])], self.dimension - ) # old version: VirtRz(np.angle(diag_U[i]), phy_n_i, - # dimension) - - U_ = phase_gate.to_matrix(identities=0) @ U_ # matmul(phase_gate.to_matrix(identities=0), U_) - - matrices.append(phase_gate) - - if not phase_propagation: - inode = placement._1stInode - if "phase_storage" in placement.nodes[inode]: - for i in range(len(list(placement.nodes))): - thetaZ = new_mod(placement.nodes[i]["phase_storage"]) - if abs(thetaZ) > 1.0e-4: - phase_gate = gates.VirtRz( - self.circuit, - "VRz", - self.qudit_index, - [i, thetaZ], - self.dimension, - ) # VirtRz(thetaZ, placement.nodes[i]['lpmap'], # [placement.nodes[i]["lpmap"], thetaZ], - # dimension) - matrices.append(phase_gate) - # reset the node - placement.nodes[i]["phase_storage"] = 0 + phase_gate = gates.VirtRz( + self.circuit, "VRz", self.qudit_index, [i, np.angle(diag_U[i])], self.dimension + ) # old version: VirtRz(np.angle(diag_U[i]), phy_n_i, dimension) + U_ = phase_gate.to_matrix(identities=0) @ U_ + matrices.append(phase_gate) return matrices, placement @@ -172,8 +135,6 @@ def DFS(self, current_root, level=0) -> None: # check if close to diagonal Ucopy = current_root.U_of_level.copy() - current_placement = current_root.graph - # is the diagonal noisy? valid_diag = any(abs(np.diag(Ucopy)) > 1.0e-4) @@ -204,7 +165,6 @@ def DFS(self, current_root, level=0) -> None: for r2 in range(r + 1, dimension): if abs(U_[r2, c]) > 1.0e-8 and (abs(U_[r, c]) > 1.0e-18 or abs(U_[r, c]) == 0): theta = 2 * np.arctan2(abs(U_[r2, c]), abs(U_[r, c])) - phi = -(np.pi / 2 + np.angle(U_[r, c]) - np.angle(U_[r2, c])) rotation_involved = gates.R( @@ -213,18 +173,7 @@ def DFS(self, current_root, level=0) -> None: U_temp = rotation_involved.to_matrix(identities=0) @ U_ # matmul(rotation_involved.matrix, U_) - non_zeros = np.count_nonzero(abs(U_temp) > 1.0e-4) - - ( - estimated_cost, - pi_pulses_routing, - new_placement, - cost_of_pi_pulses, - gate_cost, - ) = cost_calculator(rotation_involved, current_placement, non_zeros) - - next_step_cost = estimated_cost + current_root.current_cost - decomp_next_step_cost = cost_of_pi_pulses + gate_cost + current_root.current_decomp_cost + decomp_next_step_cost = rotation_involved.cost + current_root.current_decomp_cost branch_condition = current_root.max_cost[1] - decomp_next_step_cost @@ -234,54 +183,12 @@ def DFS(self, current_root, level=0) -> None: self.TREE.global_id_counter += 1 new_key = self.TREE.global_id_counter - if new_placement.nodes[r]["lpmap"] > new_placement.nodes[r2]["lpmap"]: - phi *= -1 - physical_rotation = gates.R( - self.circuit, - "R", - self.qudit_index, - [new_placement.nodes[r]["lpmap"], new_placement.nodes[r2]["lpmap"], theta, phi], - self.dimension, - ) - # R(theta, phi, new_placement.nodes[r]['lpmap'], - # new_placement.nodes[r2]['lpmap'], dimension) - # - physical_rotation = gate_chain_condition(pi_pulses_routing, physical_rotation) - physical_rotation = graph_rule_ongate(physical_rotation, new_placement) - - # take care of phases accumulated by not pi-pulsing back - p_backs = [] - for ppulse in pi_pulses_routing: - p_backs.append( - gates.R( - self.circuit, - "R", - self.qudit_index, - [ppulse.lev_a, ppulse.lev_b, ppulse.theta, -ppulse.phi], - self.dimension, - ) - ) - # p_backs.append(R(ppulse.theta, -ppulse.phi, ppulse.lev_a, ppulse.lev_b, dimension)) - - for p_back in p_backs: - graph_rule_update(p_back, new_placement) - """ - current_root.add( - new_key, - physical_rotation, - U_temp, - new_placement, - next_step_cost, - decomp_next_step_cost, - current_root.max_cost, - pi_pulses_routing - )""" current_root.add( new_key, rotation_involved, U_temp, - new_placement, - next_step_cost, + None, # new_placement, + 0, # next_step_cost, decomp_next_step_cost, current_root.max_cost, [], diff --git a/test/python/compiler/onedit/test_log_local_adaptive_decomp.py b/test/python/compiler/onedit/test_log_local_adaptive_decomp.py index 871a222..91964e2 100644 --- a/test/python/compiler/onedit/test_log_local_adaptive_decomp.py +++ b/test/python/compiler/onedit/test_log_local_adaptive_decomp.py @@ -9,39 +9,40 @@ def test_transpile(self): class TestLogAdaptiveDecomposition(TestCase): - def test_execute(self): - pass - # dim = 5 - # test_sample_edges = [(0, 4, {"delta_m": 0, "sensitivity": 1}), - # (0, 3, {"delta_m": 1, "sensitivity": 3}), - # (0, 2, {"delta_m": 1, "sensitivity": 3}), - # (1, 4, {"delta_m": 0, "sensitivity": 1}), - # (1, 3, {"delta_m": 1, "sensitivity": 3}), - # (1, 2, {"delta_m": 1, "sensitivity": 3}) - # ] - # test_sample_nodes = [0, 1, 2, 3, 4] - # test_sample_nodes_map = [3, 2, 4, 1, 0] - # - # graph_1 = level_Graph(test_sample_edges, test_sample_nodes, test_sample_nodes_map, [0]) - # graph_1.phase_storing_setup() - # - # Htest = H(dim) - # - # #----------------- - # QR = QR_decomp( Htest, graph_1, Z_prop = False, not_stand_alone = True ) - # - # decomp_qr, algorithmic_cost_qr, total_cost_qr = QR.execute() - # #---------------- - # - # ADA = Adaptive_decomposition(Htest, graph_1, cost_limit=(1.1 * algorithmic_cost_qr, 1.1 * total_cost_qr), dimension=dim, Z_prop=False) - # - # matrices_decomposed, best_cost, final_graph = ADA.execute() + """def test_execute(self): + dim = 3 + test_sample_edges = [(0, 4, {"delta_m": 0, "sensitivity": 1}), + (0, 3, {"delta_m": 1, "sensitivity": 3}), + (0, 2, {"delta_m": 1, "sensitivity": 3}), + (1, 4, {"delta_m": 0, "sensitivity": 1}), + (1, 3, {"delta_m": 1, "sensitivity": 3}), + (1, 2, {"delta_m": 1, "sensitivity": 3}) + ] + test_sample_nodes = [0, 1, 2, 3, 4] + test_sample_nodes_map = [3, 2, 4, 1, 0] + + circuit_5 = QuantumCircuit(1, [5], 0) + graph_1 = LevelGraph(test_sample_edges, test_sample_nodes, test_sample_nodes_map, [0], 0, circuit_5) + + Htest = circuit_5.h(0) + graph_1.phase_storing_setup() + + QR = QrDecomp(Htest, graph_1, Z_prop=False, not_stand_alone=False) + # gate, graph_orig, Z_prop=False, not_stand_alone=True + + decomp, _algorithmic_cost, _total_cost = QR.execute() + + ADA = LogAdaptiveDecomposition(Htest, graph_1, cost_limit=(1.1 * _algorithmic_cost, 1.1 * _total_cost), + dimension=5, Z_prop=False) + # gate, graph_orig, cost_limit=(0, 0), dimension=-1, Z_prop=False + matrices_decomposed, best_cost, final_graph = ADA.execute() # ############################################## - # - # - # V = Verifier(matrices_decomposed, Htest, test_sample_nodes, test_sample_nodes_map, graph_1.lpmap, dim) - # self.assertEqual( len(matrices_decomposed), 17) - # self.assertTrue(V.verify()) + + V = UnitaryVerifier( + matrices_decomposed, Htest, [dim], test_sample_nodes, test_sample_nodes_map, graph_1.log_phy_map + ) + # self.assertEqual(len(matrices_decomposed), 17) + self.assertTrue(V.verify()) def test_dfs(self): - pass + pass""" diff --git a/test/python/compiler/onedit/test_log_local_qr_decomp.py b/test/python/compiler/onedit/test_log_local_qr_decomp.py index 48ba194..13a2387 100644 --- a/test/python/compiler/onedit/test_log_local_qr_decomp.py +++ b/test/python/compiler/onedit/test_log_local_qr_decomp.py @@ -15,7 +15,6 @@ def test_transpile(self): class TestQrDecomp(TestCase): def test_execute(self): - # DIM 3 dim = 3 test_sample_edges = [ (0, 2, {"delta_m": 0, "sensitivity": 1}), @@ -34,9 +33,7 @@ def test_execute(self): decomp, _algorithmic_cost, _total_cost = QR.execute() - V = UnitaryVerifier( - decomp, Htest.to_matrix(identities=0), [dim], test_sample_nodes, test_sample_nodes_map, graph_1.log_phy_map - ) + V = UnitaryVerifier(decomp, Htest, [dim], test_sample_nodes, test_sample_nodes_map, graph_1.log_phy_map) # sequence, target, dimensions, nodes=None, initial_map=None, final_map=None assert len(decomp) == 5 assert V.verify() diff --git a/test/python/compiler/onedit/test_phy_local_adaptive_decomp.py b/test/python/compiler/onedit/test_phy_local_adaptive_decomp.py new file mode 100644 index 0000000..21a330c --- /dev/null +++ b/test/python/compiler/onedit/test_phy_local_adaptive_decomp.py @@ -0,0 +1,55 @@ +from __future__ import annotations + +from unittest import TestCase + +from mqt.qudits.compiler.compilation_minitools import UnitaryVerifier +from mqt.qudits.compiler.onedit.mapping_aware_transpilation import PhyAdaptiveDecomposition, PhyQrDecomp +from mqt.qudits.core import LevelGraph +from mqt.qudits.quantum_circuit import QuantumCircuit + + +class TestPhyLocAdaPass(TestCase): + def test_transpile(self): + pass + + +class TestPhyAdaptiveDecomposition(TestCase): + def test_execute(self): + dim = 5 + test_sample_edges = [ + (0, 4, {"delta_m": 0, "sensitivity": 1}), + (0, 3, {"delta_m": 1, "sensitivity": 3}), + (0, 2, {"delta_m": 1, "sensitivity": 3}), + (1, 4, {"delta_m": 0, "sensitivity": 1}), + (1, 3, {"delta_m": 1, "sensitivity": 3}), + (1, 2, {"delta_m": 1, "sensitivity": 3}), + ] + test_sample_nodes = [0, 1, 2, 3, 4] + test_sample_nodes_map = [3, 2, 4, 1, 0] + + circuit_5 = QuantumCircuit(1, [5], 0) + graph_1 = LevelGraph(test_sample_edges, test_sample_nodes, test_sample_nodes_map, [0], 0, circuit_5) + + Htest = circuit_5.h(0) + graph_1.phase_storing_setup() + + QR = PhyQrDecomp(Htest, graph_1, Z_prop=False, not_stand_alone=False) + # gate, graph_orig, Z_prop=False, not_stand_alone=True + + _decomp, _algorithmic_cost, _total_cost = QR.execute() + + ADA = PhyAdaptiveDecomposition( + Htest, graph_1, cost_limit=(1.1 * _algorithmic_cost, 1.1 * _total_cost), dimension=5, Z_prop=False + ) + # gate, graph_orig, cost_limit=(0, 0), dimension=-1, Z_prop=False + matrices_decomposed, _best_cost, final_graph = ADA.execute() + # ############################################## + + V = UnitaryVerifier( + matrices_decomposed, Htest, [dim], test_sample_nodes, test_sample_nodes_map, final_graph.log_phy_map + ) + assert len(matrices_decomposed) == 17 + assert V.verify() + + def test_dfs(self): + pass diff --git a/test/python/compiler/onedit/test_phy_local_qr_decomp.py b/test/python/compiler/onedit/test_phy_local_qr_decomp.py new file mode 100644 index 0000000..4964b3b --- /dev/null +++ b/test/python/compiler/onedit/test_phy_local_qr_decomp.py @@ -0,0 +1,45 @@ +from __future__ import annotations + +from unittest import TestCase + +from mqt.qudits.compiler.compilation_minitools import UnitaryVerifier +from mqt.qudits.compiler.onedit.mapping_aware_transpilation import PhyQrDecomp +from mqt.qudits.core import LevelGraph +from mqt.qudits.quantum_circuit import QuantumCircuit + + +class TestPhyLocQRPass(TestCase): + def test_transpile(self): + pass + + +class TestPhyQRDecomposition(TestCase): + def test_execute(self): + dim = 5 + test_sample_edges = [ + (0, 4, {"delta_m": 0, "sensitivity": 1}), + (0, 3, {"delta_m": 1, "sensitivity": 3}), + (0, 2, {"delta_m": 1, "sensitivity": 3}), + (1, 4, {"delta_m": 0, "sensitivity": 1}), + (1, 3, {"delta_m": 1, "sensitivity": 3}), + (1, 2, {"delta_m": 1, "sensitivity": 3}), + ] + test_sample_nodes = [0, 1, 2, 3, 4] + test_sample_nodes_map = [3, 2, 4, 1, 0] + + circuit_5 = QuantumCircuit(1, [5], 0) + graph_1 = LevelGraph(test_sample_edges, test_sample_nodes, test_sample_nodes_map, [0], 0, circuit_5) + + Htest = circuit_5.h(0) + graph_1.phase_storing_setup() + + QR = PhyQrDecomp(Htest, graph_1, Z_prop=False, not_stand_alone=False) + # gate, graph_orig, Z_prop=False, not_stand_alone=True + + decomp, _algorithmic_cost, _total_cost = QR.execute() + + # ############################################## + + V = UnitaryVerifier(decomp, Htest, [dim], test_sample_nodes, test_sample_nodes_map, graph_1.log_phy_map) + assert len(decomp) == 30 + assert V.verify() diff --git a/test/python/compiler/onedit/test_propagate_virtrz.py b/test/python/compiler/onedit/test_propagate_virtrz.py index 9317f17..430dc8e 100644 --- a/test/python/compiler/onedit/test_propagate_virtrz.py +++ b/test/python/compiler/onedit/test_propagate_virtrz.py @@ -2,52 +2,53 @@ from unittest import TestCase +import numpy as np + +from mqt.qudits.compiler import QuditCompiler +from mqt.qudits.compiler.onedit import ZPropagationPass +from mqt.qudits.quantum_circuit import QuantumCircuit +from mqt.qudits.quantum_circuit.components.quantum_register import QuantumRegister +from mqt.qudits.simulation import MQTQuditProvider -class TestZPropagationPass(TestCase): - """def test_tag_generator(self): - gates = [R(np.pi, np.pi / 2, 0, 1, 3), Rz(np.pi / 3, 0, 3), R(np.pi, np.pi / 2, 0, 1, 3), - R(np.pi, np.pi / 2, 0, 1, 3), Rz(np.pi / 3, 0, 3)] - tags = tag_generator(gates) - self.assertEqual([0, 1, 1, 1, 2], tags) +class TestZPropagationPass(TestCase): + def setUp(self): + provider = MQTQuditProvider() + self.compiler = QuditCompiler() + self.passes = ["ZPropagationPass"] + self.backend_ion = provider.get_backend("faketraps2trits", shots=1000) def test_propagate_z(self): - QC = QuantumCircuit(1, 0, 3, None, False) - QC.qreg[0] = [R(np.pi, np.pi / 3, 0, 1, 3), Rz(np.pi / 3, 0, 3), R(np.pi, np.pi / 3, 0, 1, 3), - R(np.pi, np.pi / 3, 0, 1, 3), Rz(np.pi / 3, 0, 3)] - - list_of_XYrots, Zseq = propagate_z(QC, 0, True) - - self.assertEqual(list_of_XYrots[1].phi, 2 * np.pi / 3) - self.assertEqual(list_of_XYrots[2].phi, 2 * np.pi / 3) - self.assertEqual(list_of_XYrots[0].phi, np.pi) - - self.assertEqual(Zseq[1].theta, 4 * np.pi) - self.assertEqual(Zseq[2].theta, 4 * np.pi) - self.assertEqual(Zseq[0].theta, 2 * np.pi / 3) - - def test_remove_z(self): - QC = QuantumCircuit(1, 0, 3, None, False) - QC.qreg[0] = [R(np.pi, np.pi / 3, 0, 1, 3), Rz(np.pi / 3, 0, 3), R(np.pi, np.pi / 3, 0, 1, 3), - R(np.pi, np.pi / 3, 0, 1, 3), Rz(np.pi / 3, 0, 3)] - remove_Z(QC, back=True) - - self.assertIsInstance(QC.qreg[0][0], Rz) - self.assertIsInstance(QC.qreg[0][1], Rz) - self.assertIsInstance(QC.qreg[0][2], Rz) - self.assertIsInstance(QC.qreg[0][3], R) - self.assertIsInstance(QC.qreg[0][4], R) - self.assertIsInstance(QC.qreg[0][4], R) - - QC = QuantumCircuit(1, 0, 3, None, False) - QC.qreg[0] = [R(np.pi, np.pi / 3, 0, 1, 3), Rz(np.pi / 3, 0, 3), R(np.pi, np.pi / 3, 0, 1, 3), - R(np.pi, np.pi / 3, 0, 1, 3), Rz(np.pi / 3, 0, 3)] - remove_Z(QC, False) - - self.assertIsInstance(QC.qreg[0][0], R) - self.assertIsInstance(QC.qreg[0][1], R) - self.assertIsInstance(QC.qreg[0][2], R) - self.assertIsInstance(QC.qreg[0][3], Rz) - self.assertIsInstance(QC.qreg[0][4], Rz) - self.assertIsInstance(QC.qreg[0][4], Rz) - """ + qreg = QuantumRegister("test_reg", 1, [3]) + circ = QuantumCircuit(qreg) + + circ.r(qreg[0], [0, 1, np.pi, np.pi / 3]) + circ.virtrz(qreg[0], [0, np.pi / 3]) + circ.r(qreg[0], [0, 1, np.pi, np.pi / 3]) + circ.r(qreg[0], [0, 1, np.pi, np.pi / 3]) + circ.virtrz(qreg[0], [0, np.pi / 3]) + + # R(np.pi, np.pi / 3, 0, 1, 3), Rz(np.pi / 3, 0, 3), + # R(np.pi, np.pi / 3, 0, 1, 3), R(np.pi, np.pi / 3, 0, 1, 3), Rz(np.pi / 3, 0, 3)] + new_circuit = self.compiler.compile(self.backend_ion, circ, self.passes) + + # VirtZs + assert new_circuit.instructions[0].phi == 2 * np.pi / 3 + assert new_circuit.instructions[1].phi == 4 * np.pi + assert new_circuit.instructions[2].phi == 4 * np.pi + # Rs + assert new_circuit.instructions[3].phi == np.pi / 3 + 2 * np.pi / 3 + assert new_circuit.instructions[4].phi == 2 * np.pi / 3 + assert new_circuit.instructions[5].phi == 2 * np.pi / 3 + + pass_z = ZPropagationPass(backend=self.backend_ion, back=False) + new_circuit = pass_z.transpile(circ) + + # Rs + assert new_circuit.instructions[0].phi == np.pi / 3 + assert new_circuit.instructions[1].phi == 0.0 + assert new_circuit.instructions[2].phi == 0.0 + # VirtZs + assert new_circuit.instructions[3].phi == 2 * np.pi / 3 + assert new_circuit.instructions[4].phi == 4 * np.pi + assert new_circuit.instructions[5].phi == 4 * np.pi diff --git a/test/python/compiler/onedit/test_remove_phase_rotations.py b/test/python/compiler/onedit/test_remove_phase_rotations.py index e69de29..2540e14 100644 --- a/test/python/compiler/onedit/test_remove_phase_rotations.py +++ b/test/python/compiler/onedit/test_remove_phase_rotations.py @@ -0,0 +1,54 @@ +from __future__ import annotations + +from unittest import TestCase + +import numpy as np + +from mqt.qudits.compiler import QuditCompiler +from mqt.qudits.quantum_circuit import QuantumCircuit +from mqt.qudits.quantum_circuit.components.quantum_register import QuantumRegister +from mqt.qudits.simulation import MQTQuditProvider + + +class TestZRemovalPass(TestCase): + def test_remove_z(self): + provider = MQTQuditProvider() + compiler = QuditCompiler() + passes = ["ZRemovalPass"] + backend_ion = provider.get_backend("faketraps2trits", shots=1000) + + qreg = QuantumRegister("test_reg", 3, [3, 3, 3]) + circ = QuantumCircuit(qreg) + + circ.virtrz(qreg[0], [0, np.pi / 3]) + circ.virtrz(qreg[1], [0, np.pi / 3]) + circ.r(qreg[1], [0, 1, np.pi, np.pi]) + circ.rz(qreg[0], [0, 1, np.pi / 3]) + + circ.r(qreg[0], [0, 1, np.pi, np.pi / 2]) + circ.r(qreg[1], [0, 1, np.pi, np.pi / 3]) + circ.r(qreg[2], [0, 1, np.pi, np.pi / 4]) + circ.r(qreg[1], [0, 1, np.pi, np.pi / 5]) + + circ.virtrz(qreg[0], [0, np.pi / 3]) + circ.r(qreg[1], [0, 1, np.pi, np.pi / 6]) + circ.rz(qreg[1], [0, 1, np.pi / 3]) + circ.rz(qreg[1], [0, 1, np.pi / 3]) + + new_circuit = compiler.compile(backend_ion, circ, passes) + + # Rs + assert len(new_circuit.instructions) == 6 + assert new_circuit.instructions[0].qasm_tag == "rxy" + assert new_circuit.instructions[1].qasm_tag == "rxy" + assert new_circuit.instructions[2].qasm_tag == "rxy" + assert new_circuit.instructions[3].qasm_tag == "rxy" + assert new_circuit.instructions[4].qasm_tag == "rxy" + assert new_circuit.instructions[5].qasm_tag == "rxy" + + assert new_circuit.instructions[0].phi == np.pi + assert new_circuit.instructions[1].phi == np.pi / 2 + assert new_circuit.instructions[2].phi == np.pi / 3 + assert new_circuit.instructions[3].phi == np.pi / 4 + assert new_circuit.instructions[4].phi == np.pi / 5 + assert new_circuit.instructions[5].phi == np.pi / 6 diff --git a/test/python/compiler/twodit/entangled_qr/test_entangled_qr.py b/test/python/compiler/twodit/entangled_qr/test_entangled_qr.py index 48ab5a4..fef6b3f 100644 --- a/test/python/compiler/twodit/entangled_qr/test_entangled_qr.py +++ b/test/python/compiler/twodit/entangled_qr/test_entangled_qr.py @@ -2,7 +2,6 @@ from unittest import TestCase -from mqt.qudits.compiler.dit_manager import QuditCompiler from mqt.qudits.quantum_circuit import QuantumCircuit from mqt.qudits.simulation import MQTQuditProvider @@ -14,11 +13,11 @@ def setUp(self) -> None: self.circuit_33 = QuantumCircuit(2, [3, 3], 0) self.cx = self.circuit_33.cx([0, 1]) - def test_entangling_qr(self): + """def test_entangling_qr(self): self.cx.to_matrix() provider = MQTQuditProvider() backend_ion = provider.get_backend("faketraps2trits", shots=1000) qudit_compiler = QuditCompiler() passes = ["LogEntQRCEXPass"] - qudit_compiler.compile(backend_ion, self.circuit_33, passes) + qudit_compiler.compile(backend_ion, self.circuit_33, passes)"""