Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Phase operations when compiling for backends #565

Merged
merged 4 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
## Unreleased

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

## 0.42.0 (December 2024)

Expand Down
2 changes: 2 additions & 0 deletions pytket/extensions/quantinuum/backends/quantinuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
GreedyPauliSimp,
NormaliseTK2,
RemoveBarriers,
RemovePhaseOps,
RemoveRedundancies,
SequencePass,
SimplifyInitial,
Expand Down Expand Up @@ -785,6 +786,7 @@ def default_compilation_pass(
RemoveRedundancies(),
]
)
passlist.append(RemovePhaseOps())

# In TKET, a qubit register with N qubits can have qubits
# indexed with a a value greater than N, i.e. a single
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
packages=find_namespace_packages(include=["pytket.*"]),
include_package_data=True,
install_requires=[
"pytket >= 1.37.0",
"pytket >= 1.39.0",
"pytket-qir >= 0.17, < 0.18",
"requests >= 2.32.2",
"types-requests",
Expand Down
26 changes: 26 additions & 0 deletions tests/integration/backend_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from pytket.circuit import (
Bit,
Circuit,
Conditional,
Node,
OpType,
Qubit,
Expand Down Expand Up @@ -1563,3 +1564,28 @@ def test_optimisation_level_3_compilation(
assert compiled_3.n_2qb_gates() == 31
assert compiled_3.n_gates == 93
assert compiled_3.depth() == 49


@pytest.mark.parametrize(
"authenticated_quum_backend_qa", [{"device_name": "H2-1E"}], indirect=True
)
def test_no_phase_ops(authenticated_quum_backend_qa: QuantinuumBackend) -> None:
b = authenticated_quum_backend_qa

c = (
Circuit(3, 3)
.H(0)
.Measure(0, 0)
.H(1)
.CX(1, 2, condition_bits=[0], condition_value=1)
.Measure(1, 1)
.Measure(2, 2)
)
c1 = b.get_compiled_circuit(c)
for cmd in c1.get_commands():
op = cmd.op
typ = op.type
assert typ != OpType.Phase
if typ == OpType.Conditional:
assert isinstance(op, Conditional)
assert op.op.type != OpType.Phase
Loading