Skip to content

Commit

Permalink
Merge pull request #112 from CQCL/release/1.13.0
Browse files Browse the repository at this point in the history
Release/1.13.0
  • Loading branch information
cqc-melf authored Mar 17, 2023
2 parents 8cb5206 + 3ef1382 commit 6ebcdc0
Showing 8 changed files with 45 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
sphinx ~= 4.3.2
sphinx_book_theme
sphinx_book_theme ~= 0.3.3
sphinx-copybutton
2 changes: 1 addition & 1 deletion _metadata.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__extension_version__ = "0.13.0"
__extension_version__ = "0.14.0"
__extension_name__ = "pytket-quantinuum"
7 changes: 7 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
~~~~~~~~~

0.14.0 (March 2023)
-------------------

* Use default ``Node`` register for flattening in default compilation pass.
* Prefer ``ZZPhase`` to ``ZZMax`` gates if available.
* Updated pytket version requirement to 1.13.

0.13.0 (January 2023)
---------------------

13 changes: 7 additions & 6 deletions pytket/extensions/quantinuum/backends/quantinuum.py
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@
from pytket.backends.backendinfo import BackendInfo
from pytket.backends.backendresult import BackendResult
from pytket.backends.backend_exceptions import CircuitNotRunError
from pytket.circuit import Circuit, OpType, Bit, Qubit # type: ignore
from pytket.circuit import Circuit, OpType, Bit, Node # type: ignore
from pytket._tket.circuit import _TEMP_BIT_NAME # type: ignore
from pytket.extensions.quantinuum._metadata import __extension_version__
from pytket.qasm import circuit_to_qasm_str
@@ -104,7 +104,7 @@ def _get_gateset(gates: List[str]) -> Set[OpType]:

def _flatten_registers(c: "Circuit") -> "Circuit":
c.remove_blank_wires()
c.rename_units({qb: Qubit("quantinuum", i) for i, qb in enumerate(c.qubits)})
c.rename_units({qb: Node(i) for i, qb in enumerate(c.qubits)})
return c


@@ -372,11 +372,12 @@ def default_compilation_pass(self, optimisation_level: int = 2) -> BasePass:

# use default (perfect fidelities) for supported gates
fidelities: Dict[str, Any] = {}
if OpType.ZZMax in self._gate_set:
fidelities["ZZMax_fidelity"] = 1.0
# If ZZPhase is available we should prefer it to ZZMax.
if OpType.ZZPhase in self._gate_set:
fidelities["ZZPhase_fidelity"] = lambda x: 1.0
if len(fidelities) == 0:
elif OpType.ZZMax in self._gate_set:
fidelities["ZZMax_fidelity"] = 1.0
else:
raise QuantinuumAPIError(
"Either ZZMax or ZZPhase gate must be supported by device"
)
@@ -429,7 +430,7 @@ def default_compilation_pass(self, optimisation_level: int = 2) -> BasePass:
# that the produced QASM has one "qreg", with the exact number
# of qubits actually used in the Circuit.
# The Circuit qubits attribute is iterated through, with the ith
# Qubit being assigned to the ith qubit of a new "quantinuum" register
# qubit being assigned to the ith qubit of a new "node" register
passlist.append(CustomPass(_flatten_registers))
return SequencePass(passlist)

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@
packages=find_namespace_packages(include=["pytket.*"]),
include_package_data=True,
install_requires=[
"pytket ~= 1.11",
"pytket ~= 1.13",
"requests >= 2.2",
"types-requests",
"websockets >= 7.0",
35 changes: 28 additions & 7 deletions tests/backend_test.py
Original file line number Diff line number Diff line change
@@ -35,6 +35,7 @@
Circuit,
Qubit,
Bit,
Node,
OpType,
reg_eq,
reg_neq,
@@ -230,12 +231,7 @@ def test_default_pass(
c.add_qubit(q1)
comp_pass.apply(c)
# 5 qubits added to Circuit, one is removed when flattening registers
assert c.qubits == [
Qubit("quantinuum", 0),
Qubit("quantinuum", 1),
Qubit("quantinuum", 2),
Qubit("quantinuum", 3),
]
assert c.qubits == [Node(0), Node(1), Node(2), Node(3)]
for pred in b.required_predicates:
assert pred.verify(c)

@@ -593,6 +589,31 @@ def test_zzphase_support_opti2(
assert c0.n_gates_of_type(OpType.ZZMax) == 1


@pytest.mark.skipif(skip_remote_tests, reason=REASON)
def test_prefer_zzphase(
authenticated_quum_backend: QuantinuumBackend,
) -> None:
# We should prefer small-angle ZZPhase to alternative ZZMax decompositions
backend = authenticated_quum_backend
c = (
Circuit(2)
.H(0)
.H(1)
.ZZPhase(0.1, 0, 1)
.Rx(0.2, 0)
.Ry(0.3, 1)
.ZZPhase(0.1, 0, 1)
.H(0)
.H(1)
.measure_all()
)
c0 = backend.get_compiled_circuit(c)
if OpType.ZZPhase in backend._gate_set:
assert c0.n_gates_of_type(OpType.ZZPhase) == 2
else:
assert c0.n_gates_of_type(OpType.ZZMax) == 2


@pytest.mark.skipif(skip_remote_tests, reason=REASON)
@pytest.mark.parametrize("device_name", ALL_DEVICE_NAMES)
def test_device_state(
@@ -635,7 +656,7 @@ def test_custom_api_handler(device_name: str) -> None:
def test_wasm(
authenticated_quum_backend: QuantinuumBackend,
) -> None:
wasfile = WasmFileHandler(str(Path(__file__).parent / "sample_wasm.wasm"))
wasfile = WasmFileHandler(str(Path(__file__).parent / "testfile.wasm"))
c = Circuit(1)
c.name = "test_wasm"
a = c.add_c_register("a", 8)
Binary file removed tests/sample_wasm.wasm
Binary file not shown.
Binary file added tests/testfile.wasm
Binary file not shown.

0 comments on commit 6ebcdc0

Please sign in to comment.