Sensible treatment of composite systems

Issue #3 resolved
E. Madison Bray repo owner created an issue

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 Qobjs 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)

  1. E. Madison Bray reporter

    Fixed in 4690fe5:88ba416. This was actually pretty easy once the BraKet objects were updated to use the correct 'dims'. I rather like that this bookkeeping is kept consistent now instead of just being ignored.

  2. Log in to comment