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

Update QuantumScriptSerializer.serialize_observables to better handle new operator arithmetic #670

Merged
merged 41 commits into from
Apr 10, 2024

Conversation

mudit2812
Copy link
Contributor

Context:
This PR is implementing some technical debt that was left behind after #649 was merged.

Description of the Change:

  • Update order of operations when serializing operators. Pauli reps are now always prioritized unless we're serializing a Hamiltonian. While Hamiltonian now does have a pauli rep, it behaves lazily. I also assumed that there might be pipelines in lightning that take advantage of Hamiltonian.grouping_indices. If this is not a major concern, I can update to also use the pauli rep with Hamiltonian.
    • One issue I ran into is figuring out how to serialize Prod when the operands might have overlapping wires. In the case of Paulis, this is handled automatically by the pauli rep. However, in other cases, we end up in an infinite recursion as simplifying does not lead to any changes to the operands. If anyone has an idea about this, I would love to hear it. The current solutions I have in mind are to either raise an error, or fallback to treating the observable as a Hermitian (although the matrix might not actually be hermitian).
  • Unpinned cmake since there is now a release with the bug fix that was causing trouble (See here for context).

Benefits:
More optimized pipeline for serialization with new operator arithmetic.

Possible Drawbacks:

Related GitHub Issues:

.github/CHANGELOG.md Outdated Show resolved Hide resolved
Copy link

codecov bot commented Apr 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.70%. Comparing base (404bd2d) to head (8f770d9).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #670      +/-   ##
==========================================
+ Coverage   97.09%   98.70%   +1.60%     
==========================================
  Files         149      173      +24     
  Lines       19387    24399    +5012     
==========================================
+ Hits        18824    24082    +5258     
+ Misses        563      317     -246     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mudit2812
Copy link
Contributor Author

[sc-59698]

requirements-dev.txt Outdated Show resolved Hide resolved
Copy link
Member

@maliasadi maliasadi left a comment

Choose a reason for hiding this comment

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

Nice work @mudit2812!

pennylane_lightning/core/_serialize.py Outdated Show resolved Hide resolved
pennylane_lightning/core/_serialize.py Show resolved Hide resolved
pennylane_lightning/core/_serialize.py Outdated Show resolved Hide resolved
pennylane_lightning/core/_serialize.py Show resolved Hide resolved
pennylane_lightning/core/_serialize.py Outdated Show resolved Hide resolved
pennylane_lightning/core/_serialize.py Outdated Show resolved Hide resolved
pennylane_lightning/core/_serialize.py Show resolved Hide resolved
pennylane_lightning/core/_serialize.py Outdated Show resolved Hide resolved
pennylane_lightning/core/_serialize.py Outdated Show resolved Hide resolved
.github/CHANGELOG.md Show resolved Hide resolved
pennylane_lightning/core/_serialize.py Outdated Show resolved Hide resolved
tests/test_serialize.py Outdated Show resolved Hide resolved
@mudit2812
Copy link
Contributor Author

I'm not sure what's going on with the codecov warnings. I added tests specifically targeting the "uncovered" lines and I know that those lines are being covered locally. My guess is that the warnings are artifacts of the continuously updated coverage that happens due to the way that coverage data is uploaded to codecov.

The checks window also says that 100% patch coverage has been achieved.

@vincentmr
Copy link
Contributor

I'm not sure what's going on with the codecov warnings. I added tests specifically targeting the "uncovered" lines and I know that those lines are being covered locally. My guess is that the warnings are artifacts of the continuously updated coverage that happens due to the way that coverage data is uploaded to codecov.

The checks window also says that 100% patch coverage has been achieved.

I have encountered that in the past. I would say feel free to ignore it.

@mudit2812 mudit2812 requested review from maliasadi and vincentmr and removed request for vincentmr April 9, 2024 14:53
Copy link
Contributor

@vincentmr vincentmr left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks @mudit2812 !

Copy link
Contributor

@AmintorDusko AmintorDusko left a comment

Choose a reason for hiding this comment

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

Nice work, @mudit2812 !

Copy link
Member

@maliasadi maliasadi left a comment

Choose a reason for hiding this comment

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

🪂

@mudit2812 mudit2812 merged commit c6a8260 into master Apr 10, 2024
83 checks passed
@mudit2812 mudit2812 deleted the op-math-serialize branch April 10, 2024 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:build_wheels Activate wheel building.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants