eclipse / xacc

XACC - eXtreme-scale Accelerator programming framework
https://xacc.readthedocs.io
BSD 3-Clause "New" or "Revised" License
163 stars 84 forks source link

Gradient executions in ParameterShiftGradient shifts multiple parameters at the same time #563

Open daanish-arya opened 1 year ago

daanish-arya commented 1 year ago

When obtaining (shifted) gradient executions using ParameterShiftGradient , any parameters set to the same value will all be shifted at once. That is, if multiple (uniquely named) parameters have the same numerical runtime value, the gradient executions will shift them all within consecutive circuits (+/-), then return a number of unaltered gradient execution circuits. For example, a circuit with parameters named theta_1, theta_2, theta_2 all being set to pi/4 will return a circuit with all of these rotations shifted to 3pi/4, another with the parameters shifted to -pi/4, and 4 circuits with no shifts present. This behaviour is not seen when the named parameters are set to unique values, either by manual assignment or through randomly sampling from a probability distribution, and the function performs as expected.