Skip to content

Commit

Permalink
Fix default cvxpy solver (#1283)
Browse files Browse the repository at this point in the history
### Summary

Similar to Qiskit/qiskit#11002, this PR fixes
the default solver for cvxpy to SCS. The 1.4.0 release changing the
default solver to Clarabel breaks tomography experiments because
Clarabel expects `max_iter` instead of `max_iters`. Also fixes a new
lint error in `test_drag.py`.
  • Loading branch information
coruscating authored Oct 11, 2023
1 parent f32e985 commit 94a34fa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions qiskit_experiments/library/tomography/fitters/cvxpy_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ def decorated_func(*args, **kwargs):
return decorated_func


def solve_iteratively(problem: Problem, initial_iters: int, scale: int = 2, **solve_kwargs) -> None:
def solve_iteratively(
problem: Problem, initial_iters: int, scale: int = 2, solver: str = "SCS", **solve_kwargs
) -> None:
"""Solve a CVXPY problem increasing iterations if solution is inaccurate.
If the problem is not solved with the ``initial_iters`` value of
Expand All @@ -79,6 +81,7 @@ def solve_iteratively(problem: Problem, initial_iters: int, scale: int = 2, **so
when solving the problem
scale: Scale factor for increasing the initial_iters up to
max_iters at each step (Default: 2).
solver: The solver to use. Defaults to the Splitting Conic Solver.
solve_kwargs: kwargs for problem.solve method.
Raises:
Expand All @@ -90,7 +93,7 @@ def solve_iteratively(problem: Problem, initial_iters: int, scale: int = 2, **so
problem_solved = False
while not problem_solved:
solve_kwargs["max_iters"] = current_max_iters
problem.solve(**solve_kwargs)
problem.solve(solver=solver, **solve_kwargs)
if problem.status in ["optimal_inaccurate", "optimal"]:
problem_solved = True
elif problem.status == "unbounded_inaccurate":
Expand Down
1 change: 1 addition & 0 deletions test/library/calibration/test_drag.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def test_end_to_end(self, freq, betas, p0_opt):
self.assertExperimentDone(expdata)
result = expdata.analysis_results(1)

# pylint: disable=no-member
self.assertTrue(abs(result.value.n - backend.experiment_helper.ideal_beta) < self.test_tol)
self.assertEqual(result.quality, "good")
self.assertEqual(expdata.metadata["meas_level"], MeasLevel.CLASSIFIED)
Expand Down

0 comments on commit 94a34fa

Please sign in to comment.