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

Implement eval_jaxpr method for lightning.qubit #1002

Merged
merged 30 commits into from
Dec 3, 2024
Merged

Conversation

albi3ro
Copy link
Contributor

@albi3ro albi3ro commented Nov 20, 2024

Context:

Now that we are decently good at capturing workflows into jaxpr, we want to start natively executing jaxpr.

We recently merged such a feature for DefaultQubit (PennyLaneAI/pennylane#6594), and now want to add it to lightning.qubit as well.

Description of the Change:

Implements LightningQubit.eval_jaxpr via a LightningInterpreter class.

Benefits:

Execution of captured jaxpr code.

Possible Drawbacks:

Related GitHub Issues:

[sc-72591]

Copy link

codecov bot commented Nov 21, 2024

Codecov Report

Attention: Patch coverage is 7.50000% with 74 lines in your changes missing coverage. Please review.

Project coverage is 91.80%. Comparing base (3cdd7e4) to head (360cf5e).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
pennylane_lightning/core/lightning_interpreter.py 0.00% 71 Missing ⚠️
pennylane_lightning/core/lightning_newAPI_base.py 62.50% 3 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (3cdd7e4) and HEAD (360cf5e). Click for more details.

HEAD has 12 uploads less than BASE
Flag BASE (3cdd7e4) HEAD (360cf5e)
20 8
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1002      +/-   ##
==========================================
- Coverage   97.13%   91.80%   -5.33%     
==========================================
  Files         228      105     -123     
  Lines       36786    16496   -20290     
==========================================
- Hits        35731    15144   -20587     
- Misses       1055     1352     +297     

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

@AmintorDusko AmintorDusko self-requested a review November 22, 2024 16:18
@albi3ro albi3ro requested a review from mudit2812 November 22, 2024 16:54
Copy link
Contributor

@mudit2812 mudit2812 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 @albi3ro . I left a couple of non-blocking comments. I didn't notice qnode present anywhere. Is that deliberate?

pennylane_lightning/core/_version.py Outdated Show resolved Hide resolved
tests/lightning_qubit/test_eval_jaxpr.py Outdated Show resolved Hide resolved
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.

Thank you, @albi3ro. We have some failing Cis and format problems. Could you please check this? I left some suggestions for that.

tests/lightning_qubit/test_eval_jaxpr.py Outdated Show resolved Hide resolved
tests/lightning_qubit/test_eval_jaxpr.py Outdated Show resolved Hide resolved
tests/lightning_qubit/test_eval_jaxpr.py Outdated Show resolved Hide resolved
tests/lightning_qubit/test_eval_jaxpr.py Outdated Show resolved Hide resolved
@albi3ro
Copy link
Contributor Author

albi3ro commented Nov 22, 2024

Looks good @albi3ro . I left a couple of non-blocking comments. I didn't notice qnode present anywhere. Is that deliberate?

I'm still working on the new execution flow, see PennyLaneAI/pennylane#6596 . So tests for eval_jaxpr shouldn't care about the larger infrastructure.

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 job! It looks like the failures we have now are essentially linting-related.

tests/lightning_qubit/test_eval_jaxpr.py Outdated Show resolved Hide resolved
tests/lightning_qubit/test_eval_jaxpr.py Outdated Show resolved Hide resolved
@albi3ro
Copy link
Contributor Author

albi3ro commented Nov 28, 2024

/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/coverage/control.py:892: CoverageWarning: No data was collected. (no-data-collected)
  self._warn("No data was collected.", slug="no-data-collected")
/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/coverage/control.py:892: CoverageWarning: No data was collected. (no-data-collected)
  self._warn("No data was collected.", slug="no-data-collected")
/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/coverage/control.py:892: CoverageWarning: No data was collected. (no-data-collected)
  self._warn("No data was collected.", slug="no-data-collected")
/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/coverage/control.py:892: CoverageWarning: No data was collected. (no-data-collected)
  self._warn("No data was collected.", slug="no-data-collected")

@AmintorDusko . Jax was installed, so the tests should have run. Ever seen these warnings before?

@AmintorDusko
Copy link
Contributor

AmintorDusko commented Nov 28, 2024

/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/coverage/control.py:892: CoverageWarning: No data was collected. (no-data-collected)
  self._warn("No data was collected.", slug="no-data-collected")
/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/coverage/control.py:892: CoverageWarning: No data was collected. (no-data-collected)
  self._warn("No data was collected.", slug="no-data-collected")
/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/coverage/control.py:892: CoverageWarning: No data was collected. (no-data-collected)
  self._warn("No data was collected.", slug="no-data-collected")
/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/coverage/control.py:892: CoverageWarning: No data was collected. (no-data-collected)
  self._warn("No data was collected.", slug="no-data-collected")

@AmintorDusko . Jax was installed, so the tests should have run. Ever seen these warnings before?

Could you please provide a link to the error or the full traceback?

@albi3ro
Copy link
Contributor Author

albi3ro commented Nov 28, 2024

/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/coverage/control.py:892: CoverageWarning: No data was collected. (no-data-collected)
  self._warn("No data was collected.", slug="no-data-collected")
/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/coverage/control.py:892: CoverageWarning: No data was collected. (no-data-collected)
  self._warn("No data was collected.", slug="no-data-collected")
/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/coverage/control.py:892: CoverageWarning: No data was collected. (no-data-collected)
  self._warn("No data was collected.", slug="no-data-collected")
/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/coverage/control.py:892: CoverageWarning: No data was collected. (no-data-collected)
  self._warn("No data was collected.", slug="no-data-collected")

@AmintorDusko . Jax was installed, so the tests should have run. Ever seen these warnings before?

Could you please provide a link to the error or the full traceback?

https://github.com/PennyLaneAI/pennylane-lightning/actions/runs/12071248436/job/33662775990

@AmintorDusko
Copy link
Contributor

/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/coverage/control.py:892: CoverageWarning: No data was collected. (no-data-collected)
  self._warn("No data was collected.", slug="no-data-collected")
/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/coverage/control.py:892: CoverageWarning: No data was collected. (no-data-collected)
  self._warn("No data was collected.", slug="no-data-collected")
/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/coverage/control.py:892: CoverageWarning: No data was collected. (no-data-collected)
  self._warn("No data was collected.", slug="no-data-collected")
/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/coverage/control.py:892: CoverageWarning: No data was collected. (no-data-collected)
  self._warn("No data was collected.", slug="no-data-collected")

@AmintorDusko . Jax was installed, so the tests should have run. Ever seen these warnings before?

Could you please provide a link to the error or the full traceback?

https://github.com/PennyLaneAI/pennylane-lightning/actions/runs/12071248436/job/33662775990

Thank you as suggested by @maliasadi, this looks like a pytest split problem.

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.

Thank you!

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.

Thanks @albi3ro! 🤩

Don't worry about the codecov warnings! This is not related to your PR and your tests have 💯 coverage. We will fix the issue with CoverageWarning: No data was collected. (no-data-collected) in parallel runs of our pytests as a follow-up.

tests/lightning_qubit/test_eval_jaxpr.py Outdated Show resolved Hide resolved
tests/lightning_qubit/test_eval_jaxpr.py Outdated Show resolved Hide resolved
tests/lightning_qubit/test_eval_jaxpr.py Outdated Show resolved Hide resolved
@albi3ro albi3ro added ci:build_wheels Activate wheel building. ci:use-gpu-runner Enable usage of GPU runner for this Pull Request labels Dec 2, 2024
Copy link
Contributor

@mudit2812 mudit2812 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

@albi3ro albi3ro requested a review from maliasadi December 2, 2024 22:31
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.

Happy to approve!

@albi3ro albi3ro merged commit 74ad9a3 into master Dec 3, 2024
93 checks passed
@albi3ro albi3ro deleted the lightning-interpreter branch December 3, 2024 22:18
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. ci:use-gpu-runner Enable usage of GPU runner for this Pull Request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants