From e581b46c5bcdab0e6a893bb6becef703ebaadbd7 Mon Sep 17 00:00:00 2001 From: Chester Wringe Date: Wed, 22 Apr 2026 16:55:10 +0100 Subject: [PATCH 1/3] fix: make max_batch_cost optional with default None, and a float. --- quantinuum_schemas/models/backend_config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quantinuum_schemas/models/backend_config.py b/quantinuum_schemas/models/backend_config.py index 618873c..6b207ca 100644 --- a/quantinuum_schemas/models/backend_config.py +++ b/quantinuum_schemas/models/backend_config.py @@ -287,7 +287,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 @@ -523,7 +523,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 From a7eea890a99e8dba5f1a809154efd283bbae9534 Mon Sep 17 00:00:00 2001 From: Chester Wringe Date: Wed, 22 Apr 2026 16:55:10 +0100 Subject: [PATCH 2/3] chore: warn if max_batch_cost is unset, to hopefully not break anyone's workflow post-submission --- quantinuum_schemas/models/backend_config.py | 12 +++++++++ tests/models/test_backend_config.py | 30 ++++++++++++++++----- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/quantinuum_schemas/models/backend_config.py b/quantinuum_schemas/models/backend_config.py index 6b207ca..25f6bb9 100644 --- a/quantinuum_schemas/models/backend_config.py +++ b/quantinuum_schemas/models/backend_config.py @@ -212,6 +212,7 @@ class Batchable(Protocol): batch_id: UUID | None attempt_batching: bool + max_batch_cost: float | None targets_hardware_device: Callable[..., bool] @@ -241,6 +242,17 @@ def warn_if_backend_doesnt_support_batching(self: BatchableT) -> BatchableT: RuntimeWarning, ) 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): diff --git a/tests/models/test_backend_config.py b/tests/models/test_backend_config.py index 70710ee..5404f56 100644 --- a/tests/models/test_backend_config.py +++ b/tests/models/test_backend_config.py @@ -186,19 +186,20 @@ 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) - QuantinuumConfig(device_name="H2-1E", attempt_batching=True) - QuantinuumConfig(device_name="H1-Emulator", attempt_batching=True) - QuantinuumConfig(device_name="H2-1SC", attempt_batching=True) + 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) 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") @@ -206,3 +207,20 @@ def test_attempt_batching_against_simulators() -> None: 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 \ No newline at end of file From 8d24a7127093bb1f8b886e228d3bbb797aa9b191 Mon Sep 17 00:00:00 2001 From: Chester Wringe Date: Thu, 23 Apr 2026 09:08:40 +0100 Subject: [PATCH 3/3] docs: Update CHANGELOG for v7.7.1 --- .cz.toml | 2 +- CHANGELOG.md | 8 ++++ pyproject.toml | 2 +- quantinuum_schemas/models/backend_config.py | 4 +- tests/models/test_backend_config.py | 41 +++++++++++++++------ uv.lock | 2 +- 6 files changed, 43 insertions(+), 16 deletions(-) diff --git a/.cz.toml b/.cz.toml index 0bcb6f8..3e85a17 100644 --- a/.cz.toml +++ b/.cz.toml @@ -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", diff --git a/CHANGELOG.md b/CHANGELOG.md index da60980..a86d5a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/pyproject.toml b/pyproject.toml index bbec869..161f202 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"}, diff --git a/quantinuum_schemas/models/backend_config.py b/quantinuum_schemas/models/backend_config.py index 25f6bb9..4d05225 100644 --- a/quantinuum_schemas/models/backend_config.py +++ b/quantinuum_schemas/models/backend_config.py @@ -242,7 +242,7 @@ def warn_if_backend_doesnt_support_batching(self: BatchableT) -> BatchableT: RuntimeWarning, ) 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""" @@ -250,7 +250,7 @@ def warn_if_max_batch_cost_is_unset(self: BatchableT) -> BatchableT: 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 + RuntimeWarning, ) return self diff --git a/tests/models/test_backend_config.py b/tests/models/test_backend_config.py index 5404f56..05b4002 100644 --- a/tests/models/test_backend_config.py +++ b/tests/models/test_backend_config.py @@ -186,20 +186,32 @@ def test_attempt_batching_against_simulators() -> None: system_name="Helios-1E", emulator_config=HeliosEmulatorConfig(), attempt_batching=True, - max_batch_cost=2000.0 + 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, 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) 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, max_batch_cost=2000.0) - QuantinuumConfig(device_name="H2-2", attempt_batching=True, max_batch_cost=2000.0) + 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") @@ -208,9 +220,12 @@ def test_attempt_batching_against_simulators() -> None: 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." + 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) @@ -221,6 +236,10 @@ def test_match_batch_cost_warns_if_needed() -> None: 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 \ No newline at end of file + 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 diff --git a/uv.lock b/uv.lock index e149865..a476558 100644 --- a/uv.lock +++ b/uv.lock @@ -833,7 +833,7 @@ wheels = [ [[package]] name = "quantinuum-schemas" -version = "7.7.0" +version = "7.7.1" source = { editable = "." } dependencies = [ { name = "orjson" },