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

Nonsquare superoperators, spre, spost, and sprepost #2171

Open
akirakyle opened this issue Jun 2, 2023 · 0 comments
Open

Nonsquare superoperators, spre, spost, and sprepost #2171

akirakyle opened this issue Jun 2, 2023 · 0 comments

Comments

@akirakyle
Copy link

akirakyle commented Jun 2, 2023

qutip 4.7.1 and 5.0.0a1 both allow one to take spre (and spost) of nonsquare operators, but not in a sensible way, for example with qutip 4.7.1

In [1]: from qutip import *

In [2]: A = basis(3,0) * basis(2,0).dag()

In [3]: A
Out[3]: 
Quantum object: dims = [[3], [2]], shape = (3, 2), type = oper, isherm = False
Qobj data =
[[1. 0.]
 [0. 0.]
 [0. 0.]]

In [4]: spre(A)
Out[4]: 
Quantum object: dims = [[[3], [2]], [[3], [2]]], shape = (6, 4), type = super, isherm = False
Qobj data =
[[1. 0. 0. 0.]
 [0. 0. 0. 0.]
 [0. 0. 0. 0.]
 [0. 0. 1. 0.]
 [0. 0. 0. 0.]
 [0. 0. 0. 0.]]

In [5]: sprepost(A, A.dag())
Out[5]: 
Quantum object: dims = [[[3], [3]], [[2], [2]]], shape = (9, 4), type = super, isherm = False
Qobj data =
[[1. 0. 0. 0.]
 [0. 0. 0. 0.]
 [0. 0. 0. 0.]
 [0. 0. 0. 0.]
 [0. 0. 0. 0.]
 [0. 0. 0. 0.]
 [0. 0. 0. 0.]
 [0. 0. 0. 0.]
 [0. 0. 0. 0.]]

In [6]: sprepost(A, A.dag())*operator_to_vector(sigmax())
Out[6]: 
Quantum object: dims = [[[3], [3]], [1]], shape = (9, 1), type = operator-ket
Qobj data =
[[0.]
 [0.]
 [0.]
 [0.]
 [0.]
 [0.]
 [0.]
 [0.]
 [0.]]

In [7]: spre(A)*operator_to_vector(sigmax())
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In [7], line 1
----> 1 spre(A)*operator_to_vector(sigmax())

File /gnu/store/7yfab8d83bbkicklsf19cpwi53594gpl-profile/lib/python3.10/site-packages/qutip/qobj.py:555, in Qobj.__mul__(self, other)
    552         return out.tidyup() if settings.auto_tidyup else out
    554     else:
--> 555         raise TypeError("Incompatible Qobj shapes")
    557 elif isinstance(other, np.ndarray):
    558     if other.dtype == 'object':

TypeError: Incompatible Qobj shapes

while in qutip 5.0.0a1

In [3]: spre(A)
Out[3]: 
Quantum object: dims=[[[3], [2]], [[3], [2]]], shape=(9, 6), type='super', isherm=False
Qobj data =
[[1. 0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0. 0.]
 [0. 0. 1. 0. 0. 0.]
 [0. 0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 1. 0.]
 [0. 0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0. 0.]]

So at the very least the behavior of spre has changed for nonsquare operators. I haven't installed the master branch to see what the current behavior is there but if I'm reading this commit correctly, then it appears as though the master branch will just throw a ValueError("Can't create and identity like a non square matrix.").

From searching throw past issues, it looks like these are the relevant pull requests:

For sprepost for rectangular operators, it's clear that the expected behavior should correspond to a supoperator taking density matrices in an input hilbert space to one in a potentially different dimensional output hilbert space. However, I think that it's not completely clear what behavior one should expect of spre (and spost) for rectangular operators. One potentially sensible behavior would be to view spre and spost as special cases of sprepost where one uses the identity isometry between input and output hilbert spaces to form a superoperator which will act like sprepost(A, A.dag()). However, I don't think such superoperators will necessarily correspond to CPTP channels as they may not admit Kraus decompositions which obey the completeness relation (I haven't actually checked this, it's just my intuition). Since it appears somewhat doubtful that anyone is currently using spre or spost with nonsquare operators, my suggestion would actually be to raise a more helpful error that acknowledges there still may be use cases for such a situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant