Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Performance] Mutate state instead of using einsum for non-parametric operations #165

Open
RolandMacDoland opened this issue Apr 26, 2024 · 0 comments
Labels
feature New feature or request

Comments

@RolandMacDoland
Copy link
Collaborator

RolandMacDoland commented Apr 26, 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 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.

@RolandMacDoland RolandMacDoland added the feature New feature or request label Apr 26, 2024
@dominikandreasseitz dominikandreasseitz changed the title [Feature] Mutate state [Performance] Mutate state instead of using einsum for non-parametric operations May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants