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

Add support for error tracking with TrotterProduct template #5384

Merged
merged 34 commits into from
Mar 21, 2024

Conversation

Jaybsoni
Copy link
Contributor

@Jaybsoni Jaybsoni commented Mar 14, 2024

Context:
Adding support to compute the error for a given instance of qml.TrotterProduct. This is part of the push on error propagation in Pennylane

Description of the Change:
Using the paper "Theory of Trotter Error with Commutator Scaling" to implement upper-bounds on the additive error for the Suzuki Trotter Product formula.

  • Created an error module: pennylane/resources/error, moved the base error.py file into this repository (similar changes for the tests)
  • Created a trotter_error.py file in the error module which contains all of the helper functions along with the implementations for the _one_norm_error and _commutator_error functions.
  • Updated the abstract ErrorOperation to change the error() from a property to a method. (associated changes in tests)
  • Updated TrotterProduct to inherit from ErrorOperation and implemented the error() method.
  • Added integration tests for the new error method in the TrotterProduct class.

Using this error method, we can benchmark the error in approximating time evolution using the Suzuki-Trotter product formulas:

image

@Jaybsoni Jaybsoni added the WIP 🚧 Work-in-progress label Mar 14, 2024
Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

@Jaybsoni
Copy link
Contributor Author

[sc-55441]

Copy link

codecov bot commented Mar 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.65%. Comparing base (54d43b8) to head (eb7df25).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5384      +/-   ##
==========================================
+ Coverage   99.63%   99.65%   +0.01%     
==========================================
  Files         399      401       +2     
  Lines       37125    36944     -181     
==========================================
- Hits        36990    36815     -175     
+ Misses        135      129       -6     

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

@Jaybsoni Jaybsoni removed the WIP 🚧 Work-in-progress label Mar 19, 2024
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! I left some nitpick suggestions, but feel free to ignore if sensible.

pennylane/resource/error/__init__.py Outdated Show resolved Hide resolved
pennylane/resource/error/trotter_error.py Outdated Show resolved Hide resolved
pennylane/resource/error/trotter_error.py Outdated Show resolved Hide resolved
pennylane/resource/error/trotter_error.py Outdated Show resolved Hide resolved
pennylane/resource/error/trotter_error.py Outdated Show resolved Hide resolved
pennylane/resource/error/trotter_error.py Outdated Show resolved Hide resolved
pennylane/resource/error/trotter_error.py Outdated Show resolved Hide resolved
pennylane/resource/error/trotter_error.py Outdated Show resolved Hide resolved
pennylane/resource/error/trotter_error.py Outdated Show resolved Hide resolved
pennylane/templates/subroutines/trotter.py Outdated Show resolved Hide resolved
Copy link
Contributor

@DSGuala DSGuala 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. Left a few small comments. I'm confused about the scaling of the error by changes in order and number of steps.

pennylane/resource/error/error.py Outdated Show resolved Hide resolved
pennylane/templates/subroutines/trotter.py Show resolved Hide resolved
pennylane/templates/subroutines/trotter.py Outdated Show resolved Hide resolved
pennylane/templates/subroutines/trotter.py Show resolved Hide resolved
pennylane/templates/subroutines/trotter.py Outdated Show resolved Hide resolved
Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>
Co-authored-by: Diego <67476785+DSGuala@users.noreply.github.com>
Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>
@Jaybsoni Jaybsoni requested a review from DSGuala March 20, 2024 18:24
Copy link
Contributor

@DSGuala DSGuala 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 👍

@Jaybsoni
Copy link
Contributor Author

It doesn't break TortterProduct, Its just not compatible with the error computation. I added a warning to make this clear to users.

Jaybsoni and others added 3 commits March 21, 2024 09:56
@Jaybsoni Jaybsoni requested a review from soranjh March 21, 2024 14:40
@Jaybsoni Jaybsoni enabled auto-merge (squash) March 21, 2024 14:57
@Jaybsoni Jaybsoni merged commit 3ee6b6f into master Mar 21, 2024
40 checks passed
@Jaybsoni Jaybsoni deleted the trotter_add_error branch March 21, 2024 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review-ready 👌 PRs which are ready for review by someone from the core team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants