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 PSWAP gate on all PennyLane-Lightning devices #1088

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

jzaia18
Copy link
Contributor

@jzaia18 jzaia18 commented Mar 12, 2025

Context:
Currently, PSWAP does not have a custom implementation within PennyLane-Lightning. This results in it using the implementation from PennyLane-Core whenever the gate is used. By implementing the gate directly in PennyLane-Lightning, performance of the PSWAP gate can be improved.

Description of the Change:
Implements the PSWAP gate natively in Lightning-Qubit, Lightning-Kokkos, and Lightning-GPU, along with the generators for the PSWAP gate.

Benefits:
Native implementation of the PSWAP gate provides significant performance benefits on all tested PennyLane-Lightning backends. The charts below show the execution time of circuits each containing 200 PSWAP gates on varying number of qubits, as well as the realized speedup from the native implementation.

NOTE The Lightning-Qubit backend was run with the dispatcher turned off to avoid any differences in speedup coming from running AVX kernels in the original version of the code.

Benchmarks for a constant number of PSWAPS:
pswap-benchmark-constant

pswap-benchmark-speedup-constant

Benchmarks for a dynamic number of PSWAPS, increasing with circuit size:
pswap-benchmark-dynamic

pswap-benchmark-speedup-dynamic

Possible Drawbacks:

Related GitHub Issues:
#976: PSWAP gate implementation in Lightning Qubit
[sc-77445]
[sc-85797]
[sc-85802]
[sc-86524]

@jzaia18 jzaia18 added the draft Indicates that the PR is still in draft mode, but needs CIs. label Mar 12, 2025
Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit .github/CHANGELOG.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.

Copy link

codecov bot commented Mar 12, 2025

Codecov Report

Attention: Patch coverage is 99.22179% with 2 lines in your changes missing coverage. Please review.

Project coverage is 98.84%. Comparing base (4b92df6) to head (0d35dde).

Files with missing lines Patch % Lines
...tning_qubit/gates/tests/Test_OpToMemberFuncPtr.cpp 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1088      +/-   ##
==========================================
+ Coverage   95.79%   98.84%   +3.05%     
==========================================
  Files         237      237              
  Lines       40193    40447     +254     
==========================================
+ Hits        38501    39981    +1480     
+ Misses       1692      466    -1226     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jzaia18 jzaia18 self-assigned this Mar 12, 2025
jzaia18 and others added 12 commits March 14, 2025 09:52
**Context:**
Currently, PSWAP does not have a custom implementation within
PennyLane-Lightning. This results in it using the implementation from
PennyLane-Core whenever the gate is used. By implementing the gate
directly in PennyLane-Lightning, performance of the PSWAP gate can be
improved.

**Description of the Change:**
Implements the PSWAP gate natively in lightning-qubit.

**Benefits:**
On a quick benchmark that runs O(10k) PSWAP gates on 20 qubits, the
native implementation reduces execution time from ~9.0s to ~2.3s.

**Possible Drawbacks:**

**Related GitHub Issues:**
#976: PSWAP gate implementation in Lightning Qubit

[sc-77445]

---------

Co-authored-by: ringo-but-quantum <[email protected]>
**Context:**
PSWAP does not have a custom implementation within Lightning-Kokkos.
This results in it using the implementation from PennyLane-Core whenever
the gate is used. By implementing the gate directly in Lightning-Kokkos,
performance of the PSWAP gate can be improved.

**Description of the Change:**
 Implements the PSWAP gate natively in Lightning-Kokkos.

**Benefits:**

**Possible Drawbacks:**

**Related GitHub Issues:**
[sc-85797]

---------

Co-authored-by: ringo-but-quantum <[email protected]>
**Context:**
PSWAP does not have hooks within Lightning-GPU This results in it using
the implementation from PennyLane-Core whenever the gate is used. By
implementing the gate directly in Lightning-GPU, performance of the
PSWAP gate can be improved.

**Description of the Change:**
 Implements the PSWAP gate natively in Lightning-GPU.

**Benefits:**

**Possible Drawbacks:**

**Related GitHub Issues:**
[sc-85802]

---------

Co-authored-by: ringo-but-quantum <[email protected]>
**Context:**
Currently, the implementation of PSWAP does not contain its generators,
and the gate is not differentiable.

**Description of the Change:**
Implements generators for the PSWAP gate.

**Benefits:**

**Possible Drawbacks:**

**Related GitHub Issues:**
[sc-86524]

---------

Co-authored-by: ringo-but-quantum <[email protected]>
@jzaia18 jzaia18 changed the title [WIP] Implement PSWAP (all devices) Implement PSWAP gate on all PennyLane-Lightning devices Mar 21, 2025
@jzaia18 jzaia18 added ci:use-multi-gpu-runner Enable usage of Multi-GPU runner for this Pull Request ci:build_wheels Activate wheel building. ci:use-gpu-runner Enable usage of GPU runner for this Pull Request and removed draft Indicates that the PR is still in draft mode, but needs CIs. labels Mar 21, 2025
@AmintorDusko
Copy link
Contributor

AmintorDusko commented Mar 24, 2025

I merged the master here to manage the use of CI runners. Please double-check it. Thanks!

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 ci:use-multi-gpu-runner Enable usage of Multi-GPU runner for this Pull Request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants