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
11 changes: 3 additions & 8 deletions qiskit_ibm_runtime/options/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ class Options:
_MAX_OPTIMIZATION_LEVEL = 3
_MAX_RESILIENCE_LEVEL_ESTIMATOR = 3
_MAX_RESILIENCE_LEVEL_SAMPLER = 1
_MIN_EXECUTION_TIME = 300
_MAX_EXECUTION_TIME = 8 * 60 * 60 # 8 hours for real device

optimization_level: Optional[int] = None
Expand Down Expand Up @@ -168,14 +167,10 @@ def validate_options(options: dict) -> None:
ResilienceOptions.validate_resilience_options(options.get("resilience"))
TranspilationOptions.validate_transpilation_options(options.get("transpilation"))
execution_time = options.get("max_execution_time")
if not execution_time is None:
if (
execution_time < Options._MIN_EXECUTION_TIME
or execution_time > Options._MAX_EXECUTION_TIME
):
if execution_time is not None:
if execution_time > Options._MAX_EXECUTION_TIME:
raise ValueError(
f"max_execution_time must be between "
f"{Options._MIN_EXECUTION_TIME} and {Options._MAX_EXECUTION_TIME} seconds."
f"max_execution_time must be below " f"{Options._MAX_EXECUTION_TIME} seconds."
)

EnvironmentOptions.validate_environment_options(options.get("environment"))
Expand Down
10 changes: 3 additions & 7 deletions qiskit_ibm_runtime/utils/qctrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,10 @@ def validate(options: Dict[str, Any]) -> None:
# Default validation otherwise.
TranspilationOptions.validate_transpilation_options(options.get("transpilation"))
execution_time = options.get("max_execution_time")
if not execution_time is None:
if (
execution_time < Options._MIN_EXECUTION_TIME
or execution_time > Options._MAX_EXECUTION_TIME
):
if execution_time is not None:
if execution_time > Options._MAX_EXECUTION_TIME:
raise ValueError(
f"max_execution_time must be between "
f"{Options._MIN_EXECUTION_TIME} and {Options._MAX_EXECUTION_TIME} seconds."
f"max_execution_time must be below " f"{Options._MAX_EXECUTION_TIME} seconds."
)

EnvironmentOptions.validate_environment_options(options.get("environment"))
Expand Down
6 changes: 0 additions & 6 deletions test/integration/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,6 @@ def test_run_program_override_max_execution_time(self, service):
job.wait_for_final_state()
self.assertEqual(job._api_client.job_get(job.job_id())["cost"], job_max_execution_time)

@run_integration_test
def test_invalid_max_execution_time_fails(self, service):
"""Test that program fails when max_execution_time is less than 300."""
with self.assertRaises(ValueError):
self._run_program(service, max_execution_time=299)

@run_integration_test
@production_only
def test_cancel_job_queued(self, service):
Expand Down
3 changes: 1 addition & 2 deletions test/unit/test_ibm_primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,6 @@ def test_transpilation_options(self):
def test_max_execution_time_options(self):
"""Test transpilation options."""
options_dicts = [
{"max_execution_time": Options._MIN_EXECUTION_TIME - 1},
{"max_execution_time": Options._MAX_EXECUTION_TIME + 1},
]
session = MagicMock(spec=MockSession)
Expand All @@ -708,7 +707,7 @@ def test_max_execution_time_options(self):
inst = cls(session=session, options=opts_dict)
inst.run(self.qx, observables=self.obs)
self.assertIn(
"max_execution_time must be between 300 and 28800 seconds",
"max_execution_time must be below 28800 seconds",
str(exc.exception),
)

Expand Down