Open Cryoris opened 1 year ago
Need a general Sparse matrix? If you need a diagonal matrix that includes the projection for example, then I agree.
The idea would be to support general sparse matrices, not just diagonal ones. As Hamiltonians coming from a quantum mechanical systems are more mostly sparse, that would be widely applicable 🙂 but projectors would of course also be included.
True, but most of them are linear sums of Paulis (So SparsePauliOp is enough). I think it may be difficult to get the measurement basis from the general sparse matrix. I am concerned that this would be a bottleneck in the calculation.
But even for a linear sum of Paulis the evaluation can be terribly slow, especially for VQE or gradient calculations (or Statevector.expectation_value I would expect). I could also do a quick benchmark to be sure 🙂
What would be the issue of getting the measurement basis? Note that this class would be designated for working with simulators, not with backends (of course it should be compatible, but it's not the main goal).
What should we add?
It would be great to support sparse matrices in the primitives and derived algorithms (like the gradients). Since they are built to take
quantum_info
objects as inputs, one option would be to add aSparseOperator
that acts like thequantum_info.Operator
, but is based on sparse matrices instead of dense operators.The
SparsePauliOp
does not satisfy this need, as (1) the conversion to a sparse matrix representation is still expensive and (2) computing expectation values based on the matrix representation can be more efficient than on each of the paulis individually.