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

Defer op-arithmetic to default qubit #349

Merged
merged 5 commits into from Sep 9, 2022
Merged

Conversation

albi3ro
Copy link
Contributor

@albi3ro albi3ro commented Sep 2, 2022

dev = qml.device('lightning.qubit', wires=2)

@qml.qnode(dev, diff_method=None)
def circuit():
    obs = qml.s_prod(2.1, qml.PauliZ(0)) + qml.op_sum(qml.PauliX(0), qml.PauliZ(1))
    return qml.expval(obs)

This PR adds support for operator arithmetic observables to lightning qubit by deferring handling of them to default.qubit.

While we should examine to natively support them in lightning, this fix at least gets support in.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 2, 2022

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.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 2, 2022

Test Report (Linux, Kokkos, and Kokkos Kernels) on Ubuntu

           1 files  ±       0             1 suites  ±0   2s ⏱️ ±0s
       956 tests +     40         956 ✔️ +     40  0 💤 ±0  0 ±0 
234 969 runs  +1 704  234 969 ✔️ +1 704  0 💤 ±0  0 ±0 

Results for commit 36dd4c1. ± Comparison against base commit 3b78924.

♻️ This comment has been updated with latest results.

@codecov
Copy link

codecov bot commented Sep 2, 2022

Codecov Report

Merging #349 (36dd4c1) into master (3b78924) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #349      +/-   ##
==========================================
- Coverage   99.88%   99.88%   -0.01%     
==========================================
  Files          49       49              
  Lines        4202     4195       -7     
==========================================
- Hits         4197     4190       -7     
  Misses          5        5              
