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]]