From 0ec33ed53523e2226c235d713b7c15b11b18d02d Mon Sep 17 00:00:00 2001 From: Takashi Imamichi Date: Tue, 10 Oct 2023 22:45:25 +0900 Subject: [PATCH 1/2] change cvxpy solver --- qiskit/quantum_info/operators/measures.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiskit/quantum_info/operators/measures.py b/qiskit/quantum_info/operators/measures.py index 09d22e3a6efc..3f7a6fd0d756 100644 --- a/qiskit/quantum_info/operators/measures.py +++ b/qiskit/quantum_info/operators/measures.py @@ -344,7 +344,7 @@ def cvx_bmat(mat_r, mat_i): # Objective function obj = cvxpy.Maximize(cvxpy.trace(choi_rt_r @ x_r) + cvxpy.trace(choi_rt_i @ x_i)) prob = cvxpy.Problem(obj, cons) - sol = prob.solve(**kwargs) + sol = prob.solve(solver="SCS", **kwargs) return sol From 3d4cf381f4f559ef301f7125ceff999c63c6f4a7 Mon Sep 17 00:00:00 2001 From: Takashi Imamichi Date: Tue, 10 Oct 2023 23:01:19 +0900 Subject: [PATCH 2/2] apply review comments --- constraints.txt | 6 ------ qiskit/quantum_info/operators/measures.py | 5 +++-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/constraints.txt b/constraints.txt index 02ae6694d06d..455610b304cf 100644 --- a/constraints.txt +++ b/constraints.txt @@ -11,9 +11,3 @@ numpy<1.25 # eigensystem code for one of the test cases. See # https://github.com/Qiskit/qiskit-terra/issues/10345 for current details. scipy<1.11 - -# cvxpy 1.4.0 caused an instability in some diamond-norm tests. That's -# likely to be an unreliable measure already given its nature, so this -# pin may be relaxed by modifying the tests slightly to choose known-safe -# operators. -cvxpy==1.3.2 diff --git a/qiskit/quantum_info/operators/measures.py b/qiskit/quantum_info/operators/measures.py index 3f7a6fd0d756..6cb0ea97edde 100644 --- a/qiskit/quantum_info/operators/measures.py +++ b/qiskit/quantum_info/operators/measures.py @@ -250,7 +250,7 @@ def gate_error( ) -def diamond_norm(choi: Choi | QuantumChannel, **kwargs) -> float: +def diamond_norm(choi: Choi | QuantumChannel, solver: str = "SCS", **kwargs) -> float: r"""Return the diamond norm of the input quantum channel object. This function computes the completely-bounded trace-norm (often @@ -260,6 +260,7 @@ def diamond_norm(choi: Choi | QuantumChannel, **kwargs) -> float: Args: choi(Choi or QuantumChannel): a quantum channel object or Choi-matrix array. + solver (str): The solver to use. kwargs: optional arguments to pass to CVXPY solver. Returns: @@ -344,7 +345,7 @@ def cvx_bmat(mat_r, mat_i): # Objective function obj = cvxpy.Maximize(cvxpy.trace(choi_rt_r @ x_r) + cvxpy.trace(choi_rt_i @ x_i)) prob = cvxpy.Problem(obj, cons) - sol = prob.solve(solver="SCS", **kwargs) + sol = prob.solve(solver=solver, **kwargs) return sol