Impacted Files Coverage Δ
pennylane_lightning/_version.py 100.00% <100.00%> (ø)
pennylane_lightning/lightning_qubit.py 99.62% <100.00%> (-0.01%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Member

@mlxd mlxd 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
A few comments and suggestions

pennylane_lightning/lightning_qubit.py Show resolved Hide resolved
.github/CHANGELOG.md Show resolved Hide resolved
tests/test_expval.py Show resolved Hide resolved
@albi3ro albi3ro requested a review from mlxd September 8, 2022 19:35
Copy link
Contributor

@chaeyeunpark chaeyeunpark 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! Happy to approve.

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.

Thanks for that @albi3ro!

@albi3ro albi3ro merged commit 84e31bd into master Sep 9, 2022
@albi3ro albi3ro deleted the op-arithmetic-support branch September 9, 2022 16:22
chaeyeunpark added a commit that referenced this pull request Sep 18, 2022
commit 84e31bd
Author: Christina Lee <chrissie.c.l@gmail.com>
Date:   Fri Sep 9 09:22:56 2022 -0700

    Defer op-arithmetic to default qubit (#349)

    * defer op-arithmetic to default qubit

    * Auto update version

    * tests, changelog, black

    * differentiation tests

    * black

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

commit 3b78924
Author: Matthew Silverman <ma.silv11@gmail.com>
Date:   Tue Aug 30 08:48:53 2022 -0400

    remove `supports_reversible_diff` (#342)

    * remove unused option

    * Auto update version

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

commit 6958fb8
Author: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>
Date:   Mon Aug 29 09:36:08 2022 -0400

    Quick fix for upload artifact for win (#346)

    * fix upload artifact for win

    * update changelog

commit 66429b0
Author: Rashid N H M <95639609+rashidnhm@users.noreply.github.com>
Date:   Sat Aug 27 21:28:06 2022 -0400

    Updated ReadTheDocs bade to new url (#339)

    * Updated ReadTheDocs bade to new url

    * Auto update version

    * Auto update version

    Co-authored-by: Dev version update bot <chae-yeun@xanadu.ai>
    Co-authored-by: Josh Izaac <josh146@gmail.com>
    Co-authored-by: Dev version update bot <github-actions[bot]@users.noreply.github.com>

commit f1a6789
Author: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>
Date:   Fri Aug 26 13:41:14 2022 -0400

    Update cancel-workflow-action and bot credentials (#345)

    * update bot credentials

    * update cancel-workflow-action

commit b594234
Author: Lee James O'Riordan <mlxd@users.noreply.github.com>
Date:   Fri Aug 26 09:21:15 2022 -0400

    Update tagger bot for latest release (#344)

    * Update tagged CI for releases

    * Auto update version

    * Update changelog [skip_ci]

    Co-authored-by: Dev version update bot <chae-yeun@xanadu.ai>

commit 8265edd
Author: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>
Date:   Thu Aug 25 10:59:45 2022 -0400

    Caching Kokkos build for wheel-builds (#316)

    * introduce caching Kokkos for wheels

    * improve process_options file

    * isolate Kokkos installation

    * offload windows wheel build to cibuildwheel

    * update PennyLane-Lightning build

    Co-authored-by: Lee James O'Riordan <mlxd@users.noreply.github.com>
    Co-authored-by: Lee J. O'Riordan <lee@xanadu.ai>

commit 2282f9f
Author: Chae-Yeun Park <chae-yeun@xanadu.ai>
Date:   Wed Aug 24 10:07:59 2022 -0400

    Exclude AVX512 lines from codecov (#340)

    * Add expval(ham) forward

    * Fix namespace

    * Auto update version

    * Trigger CI

    * Unwrap ArrayBox

    * Format

    * Trigger CI

    * Remove irrelevant file

    * Update for CodeCov

    * Auto update version

    * Retry for AVX2

    * Retry for AVX2

    * Retry for AVX2

    * Retry for AVX2

    * Retry for AVX2

commit 9bad592
Author: Chae-Yeun Park <chae-yeun@xanadu.ai>
Date:   Tue Aug 23 18:07:46 2022 -0400

    Add Hamiltonian expval in the forward path (#333)

    * Add expval(ham) forward

    * Fix namespace

    * Auto update version

    * Trigger CI

    * Unwrap ArrayBox

    * Format

    * Trigger CI

    * Auto update version

    * Remove irrelevant file

    * Auto update version

    * Update pennylane_lightning/src/algorithms/JacobianTape.hpp

    Co-authored-by: Lee James O'Riordan <mlxd@users.noreply.github.com>

    * Update changelog

    Co-authored-by: Lee James O'Riordan <mlxd@users.noreply.github.com>

commit c443592
Author: Josh Izaac <josh146@gmail.com>
Date:   Tue Aug 23 11:11:50 2022 -0400

    Update docs URL (#335)

    * Update docs URL

    * Auto update version

    * Auto update version

    * update navbar

    Co-authored-by: Dev version update bot <chae-yeun@xanadu.ai>
    Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>

commit bc54a3e
Author: Josh Izaac <josh146@gmail.com>
Date:   Tue Aug 23 02:45:02 2022 +0800

    Update conf.py

commit 1e43ace
Author: Chae-Yeun Park <chae-yeun@xanadu.ai>
Date:   Mon Aug 22 14:37:00 2022 -0400

    Fix measurement error message (#334)

    * Fix measurement error message

    * Reformat

    * Add Changelog

commit c15fa0d
Author: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>
Date:   Thu Aug 18 10:06:32 2022 -0400

    Create a PennyLane-lightning requirements-dev.txt and update the Dockerfile (#330)

    * Create a requirements-dev.txt

    * Update tests and benchmarks

    * Improve dockerfile

commit 87538ec
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Mon Aug 15 10:57:49 2022 -0400

    post release version bump (#331)

    Co-authored-by: mlxd <mlxd@users.noreply.github.com>

commit dc0d3b1
Author: Lee J. O'Riordan <loriordan@gmail.com>
Date:   Thu Aug 11 13:03:58 2022 -0400

    Remove redundant Win ops and pin to WS2019

commit e5755d9
Author: Lee J. O'Riordan <loriordan@gmail.com>
Date:   Thu Aug 11 11:39:24 2022 -0400

    Remove build base command

commit ba16ec9
Author: Lee J. O'Riordan <loriordan@gmail.com>
Date:   Thu Aug 11 11:32:27 2022 -0400

    Downgrade Py3.10 version to avoid additional characters in build path

commit e3f8b4e
Author: Lee J. O'Riordan <loriordan@gmail.com>
Date:   Thu Aug 11 11:19:56 2022 -0400

    Attempt updating Python installation package for Windows runner

commit 90c06cc
Author: Lee J. O'Riordan <loriordan@gmail.com>
Date:   Thu Aug 11 11:00:55 2022 -0400

    Retry forcing longpaths for W10 build

commit 36abd9b
Author: Lee J. O'Riordan <loriordan@gmail.com>
Date:   Thu Aug 11 10:38:24 2022 -0400

    Disable clone of Kokkos submodules to allow Windows builds to proceed

commit becd10c
Author: Lee J. O'Riordan <loriordan@gmail.com>
Date:   Thu Aug 11 08:45:43 2022 -0400

    Fix changelog++

commit c321d34
Author: Lee J. O'Riordan <loriordan@gmail.com>
Date:   Thu Aug 11 08:44:12 2022 -0400

    Fix changelog

commit c198a5d
Author: Lee J. O'Riordan <loriordan@gmail.com>
Date:   Tue Aug 9 12:10:44 2022 -0400

    Update version string

    Signed-off-by: Lee J. O'Riordan <loriordan@gmail.com>

commit 2dd4b80
Author: Lee J. O'Riordan <loriordan@gmail.com>
Date:   Tue Aug 9 12:08:50 2022 -0400

    Update changelog
chaeyeunpark added a commit that referenced this pull request Feb 7, 2023
* Adding more Generators

* Adding more AVX generators/gates

* Adding Generators

* Update

* AddIsingXY

* Add ControlledPhaseShift

* Squashed commit of the following:

commit 84e31bd
Author: Christina Lee <chrissie.c.l@gmail.com>
Date:   Fri Sep 9 09:22:56 2022 -0700

    Defer op-arithmetic to default qubit (#349)

    * defer op-arithmetic to default qubit

    * Auto update version

    * tests, changelog, black

    * differentiation tests

    * black

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

commit 3b78924
Author: Matthew Silverman <ma.silv11@gmail.com>
Date:   Tue Aug 30 08:48:53 2022 -0400

    remove `supports_reversible_diff` (#342)

    * remove unused option

    * Auto update version

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

commit 6958fb8
Author: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>
Date:   Mon Aug 29 09:36:08 2022 -0400

    Quick fix for upload artifact for win (#346)

    * fix upload artifact for win

    * update changelog

commit 66429b0
Author: Rashid N H M <95639609+rashidnhm@users.noreply.github.com>
Date:   Sat Aug 27 21:28:06 2022 -0400

    Updated ReadTheDocs bade to new url (#339)

    * Updated ReadTheDocs bade to new url

    * Auto update version

    * Auto update version

    Co-authored-by: Dev version update bot <chae-yeun@xanadu.ai>
    Co-authored-by: Josh Izaac <josh146@gmail.com>
    Co-authored-by: Dev version update bot <github-actions[bot]@users.noreply.github.com>

commit f1a6789
Author: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>
Date:   Fri Aug 26 13:41:14 2022 -0400

    Update cancel-workflow-action and bot credentials (#345)

    * update bot credentials

    * update cancel-workflow-action

commit b594234
Author: Lee James O'Riordan <mlxd@users.noreply.github.com>
Date:   Fri Aug 26 09:21:15 2022 -0400

    Update tagger bot for latest release (#344)

    * Update tagged CI for releases

    * Auto update version

    * Update changelog [skip_ci]

    Co-authored-by: Dev version update bot <chae-yeun@xanadu.ai>

commit 8265edd
Author: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>
Date:   Thu Aug 25 10:59:45 2022 -0400

    Caching Kokkos build for wheel-builds (#316)

    * introduce caching Kokkos for wheels

    * improve process_options file

    * isolate Kokkos installation

    * offload windows wheel build to cibuildwheel

    * update PennyLane-Lightning build

    Co-authored-by: Lee James O'Riordan <mlxd@users.noreply.github.com>
    Co-authored-by: Lee J. O'Riordan <lee@xanadu.ai>

commit 2282f9f
Author: Chae-Yeun Park <chae-yeun@xanadu.ai>
Date:   Wed Aug 24 10:07:59 2022 -0400

    Exclude AVX512 lines from codecov (#340)

    * Add expval(ham) forward

    * Fix namespace

    * Auto update version

    * Trigger CI

    * Unwrap ArrayBox

    * Format

    * Trigger CI

    * Remove irrelevant file

    * Update for CodeCov

    * Auto update version

    * Retry for AVX2

    * Retry for AVX2

    * Retry for AVX2

    * Retry for AVX2

    * Retry for AVX2

commit 9bad592
Author: Chae-Yeun Park <chae-yeun@xanadu.ai>
Date:   Tue Aug 23 18:07:46 2022 -0400

    Add Hamiltonian expval in the forward path (#333)

    * Add expval(ham) forward

    * Fix namespace

    * Auto update version

    * Trigger CI

    * Unwrap ArrayBox

    * Format

    * Trigger CI

    * Auto update version

    * Remove irrelevant file

    * Auto update version

    * Update pennylane_lightning/src/algorithms/JacobianTape.hpp

    Co-authored-by: Lee James O'Riordan <mlxd@users.noreply.github.com>

    * Update changelog

    Co-authored-by: Lee James O'Riordan <mlxd@users.noreply.github.com>

commit c443592
Author: Josh Izaac <josh146@gmail.com>
Date:   Tue Aug 23 11:11:50 2022 -0400

    Update docs URL (#335)

    * Update docs URL

    * Auto update version

    * Auto update version

    * update navbar

    Co-authored-by: Dev version update bot <chae-yeun@xanadu.ai>
    Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>

commit bc54a3e
Author: Josh Izaac <josh146@gmail.com>
Date:   Tue Aug 23 02:45:02 2022 +0800

    Update conf.py

commit 1e43ace
Author: Chae-Yeun Park <chae-yeun@xanadu.ai>
Date:   Mon Aug 22 14:37:00 2022 -0400

    Fix measurement error message (#334)

    * Fix measurement error message

    * Reformat

    * Add Changelog

commit c15fa0d
Author: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>
Date:   Thu Aug 18 10:06:32 2022 -0400

    Create a PennyLane-lightning requirements-dev.txt and update the Dockerfile (#330)

    * Create a requirements-dev.txt

    * Update tests and benchmarks

    * Improve dockerfile

commit 87538ec
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Mon Aug 15 10:57:49 2022 -0400

    post release version bump (#331)

    Co-authored-by: mlxd <mlxd@users.noreply.github.com>

commit dc0d3b1
Author: Lee J. O'Riordan <loriordan@gmail.com>
Date:   Thu Aug 11 13:03:58 2022 -0400

    Remove redundant Win ops and pin to WS2019

commit e5755d9
Author: Lee J. O'Riordan <loriordan@gmail.com>
Date:   Thu Aug 11 11:39:24 2022 -0400

    Remove build base command

commit ba16ec9
Author: Lee J. O'Riordan <loriordan@gmail.com>
Date:   Thu Aug 11 11:32:27 2022 -0400

    Downgrade Py3.10 version to avoid additional characters in build path

commit e3f8b4e
Author: Lee J. O'Riordan <loriordan@gmail.com>
Date:   Thu Aug 11 11:19:56 2022 -0400

    Attempt updating Python installation package for Windows runner

commit 90c06cc
Author: Lee J. O'Riordan <loriordan@gmail.com>
Date:   Thu Aug 11 11:00:55 2022 -0400

    Retry forcing longpaths for W10 build

commit 36abd9b
Author: Lee J. O'Riordan <loriordan@gmail.com>
Date:   Thu Aug 11 10:38:24 2022 -0400

    Disable clone of Kokkos submodules to allow Windows builds to proceed

commit becd10c
Author: Lee J. O'Riordan <loriordan@gmail.com>
Date:   Thu Aug 11 08:45:43 2022 -0400

    Fix changelog++

commit c321d34
Author: Lee J. O'Riordan <loriordan@gmail.com>
Date:   Thu Aug 11 08:44:12 2022 -0400

    Fix changelog

commit c198a5d
Author: Lee J. O'Riordan <loriordan@gmail.com>
Date:   Tue Aug 9 12:10:44 2022 -0400

    Update version string

    Signed-off-by: Lee J. O'Riordan <loriordan@gmail.com>

commit 2dd4b80
Author: Lee J. O'Riordan <loriordan@gmail.com>
Date:   Tue Aug 9 12:08:50 2022 -0400

    Update changelog

* Refactor some AVX functions; Add CRY

* Update

* Add AVX CRZ; format

* Auto update version

* Fix for Tidy

* Add CRX

* Format

* Fix for tidy

* Auto update version

* Add some comments

* Update

* Apply suggestions from code review

Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>

* Adding more comments

* Update comment; Add readme

* Update README

* Update

* Update

* change to PL_ASSERT

* Fix SWAP

* Tidying-up some headers

* Add docstrings to helper functions

* Change some constexpr functions to consteval

* Update setValue

* Apply suggestions from code review

Co-authored-by: Lee James O'Riordan <mlxd@users.noreply.github.com>

* Remove unneccesary head

* Retry CI

* Apply suggestions from code review

Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>

* Auto update version

* Update formatting

* Auto update version

* Add some more explanation

* Update changelog

* Format

* Update .github/CHANGELOG.md

Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>

---------

Co-authored-by: Dev version update bot <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>
Co-authored-by: Lee James O'Riordan <mlxd@users.noreply.github.com>
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.

None yet

4 participants