Skip to content

Commit 1386582

Browse files
authored
Remove Phase operations when compiling for backends (#565)
1 parent 587acea commit 1386582

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

docs/changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
## Unreleased
88

99
- Check for language support when submitting programs.
10+
- Remove all `Phase` operations from circuit when compiling for backend.
1011

1112
## 0.42.0 (December 2024)
1213

pytket/extensions/quantinuum/backends/quantinuum.py

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
GreedyPauliSimp,
5757
NormaliseTK2,
5858
RemoveBarriers,
59+
RemovePhaseOps,
5960
RemoveRedundancies,
6061
SequencePass,
6162
SimplifyInitial,
@@ -785,6 +786,7 @@ def default_compilation_pass(
785786
RemoveRedundancies(),
786787
]
787788
)
789+
passlist.append(RemovePhaseOps())
788790

789791
# In TKET, a qubit register with N qubits can have qubits
790792
# indexed with a a value greater than N, i.e. a single

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
packages=find_namespace_packages(include=["pytket.*"]),
4646
include_package_data=True,
4747
install_requires=[
48-
"pytket >= 1.37.0",
48+
"pytket >= 1.39.0",
4949
"pytket-qir >= 0.17, < 0.18",
5050
"requests >= 2.32.2",
5151
"types-requests",

tests/integration/backend_test.py

+26
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
from pytket.circuit import (
3535
Bit,
3636
Circuit,
37+
Conditional,
3738
Node,
3839
OpType,
3940
Qubit,
@@ -1563,3 +1564,28 @@ def test_optimisation_level_3_compilation(
15631564
assert compiled_3.n_2qb_gates() == 31
15641565
assert compiled_3.n_gates == 93
15651566
assert compiled_3.depth() == 49
1567+
1568+
1569+
@pytest.mark.parametrize(
1570+
"authenticated_quum_backend_qa", [{"device_name": "H2-1E"}], indirect=True
1571+
)
1572+
def test_no_phase_ops(authenticated_quum_backend_qa: QuantinuumBackend) -> None:
1573+
b = authenticated_quum_backend_qa
1574+
1575+
c = (
1576+
Circuit(3, 3)
1577+
.H(0)
1578+
.Measure(0, 0)
1579+
.H(1)
1580+
.CX(1, 2, condition_bits=[0], condition_value=1)
1581+
.Measure(1, 1)
1582+
.Measure(2, 2)
1583+
)
1584+
c1 = b.get_compiled_circuit(c)
1585+
for cmd in c1.get_commands():
1586+
op = cmd.op
1587+
typ = op.type
1588+
assert typ != OpType.Phase
1589+
if typ == OpType.Conditional:
1590+
assert isinstance(op, Conditional)
1591+
assert op.op.type != OpType.Phase

0 commit comments

Comments
 (0)