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
For non-parametric operations, we use tensordot/einsum to apply the operator. However, it could be more computationally efficient to simply mutate the existing state tensor
An example (which was what we initially did in the prototype above) is the X gate: it should target all the state amplitudes where the target qubit is 0 and exchange their place with the ones where it is 1. Other rules for each gate have to be implemented.
The implementation should essentially amount to overriding the forward method of each gate in pyqtorch.primitives.primitive_gates and pyqtorch.primitives.parametric_gates (well, the ones for which a rule can be added).
Testing it should be easy: just comparing the result to the normal usage of the apply_operator. The function calc_mat_vec_wavefunction in tests.helpers would be useful. It is used extensively in the test_tensor.py.
Overall, this could be interesting to explore, but it is not clear if we can make it efficient in torch (Spinoza does it in Rust). It should only be implemented if there is some clear performance gain over the normal apply_operator.
The text was updated successfully, but these errors were encountered:
dominikandreasseitz
changed the title
[Feature] Mutate state
[Performance] Mutate state instead of using einsum for non-parametric operations
May 29, 2024
For non-parametric operations, we use tensordot/einsum to apply the operator. However, it could be more computationally efficient to simply mutate the existing state tensor
Prototype in: #125
Edit by @jpmoutinho :
The ideas behind this are described in https://arxiv.org/pdf/2303.01493
An example (which was what we initially did in the prototype above) is the
X
gate: it should target all the state amplitudes where the target qubit is 0 and exchange their place with the ones where it is 1. Other rules for each gate have to be implemented.The implementation should essentially amount to overriding the
forward
method of each gate inpyqtorch.primitives.primitive_gates
andpyqtorch.primitives.parametric_gates
(well, the ones for which a rule can be added).Testing it should be easy: just comparing the result to the normal usage of the
apply_operator
. The functioncalc_mat_vec_wavefunction
intests.helpers
would be useful. It is used extensively in thetest_tensor.py
.Overall, this could be interesting to explore, but it is not clear if we can make it efficient in torch (Spinoza does it in Rust). It should only be implemented if there is some clear performance gain over the normal
apply_operator
.The text was updated successfully, but these errors were encountered: