Cost functions: Multiple wire measurements + backends for Hermitians

Hi mxn.wls,

  1. Yes, the runtime scales linearly. If you want to evaluate the same circuit, but with a different final measurement setting, the entire circuit is reevaluated. This is because PennyLane is hardware-based, and this is a constraint you have on real hardware. Saying this, we do realize that there are efficiency gains that could be had using simulators, e.g., caching the state right before measurement and re-using that.

  2. Not sure I follow here, unfortunately, but I’ll give a shot to answering. Say we want to estimate quantities (expectation values, gradients, etc.) with 1000 samples. How many circuit evaluations are needed for different goals?

  • Estimating an expectation value: 1000 circuit evaluations.
  • Estimating a different expectation value on the same wire whose measurement operator is linearly independent from other ones you have already measured: also 1000 evaluations.
  • Estimating a different expectation value on the same wire whose measurement operator is linearly dependent from other ones you have already measured: 0 evaluations
  • Estimating gradients with respect to a single parameter: 2000 evaluations
    There are tricks and shortcuts you can leverage when working with simulator, but these are not directly built into PennyLane
  1. The limitations are physical: Estimating one expectation value does not tell me anything about another expectation value which is linearly independent from it; also, using the “parameter-shift” gradient rule, which is compatible/scalable with hardware, requires evaluation of two expectation values (at shifted parameters)

Even with all the above, we are thinking about other ways we can make things more efficient if the user is not using physical hardware, and may implement these in the future.

2 Likes