Skip to content

Commit

Permalink
testing basic compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinMTO committed Apr 29, 2024
1 parent 72ba44c commit f8a71a1
Show file tree
Hide file tree
Showing 18 changed files with 249 additions and 1,156 deletions.
Binary file removed MQT Tutorial/2d_example.png
Binary file not shown.
Binary file removed MQT Tutorial/2dqed.png
Binary file not shown.
836 changes: 0 additions & 836 deletions MQT Tutorial/MQT Qudits Tutorial.ipynb

This file was deleted.

278 changes: 0 additions & 278 deletions MQT Tutorial/MQT Qudits in Short.ipynb

This file was deleted.

Binary file removed MQT Tutorial/MQT slide.pdf
Binary file not shown.
Binary file removed MQT Tutorial/foot.png
Binary file not shown.
Empty file.
Empty file.
46 changes: 46 additions & 0 deletions test/python/compiler/onedit/test_log_local_adaptive_decomp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from unittest import TestCase


class TestLogLocAdaPass(TestCase):
def test_transpile(self):
pass


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()
# ##############################################
#
#
# 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())

def test_dfs(self):
pass
44 changes: 44 additions & 0 deletions test/python/compiler/onedit/test_log_local_qr_decomp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from unittest import TestCase

from mqt.qudits.compiler.compilation_minitools import UnitaryVerifier
from mqt.qudits.compiler.onedit.mapping_un_aware_transpilation.log_local_qr_decomp import QrDecomp
from mqt.qudits.core import LevelGraph
from mqt.qudits.quantum_circuit import QuantumCircuit


class TestLogLocQRPass(TestCase):
def test_transpile(self):
pass


class TestQrDecomp(TestCase):
def test_execute(self):
# DIM 3
dim = 3
test_sample_edges = [(0, 2, {"delta_m": 0, "sensitivity": 1}),
(1, 2, {"delta_m": 0, "sensitivity": 1}),
]
test_sample_nodes = [0, 1, 2]
test_sample_nodes_map = [0, 1, 2]

circuit_3 = QuantumCircuit(1, [3], 0)
graph_1 = LevelGraph(test_sample_edges, test_sample_nodes, test_sample_nodes_map, [0], 0, circuit_3)

Htest = circuit_3.h(0)

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()

V = UnitaryVerifier(decomp, Htest.to_matrix(identities=0), [dim],
test_sample_nodes, test_sample_nodes_map, graph_1.log_phy_map)
# sequence, target, dimensions, nodes=None, initial_map=None, final_map=None
self.assertEqual(len(decomp), 5)
self.assertTrue(V.verify())

self.assertEqual((decomp[0].lev_a, decomp[0].lev_b), (1, 2))
self.assertEqual((decomp[1].lev_a, decomp[1].lev_b), (0, 1))
self.assertEqual((decomp[2].lev_a, decomp[2].lev_b), (1, 2))
self.assertEqual(decomp[3].lev_a, 1)
self.assertEqual(decomp[4].lev_a, 2)
Loading

0 comments on commit f8a71a1

Please sign in to comment.