-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ✨ return `QuantumCircuit` if Qiskit is available (including Layout information) * 🙈 add virtual environments to .gitignore file * 🔧🐍 make `qiskit-terra` a project dependency * 🚨 fix LGTM warning * ♻️ replace soon to be deprecated `qiskit.test.mock` imports * 📝 update documentation * ⬆️ QFR 📦 with a 🐛 fix for Qiskit `Layout` import * 🐛 fix output permutation bug in heuristic mapper * ⬆️ QFR 📦 with a 🐛 fix for the `cancelCNOTs` optimization * ✅ add tests verifying the correctness of the circuits produced by both mappers
- Loading branch information
1 parent
e6475a1
commit 108dd52
Showing
12 changed files
with
224 additions
and
71 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,11 @@ var/ | |
.installed.cfg | ||
*.egg | ||
.pytest_cache/ | ||
|
||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ |
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
Submodule qfr
updated
from 92bbd8 to 2c0c3d
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import warnings | ||
from mqt import * | ||
from mqt import qmap | ||
|
||
warnings.simplefilter('always', DeprecationWarning) | ||
warnings.warn('Usage via `import jkq` is deprecated in favor of the new prefix. Please use `import mqt` instead.', DeprecationWarning) |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import pytest | ||
from qiskit import QuantumCircuit | ||
from qiskit.providers.fake_provider import FakeLondon | ||
|
||
from mqt import qmap, qcec | ||
|
||
|
||
def test_exact_no_swaps_trivial_layout(): | ||
"""Verify that the exact mapper works on a simple circuit that requires no swaps on a trivial initial layout.""" | ||
qc = QuantumCircuit(3) | ||
qc.h(0) | ||
qc.cx(0, 1) | ||
qc.cx(1, 2) | ||
qc.measure_all() | ||
|
||
qc_mapped, results = qmap.compile(qc, arch=FakeLondon(), method="exact") | ||
assert results.timeout is False | ||
assert results.mapped_circuit != "" | ||
assert results.output.swaps == 0 | ||
|
||
result = qcec.verify(qc, qc_mapped) | ||
assert result.considered_equivalent() is True | ||
|
||
|
||
def test_exact_no_swaps_non_trivial_layout(): | ||
"""Verify that the exact mapper works on a simple circuit that requires a non-trivial layout to achieve no swaps.""" | ||
qc = QuantumCircuit(4) | ||
qc.h(0) | ||
qc.cx(0, 1) | ||
qc.cx(0, 2) | ||
qc.cx(0, 3) | ||
qc.measure_all() | ||
|
||
qc_mapped, results = qmap.compile(qc, arch=FakeLondon(), method="exact") | ||
|
||
assert results.timeout is False | ||
assert results.mapped_circuit != "" | ||
assert results.output.swaps == 0 | ||
|
||
result = qcec.verify(qc, qc_mapped) | ||
assert result.considered_equivalent() is True | ||
|
||
|
||
def test_exact_non_trivial_swaps(): | ||
"""Verify that the exact mapper works on a simple circuit that requires at least a single SWAP.""" | ||
qc = QuantumCircuit(3) | ||
qc.h(0) | ||
qc.cx(0, 1) | ||
qc.cx(1, 2) | ||
qc.cx(2, 0) | ||
qc.measure_all() | ||
|
||
qc_mapped, results = qmap.compile(qc, arch=FakeLondon(), method="exact") | ||
|
||
assert results.timeout is False | ||
assert results.mapped_circuit != "" | ||
assert results.output.swaps == 1 | ||
|
||
result = qcec.verify(qc, qc_mapped) | ||
assert result.considered_equivalent() is True |
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,67 @@ | ||
import pytest | ||
from qiskit import QuantumCircuit | ||
from qiskit.providers.fake_provider import FakeLondon | ||
|
||
from mqt import qmap, qcec | ||
|
||
|
||
def test_heuristic_no_swaps_trivial_layout(): | ||
"""Verify that the heuristic mapper works on a simple circuit that requires no swaps on a trivial initial layout.""" | ||
qc = QuantumCircuit(3) | ||
qc.h(0) | ||
qc.cx(0, 1) | ||
qc.cx(1, 2) | ||
qc.measure_all() | ||
|
||
qc_mapped, results = qmap.compile(qc, arch=FakeLondon()) | ||
assert results.timeout is False | ||
assert results.mapped_circuit != "" | ||
# assert results.output.swaps == 0 | ||
|
||
result = qcec.verify(qc, qc_mapped) | ||
assert result.considered_equivalent() is True | ||
|
||
|
||
def test_heuristic_no_swaps_non_trivial_layout(): | ||
"""Verify that the heuristic mapper works on a simple circuit that requires a non-trivial layout to achieve no swaps.""" | ||
qc = QuantumCircuit(4) | ||
qc.h(0) | ||
qc.cx(0, 1) | ||
qc.cx(0, 2) | ||
qc.cx(0, 3) | ||
qc.measure_all() | ||
|
||
qc_mapped, results = qmap.compile(qc, arch=FakeLondon()) | ||
|
||
assert results.timeout is False | ||
assert results.mapped_circuit != "" | ||
# assert results.output.swaps == 0 | ||
|
||
result = qcec.verify(qc, qc_mapped) | ||
assert result.considered_equivalent() is True | ||
|
||
|
||
def test_heuristic_non_trivial_swaps(): | ||
"""Verify that the heuristic mapper works on a simple circuit that requires at least a single SWAP.""" | ||
qc = QuantumCircuit(3) | ||
qc.h(0) | ||
qc.cx(0, 1) | ||
qc.cx(1, 2) | ||
qc.cx(2, 0) | ||
qc.measure_all() | ||
|
||
qc_mapped, results = qmap.compile(qc, arch=FakeLondon()) | ||
|
||
assert results.timeout is False | ||
assert results.mapped_circuit != "" | ||
assert results.output.swaps == 1 | ||
|
||
print('\n') | ||
print(qc_mapped) | ||
|
||
config = qcec.Configuration() | ||
config.execution.run_alternating_checker = False | ||
result = qcec.verify(qc, qc_mapped, config=config) | ||
print(result) | ||
|
||
assert result.considered_equivalent() is True |
Oops, something went wrong.