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

[Frontend] Add support for the new PL arithmetic operators #250

Merged
merged 18 commits into from
Aug 23, 2023

Conversation

maliasadi
Copy link
Member

@maliasadi maliasadi commented Aug 17, 2023

Context:
PennyLane is in the process of replacing Hamiltonian and Tensor observables with a set of general arithmetic operators. These consist of Prod, Sum and SProd. By default, using dunder methods (eg. +, -, @, *) to combine operators with scalars or other operators will create Hamiltonian’s and Tensor’s. However, these two classes will be replaced in coming releases of PennyLane. To enable the new arithmetic operators path, one can use those three classes directly or call enable_new_opmath.

This PR adds support for Prod, Sum and SProd in Catalyst by implementing converter methods that serialize these classes to Runtime known observable classes at tracing.

Benefits:

  • Support for qml.ops.op_math: Prod, Sum, Sprod.

[sc-41351]

@maliasadi maliasadi changed the title [Frontend] Add support for the PL new arithmetic operators [Frontend] Add support for the new PL arithmetic operators Aug 17, 2023
@codecov
Copy link

codecov bot commented Aug 17, 2023

Codecov Report

Merging #250 (8ce5458) into main (f4c1719) will increase coverage by 0.06%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #250      +/-   ##
==========================================
+ Coverage   99.26%   99.32%   +0.06%     
==========================================
  Files          38       38              
  Lines        6923     6972      +49     
  Branches      343      355      +12     
==========================================
+ Hits         6872     6925      +53     
+ Misses         28       26       -2     
+ Partials       23       21       -2     
Files Changed Coverage Δ
frontend/catalyst/jax_tape.py 99.05% <100.00%> (+2.14%) ⬆️
frontend/catalyst/jax_tracer.py 95.47% <100.00%> (+1.54%) ⬆️

Copy link
Collaborator

@dime10 dime10 left a comment

Choose a reason for hiding this comment

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

Nice, good start 💯

frontend/catalyst/jax_tape.py Outdated Show resolved Hide resolved
frontend/catalyst/jax_tracer.py Outdated Show resolved Hide resolved
@maliasadi maliasadi requested a review from dime10 August 23, 2023 16:50
Copy link
Collaborator

@dime10 dime10 left a comment

Choose a reason for hiding this comment

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

Thanks for the new op math support 🥳

frontend/catalyst/jax_tape.py Outdated Show resolved Hide resolved
frontend/catalyst/jax_tracer.py Outdated Show resolved Hide resolved
frontend/catalyst/jax_tracer.py Outdated Show resolved Hide resolved
frontend/test/pytest/test_measurements_results.py Outdated Show resolved Hide resolved
mlir/Enzyme Outdated Show resolved Hide resolved
Copy link
Collaborator

@dime10 dime10 left a comment

Choose a reason for hiding this comment

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

🥳

@maliasadi maliasadi merged commit 9aeef38 into main Aug 23, 2023
22 checks passed
@maliasadi maliasadi deleted the maa/pl-new-arith-ops-support branch August 23, 2023 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants