Description
Sometimes, it is useful to be able to analyze circuits in ways that aren't valid on a quantum computer, but might still be interesting for theory reasons. I came across this issue a little while ago when wanting to compute the overlap <psi_1 | psi_2>
of a state and had a hard time keeping memory limits under control with larger batch and state sizes using tfq.layers.State
. I ultimately ended up simulating the circuits one by one, and doing the inner products in tf manually. It worked, but it wasn't pretty.
Would people be interested in implementing things like:
Examples that can be done right now, but are tricky to get right without blowing up memory:
tfq.math.overlap # => analytically compute state overlap between the two circuits
tfq.math.amplitudes # => analytically compute requested state amplitudes (could use qsimh ?).
tfq.math.fideltiy # => analytically compute fidelity between two circuits.
Other interesting math functions might be worth having
tfq.math.operator_matrix # => ingest a cirq.PauliSum and compute the matrix
tfq.math.operator_commutators # => compute commutators on operator matrices
Does anyone else have any suggestions for useful math function ? @dabacon @zaqqwerty @jaeyoo @we-taper
Final thought: If we do end up making this .math
module , maybe we should move calculate_unitary
and calculate_state
inside of it.