2
$\begingroup$

I want to convert a Choi matrix into a corresponding set of Kraus operators.

I start out from a numpy array representing the Choi matrix. I convert it to a QuTip Qobj object and then convert it to Kraus representation. The code runs, however the output is just the input matrix.

The problem likely is related to this question, where they observed same behavior and the solution was to add type='super' to the instantiation of the Qobj.

This no longer seems to be the solution in QuTip 5.2.1. Qobj(matrix, dims=[[2, 2], [2, 2]], type='super') will give an 'unexpected keyword argument' error. Also, to_choi \ to_super will already do the conversion, so that the object handed to to_kraus is a super operator.

How can I get the Kraus operators corresponding to the Choi matrix in QuTip 5.2.1?

Example code:

# independent minimal example for channel being simple H gate on one qubit
import numpy as np
from qutip import Qobj, superop_reps

matrix = np.array([[1, 1, 1, -1], [1,1,1,1], [1,1,1,-1], [-1,1,-1,1]])
print(f'dimension of numpy array: {np.shape(matrix)}')

choi_qobj = Qobj(matrix, dims=[[2, 2], [2, 2]])#, type='super')
#choi_super = superop_reps.to_super(choi_qobj) 
choi_super = superop_reps.to_choi(choi_qobj)
print(f'dimension of qutip choi matrix: {choi_super.dims}, its type {choi_super.type}, {choi_super.superrep}')
kraus_operators = superop_reps.to_kraus(choi_super)


for i, K in enumerate(kraus_operators):
    print(f'Kraus operator {i}: dimensions {K.dims}, {K}')

Output:

dimension of numpy array: (4, 4)
dimension of qutip choi matrix: [[[2, 2], [2, 2]], [[2, 2], [2, 2]]], its type super, choi
Kraus operator 0: dimensions [[2, 2], [2, 2]], Quantum object: dims=[[2, 2], [2, 2]], shape=(4, 4), type='oper', dtype=Dense, isherm=True
Qobj data =
[[-1. -1. -1.  1.]
 [-1. -1. -1. -1.]
 [-1. -1. -1.  1.]
 [ 1. -1.  1. -1.]]

Edit:

Thanks to the answer by Bram I learned that my definition of the dimensions is wrong. It should not be dims=[[2, 2], [2, 2]] but dims=[[[2], [2]], [[2], [2]]]. With that I obtain Kraus operators of the right dimensionality.

However, the result still seems wrong. If I take the obtained list of Kraus operators and convert them back to Choi by choi = superop_reps.kraus_to_choi(kraus_operators) this does not reproduce the original input matrix. While the Kraus operator representation is not unique, the Choi representation is, isn't it? Can this be solely due to roundings and the fitting happening in the conversion or do i do something wrong?

Original Matrix: [[1, 1, 1, -1], [1,1,1,1], [1,1,1,-1], [-1,1,-1,1]]

Matrix obtained by converting to Kraus and back: [[ 1.00000001e+00 -1.38448541e-08 -1.38448544e-08 1.00000001e+00] [-1.38448541e-08 1.00000001e+00 -9.99999986e-01 -1.38448541e-08] [-1.38448544e-08 -9.99999986e-01 1.00000001e+00 -1.38448543e-08] [ 1.00000001e+00 -1.38448541e-08 -1.38448543e-08 1.00000001e+00]]

~ [[1, 0, 0, 1], [0,1,-1,0], [0,-1,1,0], [1,0,0,1]]

$\endgroup$

2 Answers 2

1
$\begingroup$

There were two issues with the initial code:

  1. As I found thanks to @Bram s answer, my definition of the dimensions was wrong.

  2. After using to_super, it is assumed that the object is a superoperator. When calling to_kraus() it first converts the superoperator to a choi object, then calls _choi_to_kraus(). The convertion goes along with a reshuffeling of the elemnts of the matrix and should not be done, since the matrix already represents a Choi matrix. Same conversion happens when calling to_choi() instead of to_super(). So, the solution to avoid this conversion is to use to_super() instead of to_choi(), and then calling _choi_to_kraus() directly.

$\endgroup$
0
$\begingroup$

You’re hitting this because your installed QuTiP version no longer accepts the type keyword in Qobj. Superoperator-ness is inferred from dims, and the representation is specified with superrep.

Fix it by using superrep and pick the correct representation for your 4×4 matrix. f your 4×4 is already a Choi matrix: Code:

C = Qobj(matrix, dims=[[2, 2], [2, 2]], superrep='choi')

S = superop_reps.to_super(C)

# independent minimal example for channel being simple H gate on one qubit
import numpy as np
from qutip import Qobj, superop_reps

matrix = np.array([[1, 1, 1, -1], [1,1,1,1], [1,1,1,-1], [-1,1,-1,1]])
print(f'dimension of numpy array: {np.shape(matrix)}')

choi_qobj = Qobj(matrix, dims=[[[2], [2]], [[2], [2]]], superrep='choi')
choi_super = superop_reps.to_super(choi_qobj)
w = np.linalg.eigvalsh(C.full()); print(w.min())
print(f'dimension of qutip choi matrix: {choi_super.dims}, its type {choi_super.type}, {choi_super.superrep}')
kraus_operators = superop_reps.to_kraus(choi_super)


for i, K in enumerate(kraus_operators):
    print(f'Kraus operator {i}: dimensions {K.dims}, {K}')

output

dimension of numpy array: (4, 4)
dimension of qutip choi matrix: [[[2], [2]], [[2], [2]]], its type super, super
Kraus operator 0: dimensions [[2], [2]], Quantum object: dims=[[2], [2]], shape=(2, 2), type='oper', dtype=Dense, isherm=False
Qobj data =
[[nan nan]
 [nan nan]]
Kraus operator 1: dimensions [[2], [2]], Quantum object: dims=[[2], [2]], shape=(2, 2), type='oper', dtype=Dense, isherm=False
Qobj data =
[[0.00000000e+00 1.57009246e-16]
 [1.00000000e+00 1.00000000e+00]]
Kraus operator 2: dimensions [[2], [2]], Quantum object: dims=[[2], [2]], shape=(2, 2), type='oper', dtype=Dense, isherm=False
Qobj data =
[[-1.08204454 -1.08204454]
 [-0.6687403   0.6687403 ]]

In the output we see probably NaNs because the Choi you constructed isn’t positive semidefinite (i.e., the map is not CP). QuTiP’s to_kraus diagonalizes the Choi and takes square roots of its eigenvalues; negatives cause the sqrt warning and NaNs.

$\endgroup$
2
  • $\begingroup$ just adding superrep='choi' to my code example gives error 'cannot set superrep for object that is not type super' $\endgroup$ Commented Sep 6 at 10:54
  • 1
    $\begingroup$ but your answer still provides the solution: My definition of the dimensions were wrong. I needed one more dimension to the array that states the dimensions. Thanks! $\endgroup$ Commented Sep 6 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.