Skip to content

Commit 0b01c67

Browse files
authored
Improve error message (#595)
1 parent 7209194 commit 0b01c67

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

docs/changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
# Changelog
66

7+
## Unreleased
8+
9+
- Update pytket-qir minimum version requirement to 0.24.1.
10+
711
## 0.48.0 (May 2025)
812

913
- Update pytket minimum version requirement to 2.4.1.

pytket/extensions/quantinuum/backends/quantinuum.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
)
7575
from pytket.qasm import circuit_to_qasm_str
7676
from pytket.qir import QIRFormat, QIRProfile, pytket_to_qir
77+
from pytket.qir.conversion.api import ClassicalRegisterWidthError
7778
from pytket.unit_id import _TEMP_BIT_NAME
7879
from pytket.utils import prepare_circuit
7980
from pytket.utils.outcomearray import OutcomeArray
@@ -1220,18 +1221,20 @@ def process_circuits( # noqa: PLR0912, PLR0915
12201221
profile = QIRProfile.PYTKET
12211222
else:
12221223
profile = QIRProfile.ADAPTIVE
1223-
1224-
quantinuum_circ = b64encode(
1225-
cast(
1226-
"bytes",
1227-
pytket_to_qir(
1228-
c0,
1229-
"circuit generated by pytket-qir",
1230-
QIRFormat.BINARY,
1231-
profile=profile,
1232-
),
1224+
try:
1225+
qir = pytket_to_qir(
1226+
c0,
1227+
"circuit generated by pytket-qir",
1228+
QIRFormat.BINARY,
1229+
profile=profile,
12331230
)
1234-
).decode("utf-8")
1231+
except ClassicalRegisterWidthError as e:
1232+
raise ValueError(
1233+
"Unable to convert pytket circuit to QIR as "
1234+
f"it contains a classical register of width {e.width}: "
1235+
f"maximum allowed width is {e.max_width}."
1236+
) from None
1237+
quantinuum_circ = b64encode(cast("bytes", qir)).decode("utf-8")
12351238

12361239
for name, count in Counter(
12371240
bit.reg_name for bit in c0.bits if not _is_scratch(bit)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
include_package_data=True,
4747
install_requires=[
4848
"pytket >= 2.4.1",
49-
"pytket-qir >= 0.23.0",
49+
"pytket-qir >= 0.24.1",
5050
"requests >= 2.32.2",
5151
"types-requests",
5252
"websockets >= 13.1",

0 commit comments

Comments
 (0)