tensorflow/quantum

Projective measurements layer?

zaqqwerty opened this issue · 2 comments

Given a tensor of PauliSums, one may want to repeatedly measure these operators. This would be a generalization of the Sample layer, which is implicitly performing this calculation for a tensor of single qubit Z pauli sums. Currently, only the Expectation layer ingests operators.

Yes this seems like a crucial addition for use on real hardware as well.

Would there be a Pauli term measurement batching algorithm as an option?

There are several algorithms for "batching" the measurement of possibly non-commuting Paulis (e.g. this and this) efficiently, though a vanilla implementation (no batching) would be a first step.

This seems like a reasonable addition. Although the reason we didn't work on this initially is because the shape of the tensor from an op like that would be very difficult to use. For the sample op we have [batch, n_samples, ragged_n_qubits] for an op like this it might wind up being: [batch, n_samples, n_ops, ragged_n_qubits]. Would you be interested in adding this functionality in ? Keep in mind we can achieve this same result using a tf loop with existing sample ops but the performance would not be as high as writing this op natively.