You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #4585, the decomposition of TmpPauliRot, a helper object of SpecialUnitary, was changed in order to allow the new DefaultQubit device to differentiate SpecialUnitary.
The decomposition-based differentiation pipeline assumed that the device's decomposition step before execution would happen after the trainable parameters are determined and corresponding gradient transforms are called.
Unfortunately, this changes with the new device, so that now the zero-angle instances of TmpPauliRot are decomposed into zero-angle instances of PauliRot, which in turn make it into the execution pipeline.
This makes the simulator execute a lot of identity operations, with causes some overhead (benchmark to be provided)
This affects differentiation of SpecialUnitary only, and only when using a differentiation method that uses the decomposition, like param_shift (as happens when using shot-based simulation).
Implementation
I do not see a straight-forward solution at this point. Possible implementations rely on composability of gradient transforms envisioned for the mid-term future, or on a generalization of the generator property of operations.
Other ideas to implement the (non-backprop) differentiation of SpecialUnitary are very much welcome.
How important would you say this feature is?
2: Somewhat important. Needed this quarter.
Additional information
No response
The text was updated successfully, but these errors were encountered:
I looked at an example code on 4 qubits (for which SpecialUnitary has 255 parameters), code below.
For JAX, could it be that these identity operations we're concerned about are being compiled away within jax.grad? I'm not entirely sure, but the compile time/first run gets sped up (12.4s -> ~12s) by manually skipping these ops (in apply_operation) whereas the execution time did not really change (is at about 4.3s)
For torch, the execution is about 3.2% faster if we manually skip identity ops (64.34s->62.25s)
For TF,
For torch, the execution time is about the same if we manually skip identity ops (at ~5.1s)
Feature details
In #4585, the decomposition of
TmpPauliRot
, a helper object ofSpecialUnitary
, was changed in order to allow the newDefaultQubit
device to differentiateSpecialUnitary
.The decomposition-based differentiation pipeline assumed that the device's decomposition step before execution would happen after the trainable parameters are determined and corresponding gradient transforms are called.
Unfortunately, this changes with the new device, so that now the zero-angle instances of
TmpPauliRot
are decomposed into zero-angle instances ofPauliRot
, which in turn make it into the execution pipeline.This makes the simulator execute a lot of identity operations, with causes some overhead (benchmark to be provided)
This affects differentiation of
SpecialUnitary
only, and only when using a differentiation method that uses the decomposition, likeparam_shift
(as happens when using shot-based simulation).Implementation
I do not see a straight-forward solution at this point. Possible implementations rely on composability of gradient transforms envisioned for the mid-term future, or on a generalization of the
generator
property of operations.Other ideas to implement the (non-backprop) differentiation of
SpecialUnitary
are very much welcome.How important would you say this feature is?
2: Somewhat important. Needed this quarter.
Additional information
No response
The text was updated successfully, but these errors were encountered: