- edited description
Sensible treatment of composite systems
QuTiP Qobj
instances have dims
attribute that keeps track of the structure of states and operators in composite systems, which is updated when one takes the tensor products of multiple Qobj
. For example:
In [11]: o = Qobj([[1, 2], [3, 4]])
In [12]: o.dims
Out[12]: [[2], [2]]
This shows that o
is a rank-2 tensor (an operator) in a 2-dimensional space.
In [13]: p = Qobj([[1, 2, 3, 4], [5, 6, 7, 8], [1, 2, 3, 4], [5, 6, 7, 8]])
In [14]: p.dims
Out[14]: [[4], [4]]
and p
is a rank-2 tensor in a 4-dimensional space.
In [15]: tensor(o, p).dims
Out[15]: [[2, 4], [2, 4]]
Finally this shows that tensor(o, p)
gives us again a rank-2 tensor that operates on a composite space--the product of a 2-dimensional space with 4-dimensional space. The total dimensions of the compound space that the operator works on is 2*4 = 8, so this is basically an 8x8 matrix, and if were defined directly as such it would have .dims
of [[8], [8]]
.
But it's really more useful that Qobj
s track the shapes of multipartite systems; in particular it enables operations like partial traces.
The current implementation of PyQC is lazy about this. For example a 3-qubit state is just given as a vector in an 8-dimensional space:
In [18]: Ket(0, 0, 0).qobj
Out[18]:
Quantum object: dims = [[8], [1]], shape = [8, 1], type = ket
(Don't be confused by the fact that its .dims
has two elements in it--it always does. But because one of the dimensions is only 1 this is actually viewed as a rank-1 tensor). There's nothing inherently wrong with treating a 3-qubit state space as an 8-dimensional space, in particular if we're only going to work with operators that act on all 3 qubits simultaneously. But it would be much better--in particular if we want to operate on individual qubits--to instead treat this as a product of 3 spaces, like:
In [18]: Ket(0, 0, 0).qobj
Out[18]:
Quantum object: dims = [[2, 2, 2], [1, 1, 1]], shape = [8, 1], type = ket
This clearly shows that we have a vector in an 8-dimensional product of 3 2-dimensional spaces. PyQC is currently not precise in how it treats this and simply reduces every state and operator to belonging to a single reduced space before operating between them. But this bookkeeping is useful and we should try instead to preserve it (in particular to preserve the partial traces).
Comments (5)
-
reporter -
reporter - edited description
-
reporter -
assigned issue to
-
assigned issue to
-
reporter -
reporter - changed status to resolved
- Log in to comment