Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate optimization_level #1748

Merged
merged 4 commits into from
Jun 17, 2024
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
9 changes: 9 additions & 0 deletions qiskit_ibm_runtime/estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,15 @@ def _validate_options(self, options: dict) -> None:
"a coupling map is required."
)

if options.get("optimization_level", None):
issue_deprecation_msg(
msg="The 'optimization_level' option is deprecated",
version="0.25.0",
remedy="Instead, you can perform circuit optimization using Qiskit transpiler "
"or Qiskit transpiler service. "
"See https://docs.quantum.ibm.com/transpile for more information.",
)

@classmethod
def _program_id(cls) -> str:
"""Return the program ID."""
Expand Down
9 changes: 2 additions & 7 deletions qiskit_ibm_runtime/options/estimator_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,14 @@ class EstimatorOptions(OptionsV2):

Default: ``None``.

optimization_level: How much optimization to perform on the circuits.
optimization_level: (DEPRECATED) How much optimization to perform on the circuits.
Higher levels generate more optimized circuits,
at the expense of longer processing times.

* 0: no optimization
* 1: light optimization

Refer to the
`Configure runtime compilation for Qiskit Runtime
<https://docs.quantum.ibm.com/run/configure-runtime-compilation>`_.
for more information about the optimization levels.

Default: 1.
Default: 0.

resilience_level: How much resilience to build against errors.
Higher levels generate more accurate results,
Expand Down
2 changes: 2 additions & 0 deletions release-notes/unreleased/1748.deprecation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The ``optimization_level`` option in ``EstimatorV2`` is deprecated.
Instead, you can perform circuit optimization using the Qiskit transpiler or Qiskit transpiler service.
2 changes: 0 additions & 2 deletions test/integration/test_estimator_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def test_estimator_v2_options(self, service):
estimator.options.default_precision = 0.05
estimator.options.default_shots = 400
estimator.options.resilience_level = 1
estimator.options.optimization_level = 1
estimator.options.seed_estimator = 42
estimator.options.resilience.measure_mitigation = True
estimator.options.resilience.zne_mitigation = True
Expand Down Expand Up @@ -116,7 +115,6 @@ def test_pec(self, service):

estimator = EstimatorV2(backend=backend)
estimator.options.resilience_level = 0
estimator.options.optimization_level = 0
estimator.options.resilience.pec_mitigation = True
estimator.options.resilience.pec_max_overhead = 200
estimator.options.simulator.set_backend(FakeAuckland())
Expand Down
7 changes: 7 additions & 0 deletions test/unit/test_estimator_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,10 @@ def test_zero_resilience_level(self):
options = backend.service.run.call_args.kwargs["inputs"]
self.assertIn("resilience_level", options)
self.assertEqual(options["resilience_level"], 0)

def test_optimization_level_deprecation(self):
"""Test optimization level being deprecated."""
backend = get_mocked_backend()
estimator = Estimator(backend=backend, options={"optimization_level": 1})
with self.assertWarnsRegex(DeprecationWarning, r".*optimization_level.*"):
_ = estimator.run(**get_primitive_inputs(estimator))
2 changes: 1 addition & 1 deletion test/unit/test_local_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def test_v2_estimator_with_accepted_options(self, backend):
primitive=[SamplerV2, EstimatorV2], backend=[FakeManila(), FakeManilaV2(), AerSimulator()]
)
def test_primitive_v2_with_not_accepted_options(self, primitive, backend):
"""Test V1 primitive with accepted options."""
"""Test V2 primitive with not accepted options."""
options = {
"max_execution_time": 200,
"dynamical_decoupling": {"enable": True},
Expand Down