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

Fix decompositions with LightningQubit #687

Merged
merged 9 commits into from Apr 18, 2024

Conversation

mudit2812
Copy link
Contributor

@mudit2812 mudit2812 commented Apr 16, 2024

Context:
PL Issue #5526. State prep operations in the middle of circuits were not being decomposed with lightning.qubit.

Description of the Change:

  • Removed state prep ops from list of supported ops. If used in the beginning of the circuit, state prep ops will still not be decomposed unless they have trainable parameters and adjoint diff is requested. If present in the middle of the circuit, the state prep ops will always be decomposed.
  • Update stopping_condition to decompose qml.QFT and qml.GroverOperator if number of wires is >= 10 or 13 respectively.

Benefits:
Feature parity with default.qubit/old lightning.qubit.

Possible Drawbacks:

Related GitHub Issues:

@mudit2812
Copy link
Contributor Author

[sc-61467]

Comment on lines -185 to -187
"BasisState",
"QubitStateVector",
"StatePrep",
Copy link
Member

Choose a reason for hiding this comment

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

For the reference, these ops are also decomposed in Catalyst by default

decomp = [
"BasisState",
"QubitStateVector",
"StatePrep",
"QFT",
"MultiControlledX",
]

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

codecov bot commented Apr 16, 2024

Codecov Report

Attention: Patch coverage is 0% with 5 lines in your changes are missing coverage. Please review.

❗ No coverage uploaded for pull request base (feature/test_templates@201d14a). Click here to learn what that means.

Files Patch % Lines
...ylane_lightning/lightning_qubit/lightning_qubit.py 0.00% 5 Missing ⚠️
Additional details and impacted files
@@                    Coverage Diff                    @@
##             feature/test_templates     #687   +/-   ##
=========================================================
  Coverage                          ?   95.72%           
=========================================================
  Files                             ?      173           
  Lines                             ?    24507           
  Branches                          ?        0           
=========================================================
  Hits                              ?    23459           
  Misses                            ?     1048           
  Partials                          ?        0           

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

@mudit2812 mudit2812 changed the title Fix state prep op decomposition with LightningQubit Fix decompositions with LightningQubit Apr 17, 2024
@mudit2812 mudit2812 changed the base branch from master to feature/test_templates April 17, 2024 17:43
.github/CHANGELOG.md Outdated Show resolved Hide resolved
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. +1 on @maliasadi 's suggestions.

pennylane_lightning/lightning_qubit/lightning_qubit.py Outdated Show resolved Hide resolved
.github/CHANGELOG.md 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.

Looks good to me. One more +1 to @maliasadi's suggestion

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 .

@maliasadi maliasadi added the ci:build_wheels Activate wheel building. label Apr 17, 2024
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 @mudit2812! Nice job 🥳

@mudit2812 mudit2812 merged commit 50b7fa9 into feature/test_templates Apr 18, 2024
1 check was pending
@mudit2812 mudit2812 deleted the state-prep-fix branch April 18, 2024 14:01
maliasadi added a commit that referenced this pull request Apr 18, 2024
…ix LQ decomposition strategy of QFT and GroverOperator (#684)

* Add test for QSVT.

* Auto update version

* Update changelog.

* Add tests for embedding, layer and stateprep templates.

* Parametrize tests over n_qubits.

* Add qchem template tests.

* Add a few misc template tests.

* Auto update version

* trigger ci

* Fix serialize.

* Fix formatting.

* Update tests/test_templates.py

Co-authored-by: Amintor Dusko <[email protected]>

* Update tests/test_templates.py

Co-authored-by: Amintor Dusko <[email protected]>

* Add xfail condition for AmplitudeEmbedding.

* Fix pytest.skip top cond.

* Update tests/test_templates.py

Co-authored-by: Ali Asadi <[email protected]>

* Update pennylane_lightning/core/_serialize.py

Co-authored-by: Ali Asadi <[email protected]>

* Add breaking tests for if not observable

* trigger ci

* Auto update version

* Fix decompositions with `LightningQubit` (#687)

* Fix bug; add tests; update changelog

* Auto update version

* Update tests

* Update qft/grover decomp

* Addressing code review

* Update pennylane_lightning/lightning_qubit/lightning_qubit.py

Co-authored-by: Ali Asadi <[email protected]>

* Trigger CI

* Auto update version

---------

Co-authored-by: Dev version update bot <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Ali Asadi <[email protected]>

* Fix test params

---------

Co-authored-by: Dev version update bot <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Amintor Dusko <[email protected]>
Co-authored-by: Ali Asadi <[email protected]>
Co-authored-by: Mudit Pandey <[email protected]>
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.

[BUG] qml.AmplitudeEmbedding not supported in lightning.qubit in the middle of the circuit
4 participants