generated from CQCL/pytemplate
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
90565f1
commit 7dc92df
Showing
5 changed files
with
43 additions
and
0 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 |
---|---|---|
|
@@ -37,5 +37,6 @@ repos: | |
additional_dependencies: [ | ||
pytest, | ||
pytket==1.20.1, | ||
pytket-quantinuum==0.23.0, | ||
types-setuptools, | ||
] |
Empty file.
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,18 @@ | ||
from pytket.circuit import Circuit | ||
from pytket.extensions.quantinuum.backends.api_wrappers import QuantinuumAPIOffline | ||
from pytket.extensions.quantinuum.backends.quantinuum import ( | ||
QuantinuumBackend, | ||
) | ||
|
||
|
||
def rebase_to_qtm_machine(circuit: Circuit, qtm_machine: str) -> Circuit: | ||
"""Rebases a circuit's gate to the gate set appropriate for the given machine.""" | ||
qapi_offline = QuantinuumAPIOffline() | ||
backend = QuantinuumBackend( | ||
device_name=qtm_machine, | ||
machine_debug=False, | ||
api_handler=qapi_offline, # type: ignore [arg-type] | ||
) | ||
# Optimization level 0 includes rebasing and little else | ||
# see: https://cqcl.github.io/pytket-quantinuum/api/#default-compilation | ||
return backend.get_compiled_circuit(circuit, 0) |
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 |
---|---|---|
|
@@ -5,4 +5,5 @@ pre-commit==3.4.0 | |
pytest==7.4.2 | ||
ruff==0.0.292 | ||
pytket==1.20.1 | ||
pytket-quantinuum==0.23.0 | ||
wheel==0.41.2 |
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,23 @@ | ||
from pytket.circuit import Circuit, OpType | ||
from pytket.phir.rebasing.rebaser import rebase_to_qtm_machine | ||
|
||
from .sample_data import QasmFiles, get_qasm_as_circuit | ||
|
||
EXPECTED_GATES = [ | ||
OpType.Measure, | ||
OpType.Rz, | ||
OpType.PhasedX, | ||
OpType.ZZPhase, | ||
] | ||
|
||
|
||
class TestRebaser: | ||
def test_rebaser_happy_path_arc1a(self) -> None: | ||
circ = get_qasm_as_circuit(QasmFiles.baby) | ||
rebased: Circuit = rebase_to_qtm_machine(circ, "H1-1") | ||
|
||
print(rebased) | ||
for command in rebased.get_commands(): | ||
print(command) | ||
if command.op.is_gate(): | ||
assert command.op.type in EXPECTED_GATES |