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

[Feature] Adding apply to SummedPauliOp #80

Merged
merged 19 commits into from
Nov 6, 2024
Merged

Conversation

jamesETsmith
Copy link
Contributor

@jamesETsmith jamesETsmith commented Oct 29, 2024

General

This PR add SummedPauilOp.apply for the operation: $\sum_k \sum_j h_{jk} \mathcal{P}_j \ket{\psi_t}$ and has some small performance tweaks for SummedPauliOp.apply_weighted.

Details

  • Implements SummedPauilOp.apply
  • Small bug fix for apply_weighted and expectation_value where the ExecutionPolicy wasn't being checked properly and it was always running serially

Update on SummedPauliOp.square

I've implemented the square function to create a SummedPauliOp from sparse utilities that's equivalent to (A_k)^2. We do not save the "map" t_aij like we'd want to if we call this function immediately, but introducing that capability in the future should be straightforward if we want to.

In terms of performance,

  • $\big( A_k \big)^2 \ket{\psi}$ is slower than $A_k \big( A_k \ket{\psi} \big)$ in all situations I looked at
  • $A_k$ --> dense --> $A_k^2$ is faster than $A_k$ --> $A_k^2$ --> dense for smaller numbers of qubits, but around 6-8 qubits, the latter becomes much faster

Remaining TODOs

  • Implement to_tensor
  • Implement optimized version to apply a SummedPauliOp squared to a set of states
  • Add C++ and Python docstrings for SummedPauliOp methods
  • C++ tests for new methods
  • Python tests for new methods

@jamesETsmith jamesETsmith added bug Something isn't working enhancement New feature or request labels Oct 29, 2024
@jamesETsmith jamesETsmith self-assigned this Oct 29, 2024
@jamesETsmith jamesETsmith marked this pull request as ready for review October 31, 2024 14:11
fast_pauli/cpp/include/__pauli_helpers.hpp Outdated Show resolved Hide resolved
fast_pauli/cpp/include/__summed_pauli_op.hpp Outdated Show resolved Hide resolved
fast_pauli/cpp/include/__summed_pauli_op.hpp Outdated Show resolved Hide resolved
fast_pauli/cpp/include/__summed_pauli_op.hpp Show resolved Hide resolved
fast_pauli/cpp/include/__summed_pauli_op.hpp Show resolved Hide resolved
fast_pauli/cpp/include/__summed_pauli_op.hpp Outdated Show resolved Hide resolved
fast_pauli/cpp/include/__summed_pauli_op.hpp Show resolved Hide resolved
Copy link
Collaborator

@stand-by stand-by left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍
Thank you James

@jamesETsmith jamesETsmith merged commit f9e94d0 into main Nov 6, 2024
10 checks passed
@jamesETsmith jamesETsmith deleted the feature/SPO_apply branch November 6, 2024 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants