Sparse storage of state attribute in device class

Hi all! First of all I want to congratulate the developers for such an amazing library.

I would like to ask on the possibility of creating devices for mixed states that are able to store a considerably large number of qubits (N=16 needs approx. 64Gb of memory). While devices of the type “default.qubit” do well, as they store the “state” attribute on a NumPy array of a single dimension, for mixed states the attribute “state” is stored into a (sparse) matrix of NxN complex entries, thus producing a memory blow-up. This happens at the level of initialization already.

Is there a way to improve this, for instance, by storing the “state” attributes as a sparse? Or is this already something that can be done and I am missing something (i.e. in the documentation)? Generally state preparation could have also highly entangled states, but for a default preparation of the device (like the product state |0><0| in the case of a default.mixed ) this could help on working with bigger system sizes.

Thanks a lot!

Hi @zrtstr, welcome to our community!

And thank you for your kind words :slight_smile:

Your request seems reasonable, but definitely not easy to implement.
Probably the main way to avoid the huge memory cost of mixed states is to use tensor networks/matrix product operator. A density matrix, unless extremely trivial or very low rank, will usually be quite dense.

We will think more about this problem. If you have any ideas please let us know!