-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tested the compiler passes for single qudit uniaries. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Lukas Burgholzer <[email protected]>
- Loading branch information
1 parent
c1dee1a
commit c5af9f9
Showing
9 changed files
with
249 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
test/python/compiler/onedit/test_phy_local_adaptive_decomp.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
Oops, something went wrong.