Skip to content
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
2 changes: 1 addition & 1 deletion .cz.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.commitizen]
name = "cz_customize"
tag_format = "v$version"
version = "7.7.0"
version = "7.7.1"
version_scheme = "semver"
version_files = [
"pyproject.toml:version",
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 7.7.1 (2026-04-23)


### Fixed

- Make max_batch_cost optional with default none, and a float.


## 7.7.0 (2026-04-17)


Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "quantinuum-schemas"
version = "7.7.0"
version = "7.7.1"
description = "Shared data models for Quantinuum."
authors = [
{name = "Matthew Burke", email = "matthew.burke@quantinuum.com"},
Expand Down
16 changes: 14 additions & 2 deletions quantinuum_schemas/models/backend_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ class Batchable(Protocol):

batch_id: UUID | None
attempt_batching: bool
max_batch_cost: float | None
targets_hardware_device: Callable[..., bool]


Expand Down Expand Up @@ -242,6 +243,17 @@ def warn_if_backend_doesnt_support_batching(self: BatchableT) -> BatchableT:
)
return self

@model_validator(mode="after")
def warn_if_max_batch_cost_is_unset(self: BatchableT) -> BatchableT:
"""Warns if attempt_batching is true and batch_max_hqc is unset"""

if self.attempt_batching and self.max_batch_cost is None:
warnings.warn(
"max_batch_cost is unset. Your organisation's value will be used instead.",
RuntimeWarning,
)
return self


class QuantinuumConfig(BaseBackendConfig, BatchingValidationMixin):
"""Runs circuits on Quantinuum's quantum devices and simulators.
Expand Down Expand Up @@ -287,7 +299,7 @@ class QuantinuumConfig(BaseBackendConfig, BatchingValidationMixin):
noisy_simulation: bool = True
target_2qb_gate: Optional[str] = None
user_group: Optional[str] = None
max_batch_cost: int = 2000
max_batch_cost: Optional[float] = None
compiler_options: Optional[QuantinuumCompilerOptions] = None
no_opt: bool = True
allow_2q_gate_rebase: bool = False
Expand Down Expand Up @@ -523,7 +535,7 @@ class HeliosConfig(BaseBackendConfig, BatchingValidationMixin):

attempt_batching: bool = False
batch_id: Optional[UUID] = None
max_batch_cost: float = 2000.0
max_batch_cost: Optional[float] = None

options: QuantinuumOptions | None = None

Expand Down
49 changes: 43 additions & 6 deletions tests/models/test_backend_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,23 +186,60 @@ def test_attempt_batching_against_simulators() -> None:
system_name="Helios-1E",
emulator_config=HeliosEmulatorConfig(),
attempt_batching=True,
max_batch_cost=2000.0,
)
HeliosConfig(
system_name="Helios-1SC", attempt_batching=True, max_batch_cost=2000.0
)
QuantinuumConfig(
device_name="H2-1E", attempt_batching=True, max_batch_cost=2000.0
)
QuantinuumConfig(
device_name="H1-Emulator", attempt_batching=True, max_batch_cost=2000.0
)
QuantinuumConfig(
device_name="H2-1SC", attempt_batching=True, max_batch_cost=2000.0
)
HeliosConfig(system_name="Helios-1SC", attempt_batching=True)
QuantinuumConfig(device_name="H2-1E", attempt_batching=True)
QuantinuumConfig(device_name="H1-Emulator", attempt_batching=True)
QuantinuumConfig(device_name="H2-1SC", attempt_batching=True)

assert len(record) == 5, record
assert all([error_string in str(i.message) for i in record]), record

with warnings.catch_warnings(record=True) as captured_warnings:
# test valid configs don't throw warning.
HeliosConfig(system_name="Helios-1", attempt_batching=True)
QuantinuumConfig(device_name="H2-2", attempt_batching=True)
HeliosConfig(
system_name="Helios-1", attempt_batching=True, max_batch_cost=2000.0
)
QuantinuumConfig(
device_name="H2-2", attempt_batching=True, max_batch_cost=2000.0
)
# if attempt batching is false, no warning is throw
HeliosConfig(system_name="Helios-1E", emulator_config=HeliosEmulatorConfig())
HeliosConfig(system_name="Helios-1SC")
QuantinuumConfig(device_name="H2-1E")
QuantinuumConfig(device_name="H1-Emulator")
QuantinuumConfig(device_name="H2-1SC")
assert not captured_warnings


def test_match_batch_cost_warns_if_needed() -> None:
"""Test warning if attempt_batching is True and max_batch_cost is unset."""
error_string = (
"max_batch_cost is unset. Your organisation's value will be used instead."
)
with pytest.warns(RuntimeWarning) as record:
# test warning if max_batch_cost is unset.
HeliosConfig(system_name="Helios-1", attempt_batching=True)
QuantinuumConfig(device_name="H2-2", attempt_batching=True)

assert len(record) == 2, record
assert all([error_string in str(i.message) for i in record]), record

with warnings.catch_warnings(record=True) as captured_warnings:
# test warning isn't thrown when max_batch_cost is set.
HeliosConfig(
system_name="Helios-1", attempt_batching=True, max_batch_cost=2000.0
)
QuantinuumConfig(
device_name="H2-2", attempt_batching=True, max_batch_cost=2000.0
)
assert not captured_warnings
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading