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

CY inherits from ControlledOp #4116

Merged
merged 38 commits into from May 25, 2023
Merged

CY inherits from ControlledOp #4116

merged 38 commits into from May 25, 2023

Conversation

frederikwilde
Copy link
Contributor

Context:
Controlled qubit gates are currently implemented manually in the qml.ops.qubit.non_parametric_ops and qml.ops.qubit.parametric_ops_controlled modules. This results in a lot of redundant code. The new (already existing) qml.ops.op_math.ControlledOp removes some of these redundancies.

Description of the Change:
The controlled-PauliY gate CY is moved from qml.ops.qubit.non_parametric_ops to qml.ops.op_math.controlled_ops and inherits from ControlledOp.

Benefits:
Fewer code redundancies. CY now has _controlled as a new method for creating a CCY gate.

Possible Drawbacks:
n/a

Related GitHub Issues:
#1447

@frederikwilde frederikwilde added the WIP 🚧 Work-in-progress label May 11, 2023
@github-actions
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.

@codecov
Copy link

codecov bot commented May 12, 2023

Codecov Report

Merging #4116 (9bc2817) into master (f7cc39d) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #4116   +/-   ##
=======================================
  Coverage   99.77%   99.77%           
=======================================
  Files         340      340           
  Lines       30564    30564           
=======================================
  Hits        30495    30495           
  Misses         69       69           
Impacted Files Coverage Δ
pennylane/ops/op_math/controlled.py 100.00% <ø> (ø)
pennylane/ops/qubit/__init__.py 100.00% <ø> (ø)
pennylane/ops/op_math/__init__.py 100.00% <100.00%> (ø)
pennylane/ops/op_math/controlled_ops.py 100.00% <100.00%> (ø)
pennylane/ops/qubit/non_parametric_ops.py 100.00% <100.00%> (ø)

@albi3ro
Copy link
Contributor

albi3ro commented May 15, 2023

[sc-38095]

@frederikwilde frederikwilde removed the WIP 🚧 Work-in-progress label May 15, 2023
Copy link
Contributor

@timmysilv timmysilv 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, a few small things but this is pretty much good to go. don't forget to add a changelog entry!

pennylane/ops/op_math/controlled_ops.py Outdated Show resolved Hide resolved
pennylane/ops/op_math/controlled_ops.py Outdated Show resolved Hide resolved
tests/ops/op_math/test_controlled_ops.py Outdated Show resolved Hide resolved
pennylane/ops/op_math/controlled_ops.py Outdated Show resolved Hide resolved
frederikwilde and others added 2 commits May 16, 2023 13:41
Co-authored-by: Matthew Silverman <matthews@xanadu.ai>
Co-authored-by: Matthew Silverman <matthews@xanadu.ai>
Copy link
Contributor

@albi3ro albi3ro left a comment

Choose a reason for hiding this comment

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

Looking good. Just a few minor testing comments like the ones in #4117 .

And CY should be added to the list here

frederikwilde and others added 2 commits May 16, 2023 16:39
Co-authored-by: Christina Lee <christina@xanadu.ai>
Co-authored-by: Christina Lee <christina@xanadu.ai>
@frederikwilde
Copy link
Contributor Author

@albi3ro @timmysilv There are only two comments unresolved, which I'd need your opinion on. Aside from that, there is one test test_acting_on_qnodes_multi_param which only fails some times. I was also not able to reproduce the failure locally.

Copy link
Contributor

@timmysilv timmysilv left a comment

Choose a reason for hiding this comment

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

that test failure is unrelated. might need a change to the atol or something, but this change looks good to go!

Copy link
Contributor

@albi3ro albi3ro left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks for this :) 🚀

@frederikwilde frederikwilde merged commit 6c350c0 into master May 25, 2023
43 checks passed
@frederikwilde frederikwilde deleted the move-CY-to-controlled-ops branch May 25, 2023 20:08
frederikwilde added a commit that referenced this pull request May 25, 2023
`qml.CY` has been moved from `qml.ops.qubit.non_parametric_ops` to `qml.ops.op_math.controlled_ops`
  and now inherits from `qml.ops.op_math.ControlledOp`.
---------
Co-authored-by: Matthew Silverman <matthews@xanadu.ai>
Co-authored-by: Christina Lee <christina@xanadu.ai>
frederikwilde added a commit that referenced this pull request Aug 15, 2023
* Change seed setting in spsa_grad.

* Update changelog.

* Adapt tests. Note that lots of tests still set a global seed!

* Update pennylane/gradients/spsa_gradient.py

Co-authored-by: Christina Lee <christina@xanadu.ai>

* Update pennylane/gradients/spsa_gradient.py

Co-authored-by: Christina Lee <christina@xanadu.ai>

* use Shots class in gradients module (#4152)

* linting

* add num_copies property to shots

* change gradients to use new Shots class

* fix missing update in vjp

* fix stacking and single-shots in shot_adaptive

* remove unneeded cast to tuple

* type-hints and touch-ups

* code review feedback

* changelog

---------

Co-authored-by: Romain Moyard <rmoyard@gmail.com>

* Qutrit Rotations #2 (TRY) (#2846)

* Adding tests for tensor observables

* Added tests for tensor sample

* Updated tests

* Apply suggestions from code review

* Partition device apply ops test case.

* Run black

* Fix pylint

* Update pennylane/devices/default_qutrit.py

* black and pylint

* Update pennylane/devices/default_qutrit.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_non_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Updated test_default_qutrit.py

* Updated _apply_tadd documentation

* Added eigvals method for TSWAP

* Reverted TSWAP eigval changes

* Update tests/devices/test_default_qutrit.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update pennylane/devices/default_qutrit.py

Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca>

* Added TSWAP eigvals

* Updated changelog-dev.md to include GellMannObs

* Removed empty file

* Added linting comments

* Updated tests to use gate_data

* Updated test parameter names to be more accurate

* Remove unused file

* Updated GellMannObs doc-string

* Update changelog-dev.md

* Update tests/devices/test_default_qutrit.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/devices/test_default_qutrit.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/devices/test_default_qutrit.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update pennylane/ops/qutrit/observables.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Added changes to GellMann to address PR comments

* Updated test

* Reformatting

* Trying out changes to Gell-Mann docstring

* Updated Changelog

* Update pennylane/ops/qutrit/observables.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Testing LaTeX align

* Added non-diag tests

* Added diag, complex case for tensor sample

* Added example to doc string

* Fixed label test

* Update pennylane/ops/qutrit/observables.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update pennylane/ops/qutrit/observables.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/devices/test_default_qutrit.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/devices/test_default_qutrit.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Added tests for controlled qutrit unitary

* Fix broadcasting, finish tests for CQutritUnitary

* Added TRX and created skeleton files

* Adding tests for TRX

* Fixed broadcasting issue in controlled qutrit unitary

* Fixed broadcasting issue with ControlledQutritUnitary

* Fixed broadcasting issue in TRX

* Updated TRX documentation

* Added tests

* Added tests for TRX

* Removed unused imports

* Removed unused imports, linting changes

* Added TRX parameter frequencies

* Updated matrix dtype for TRX generator

* Added test for param frequencies

* Added param-shift capability for qutrit devices

* Updated changelog

* Update changelog

* Added change for TRX generator

* Updated utils.py to support higher dimensions

* Added tests for updated utils.sparse_hamiltonian

* Added Identity as supported obs

* Updated TRX docstring

* Update tests/ops/qutrit/test_qutrit_non_parametric_ops.py

Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca>

* Update pennylane/ops/qutrit/observables.py

Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca>

* Update pennylane/ops/qutrit/observables.py

Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca>

* Added ControlledQutritUnitary

* Update changelog-dev.md

* Removed empty files

* Update tests/ops/qutrit/test_qutrit_matrix_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_matrix_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_matrix_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_matrix_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Updated to address PR

* Fixed uncommented lines in test suite

* Added complex values to state

* Updated test_mixed_polarity_controls

* Fixed QutritUnitary._controlled

* Updated test_controlled for matrix ops

* Updated ControlledQutritUnitary._controlled

* Reformatting

* Update pennylane/ops/qutrit/matrix_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Updated ControlledQutritUnitary and tests

* Addressing PR review

* Updated sparse_hamiltonian, fixed TRX docstring

* Addressing PR review

* Refactoring

* Fixed changelog

* Update pennylane/devices/default_qutrit.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update pennylane/ops/qutrit/parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update pennylane/ops/qutrit/parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update pennylane/ops/qutrit/parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update pennylane/ops/qutrit/parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/test_qnode.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Reverted changes to sparse_hamiltonian

* Fixed sparse_hamiltonian test

* Updated changelog

* Updated TRX documentation

* Fixed generator

* Adding levels to sparse_hamiltonian

* Updated test sparse hamiltonian

* Fixed sparse hamiltonian test

* Fixed constant level kwarg

* Updated changelog, added test coverage

* Fixed coverage

* Updated test suite

* Updated files to address PR review

* Updated tests to include subspace error tests

* Added TRX tests for parameter shift

* Update doc/releases/changelog-dev.md

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update pennylane/utils.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update utils.py to remove trailing whitespace

* Updated to address PR review

* Fixed class/object confusion bug

* Testing changes to adjust lines changed in PR

* Fixing changes

* Fixing changes

* Resetting problem files

* Fixing changes

* updated TRX docs

* Fixed TRX docs

* Updated TRX docs

* Fixed PR too many lines changed issue

* Updated subspace error tests

* Tweaked THadamard docs to fix rendering

* Test dos2unix

* Fixed subspace testing

* Merge changes

* Started adding tests for grad

* Updated tests to parametrize diff-method

* Linted tests

* Fiex tests using in-place inversion

* Added diff tests

* Update pennylane/ops/qutrit/parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Fixed formatting

* Update pennylane/utils.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Updated TRY and tests

* Updated utils.py

* Fixed TRX generator

* Updated generator TRY

* Updated subspace validation for TRY

* Updated subspace validation

* Update pennylane/ops/qutrit/parametric_ops.py

Co-authored-by: Christina Lee <chrissie.c.l@gmail.com>

* Update pennylane/ops/qutrit/parametric_ops.py

Co-authored-by: Matthew Silverman <ma.silv11@gmail.com>

* Update pennylane/ops/qutrit/parametric_ops.py

Co-authored-by: Matthew Silverman <ma.silv11@gmail.com>

* Reverted `validate_subspace` changes

* Updated test

* Added parameter shift test

* Fixed test

* Update doc/releases/changelog-dev.md

* Update changelog

* Updated grad tests

* Apply suggestions from code review

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Updated subspace docstring

---------

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>
Co-authored-by: Olivia Di Matteo <dimatteo.olivia@protonmail.com>
Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca>
Co-authored-by: Christina Lee <chrissie.c.l@gmail.com>
Co-authored-by: Matthew Silverman <ma.silv11@gmail.com>

* jax integration for for DefaultQubit2 (#4137)

* copy-paste autograd test file

* port to jax in tests; update shots in jax interface

* add argnums when needed; skip tests that do not work with jax

* use pytest imports to skip

* pylint tests

* changelog

* take shots change from Christina's PR

* Update doc/releases/changelog-dev.md

Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>

* copy changes to autograd as well

* rename to indicate bool; slight autograd fixup

---------

Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>

* Treat identities as equivalent in `pauli.are_identical_pauli_words` (#4161)

* fix hamiltonian grouping indices bug

* Update doc/releases/changelog-dev.md

* Take wire ordering in the `wires` argument to `qml.density_matrix` into account (#4072)

* include wire ordering, test for that, raise error for broadcasting, test for that

* reduce

* changelog

* add test for qinfo transform

* more tests for math module

* lint math tests

* lint

* black

* introduce, use and test input_is_dm kwarg to reduced_dm

* tmp

* reverting

* seed fix

---------

Co-authored-by: Edward Jiang <34989448+eddddddy@users.noreply.github.com>

* CY inherits from ControlledOp (#4116)

`qml.CY` has been moved from `qml.ops.qubit.non_parametric_ops` to `qml.ops.op_math.controlled_ops`
  and now inherits from `qml.ops.op_math.ControlledOp`.
---------
Co-authored-by: Matthew Silverman <matthews@xanadu.ai>
Co-authored-by: Christina Lee <christina@xanadu.ai>

* Empty hamiltonians are compatible with `qml.pauli_sentence()` (#4171)

* fix ps rep for empty hamiltonian

* changelog

* Update doc/releases/changelog-dev.md

Co-authored-by: Utkarsh <utkarshazad98@gmail.com>

---------

Co-authored-by: Utkarsh <utkarshazad98@gmail.com>

* Update tests/interfaces/test_torch_qnode.py

Co-authored-by: Christina Lee <christina@xanadu.ai>

* Python 3.8 compatibility and increase num_directions, since spsa_grad, with num_directions=1, fails sometimes, depending on the seed.

* Fix failing tests

* Fix docs.

* Fix unsupported NoneType import

* Undo irrelevant change.

* Fix failing tests. Still not reliable.

* Fix tolerance issue with SPSA second derivative.

* Increase tolerance. This test has also been failing spontaneously on the master branch 3468885

* Switch to sampler_rng kwarg and fix tolerance issues.

* More migration to sampler_rng

* Migrate more tests to sampler_rng

* Migrate legacy tests to sampler_rng

* black

* Deprecated the sampler_seed argument

* black

* Increase tolerance for test_hamiltonian_expansion_finite_shots tests.

* Fix tol

* Pin autoray for CI

* Set num_directions=20 in all hamiltonian_expansion_finite_shots tests.

* Make black and pylint happy

* Set device seed for DQ2 tests.

* Add tests for new return type system.

* Fix bug

* Adapt dq2 tests for spsa

* Remove qml.disable_return()

* Change DQ2 tests to new seed setting system.

* Fix bug

* Fix failing tests. TF tests pass locally. Not sure what the problem is.

* Fix missing grad_kwarg

* black

* Increase tol

* Increase num_directions

* Apply suggestions from code review

Co-authored-by: David Wierichs <david.wierichs@xanadu.ai>

* Update pennylane/gradients/spsa_gradient.py

Co-authored-by: David Wierichs <david.wierichs@xanadu.ai>

* Copy TestRademacherSampler into new tests

* Make docs more precise and add tests for rng kwarg of samplers.

* black

* black

* Fix error message in _spsa_grad_legacy

* pylint

* Update changelog-dev.md

* black

* Increase num_directions for Hessian test.

---------

Co-authored-by: Christina Lee <christina@xanadu.ai>
Co-authored-by: Matthew Silverman <matthews@xanadu.ai>
Co-authored-by: Romain Moyard <rmoyard@gmail.com>
Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>
Co-authored-by: Olivia Di Matteo <dimatteo.olivia@protonmail.com>
Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca>
Co-authored-by: Christina Lee <chrissie.c.l@gmail.com>
Co-authored-by: Matthew Silverman <ma.silv11@gmail.com>
Co-authored-by: David Wierichs <david.wierichs@xanadu.ai>
Co-authored-by: Edward Jiang <34989448+eddddddy@users.noreply.github.com>
Co-authored-by: Utkarsh <utkarshazad98@gmail.com>
ludmilaasb pushed a commit to ludmilaasb/pennylane that referenced this pull request Aug 15, 2023
* Change seed setting in spsa_grad.

* Update changelog.

* Adapt tests. Note that lots of tests still set a global seed!

* Update pennylane/gradients/spsa_gradient.py

Co-authored-by: Christina Lee <christina@xanadu.ai>

* Update pennylane/gradients/spsa_gradient.py

Co-authored-by: Christina Lee <christina@xanadu.ai>

* use Shots class in gradients module (PennyLaneAI#4152)

* linting

* add num_copies property to shots

* change gradients to use new Shots class

* fix missing update in vjp

* fix stacking and single-shots in shot_adaptive

* remove unneeded cast to tuple

* type-hints and touch-ups

* code review feedback

* changelog

---------

Co-authored-by: Romain Moyard <rmoyard@gmail.com>

* Qutrit Rotations PennyLaneAI#2 (TRY) (PennyLaneAI#2846)

* Adding tests for tensor observables

* Added tests for tensor sample

* Updated tests

* Apply suggestions from code review

* Partition device apply ops test case.

* Run black

* Fix pylint

* Update pennylane/devices/default_qutrit.py

* black and pylint

* Update pennylane/devices/default_qutrit.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_non_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Updated test_default_qutrit.py

* Updated _apply_tadd documentation

* Added eigvals method for TSWAP

* Reverted TSWAP eigval changes

* Update tests/devices/test_default_qutrit.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update pennylane/devices/default_qutrit.py

Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca>

* Added TSWAP eigvals

* Updated changelog-dev.md to include GellMannObs

* Removed empty file

* Added linting comments

* Updated tests to use gate_data

* Updated test parameter names to be more accurate

* Remove unused file

* Updated GellMannObs doc-string

* Update changelog-dev.md

* Update tests/devices/test_default_qutrit.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/devices/test_default_qutrit.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/devices/test_default_qutrit.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update pennylane/ops/qutrit/observables.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Added changes to GellMann to address PR comments

* Updated test

* Reformatting

* Trying out changes to Gell-Mann docstring

* Updated Changelog

* Update pennylane/ops/qutrit/observables.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Testing LaTeX align

* Added non-diag tests

* Added diag, complex case for tensor sample

* Added example to doc string

* Fixed label test

* Update pennylane/ops/qutrit/observables.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update pennylane/ops/qutrit/observables.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/devices/test_default_qutrit.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/devices/test_default_qutrit.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Added tests for controlled qutrit unitary

* Fix broadcasting, finish tests for CQutritUnitary

* Added TRX and created skeleton files

* Adding tests for TRX

* Fixed broadcasting issue in controlled qutrit unitary

* Fixed broadcasting issue with ControlledQutritUnitary

* Fixed broadcasting issue in TRX

* Updated TRX documentation

* Added tests

* Added tests for TRX

* Removed unused imports

* Removed unused imports, linting changes

* Added TRX parameter frequencies

* Updated matrix dtype for TRX generator

* Added test for param frequencies

* Added param-shift capability for qutrit devices

* Updated changelog

* Update changelog

* Added change for TRX generator

* Updated utils.py to support higher dimensions

* Added tests for updated utils.sparse_hamiltonian

* Added Identity as supported obs

* Updated TRX docstring

* Update tests/ops/qutrit/test_qutrit_non_parametric_ops.py

Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca>

* Update pennylane/ops/qutrit/observables.py

Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca>

* Update pennylane/ops/qutrit/observables.py

Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca>

* Added ControlledQutritUnitary

* Update changelog-dev.md

* Removed empty files

* Update tests/ops/qutrit/test_qutrit_matrix_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_matrix_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_matrix_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_matrix_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Updated to address PR

* Fixed uncommented lines in test suite

* Added complex values to state

* Updated test_mixed_polarity_controls

* Fixed QutritUnitary._controlled

* Updated test_controlled for matrix ops

* Updated ControlledQutritUnitary._controlled

* Reformatting

* Update pennylane/ops/qutrit/matrix_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Updated ControlledQutritUnitary and tests

* Addressing PR review

* Updated sparse_hamiltonian, fixed TRX docstring

* Addressing PR review

* Refactoring

* Fixed changelog

* Update pennylane/devices/default_qutrit.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update pennylane/ops/qutrit/parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update pennylane/ops/qutrit/parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update pennylane/ops/qutrit/parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update pennylane/ops/qutrit/parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/test_qnode.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Reverted changes to sparse_hamiltonian

* Fixed sparse_hamiltonian test

* Updated changelog

* Updated TRX documentation

* Fixed generator

* Adding levels to sparse_hamiltonian

* Updated test sparse hamiltonian

* Fixed sparse hamiltonian test

* Fixed constant level kwarg

* Updated changelog, added test coverage

* Fixed coverage

* Updated test suite

* Updated files to address PR review

* Updated tests to include subspace error tests

* Added TRX tests for parameter shift

* Update doc/releases/changelog-dev.md

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update pennylane/utils.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update utils.py to remove trailing whitespace

* Updated to address PR review

* Fixed class/object confusion bug

* Testing changes to adjust lines changed in PR

* Fixing changes

* Fixing changes

* Resetting problem files

* Fixing changes

* updated TRX docs

* Fixed TRX docs

* Updated TRX docs

* Fixed PR too many lines changed issue

* Updated subspace error tests

* Tweaked THadamard docs to fix rendering

* Test dos2unix

* Fixed subspace testing

* Merge changes

* Started adding tests for grad

* Updated tests to parametrize diff-method

* Linted tests

* Fiex tests using in-place inversion

* Added diff tests

* Update pennylane/ops/qutrit/parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Fixed formatting

* Update pennylane/utils.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Updated TRY and tests

* Updated utils.py

* Fixed TRX generator

* Updated generator TRY

* Updated subspace validation for TRY

* Updated subspace validation

* Update pennylane/ops/qutrit/parametric_ops.py

Co-authored-by: Christina Lee <chrissie.c.l@gmail.com>

* Update pennylane/ops/qutrit/parametric_ops.py

Co-authored-by: Matthew Silverman <ma.silv11@gmail.com>

* Update pennylane/ops/qutrit/parametric_ops.py

Co-authored-by: Matthew Silverman <ma.silv11@gmail.com>

* Reverted `validate_subspace` changes

* Updated test

* Added parameter shift test

* Fixed test

* Update doc/releases/changelog-dev.md

* Update changelog

* Updated grad tests

* Apply suggestions from code review

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Updated subspace docstring

---------

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>
Co-authored-by: Olivia Di Matteo <dimatteo.olivia@protonmail.com>
Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca>
Co-authored-by: Christina Lee <chrissie.c.l@gmail.com>
Co-authored-by: Matthew Silverman <ma.silv11@gmail.com>

* jax integration for for DefaultQubit2 (PennyLaneAI#4137)

* copy-paste autograd test file

* port to jax in tests; update shots in jax interface

* add argnums when needed; skip tests that do not work with jax

* use pytest imports to skip

* pylint tests

* changelog

* take shots change from Christina's PR

* Update doc/releases/changelog-dev.md

Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>

* copy changes to autograd as well

* rename to indicate bool; slight autograd fixup

---------

Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>

* Treat identities as equivalent in `pauli.are_identical_pauli_words` (PennyLaneAI#4161)

* fix hamiltonian grouping indices bug

* Update doc/releases/changelog-dev.md

* Take wire ordering in the `wires` argument to `qml.density_matrix` into account (PennyLaneAI#4072)

* include wire ordering, test for that, raise error for broadcasting, test for that

* reduce

* changelog

* add test for qinfo transform

* more tests for math module

* lint math tests

* lint

* black

* introduce, use and test input_is_dm kwarg to reduced_dm

* tmp

* reverting

* seed fix

---------

Co-authored-by: Edward Jiang <34989448+eddddddy@users.noreply.github.com>

* CY inherits from ControlledOp (PennyLaneAI#4116)

`qml.CY` has been moved from `qml.ops.qubit.non_parametric_ops` to `qml.ops.op_math.controlled_ops`
  and now inherits from `qml.ops.op_math.ControlledOp`.
---------
Co-authored-by: Matthew Silverman <matthews@xanadu.ai>
Co-authored-by: Christina Lee <christina@xanadu.ai>

* Empty hamiltonians are compatible with `qml.pauli_sentence()` (PennyLaneAI#4171)

* fix ps rep for empty hamiltonian

* changelog

* Update doc/releases/changelog-dev.md

Co-authored-by: Utkarsh <utkarshazad98@gmail.com>

---------

Co-authored-by: Utkarsh <utkarshazad98@gmail.com>

* Update tests/interfaces/test_torch_qnode.py

Co-authored-by: Christina Lee <christina@xanadu.ai>

* Python 3.8 compatibility and increase num_directions, since spsa_grad, with num_directions=1, fails sometimes, depending on the seed.

* Fix failing tests

* Fix docs.

* Fix unsupported NoneType import

* Undo irrelevant change.

* Fix failing tests. Still not reliable.

* Fix tolerance issue with SPSA second derivative.

* Increase tolerance. This test has also been failing spontaneously on the master branch 3468885

* Switch to sampler_rng kwarg and fix tolerance issues.

* More migration to sampler_rng

* Migrate more tests to sampler_rng

* Migrate legacy tests to sampler_rng

* black

* Deprecated the sampler_seed argument

* black

* Increase tolerance for test_hamiltonian_expansion_finite_shots tests.

* Fix tol

* Pin autoray for CI

* Set num_directions=20 in all hamiltonian_expansion_finite_shots tests.

* Make black and pylint happy

* Set device seed for DQ2 tests.

* Add tests for new return type system.

* Fix bug

* Adapt dq2 tests for spsa

* Remove qml.disable_return()

* Change DQ2 tests to new seed setting system.

* Fix bug

* Fix failing tests. TF tests pass locally. Not sure what the problem is.

* Fix missing grad_kwarg

* black

* Increase tol

* Increase num_directions

* Apply suggestions from code review

Co-authored-by: David Wierichs <david.wierichs@xanadu.ai>

* Update pennylane/gradients/spsa_gradient.py

Co-authored-by: David Wierichs <david.wierichs@xanadu.ai>

* Copy TestRademacherSampler into new tests

* Make docs more precise and add tests for rng kwarg of samplers.

* black

* black

* Fix error message in _spsa_grad_legacy

* pylint

* Update changelog-dev.md

* black

* Increase num_directions for Hessian test.

---------

Co-authored-by: Christina Lee <christina@xanadu.ai>
Co-authored-by: Matthew Silverman <matthews@xanadu.ai>
Co-authored-by: Romain Moyard <rmoyard@gmail.com>
Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>
Co-authored-by: Olivia Di Matteo <dimatteo.olivia@protonmail.com>
Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca>
Co-authored-by: Christina Lee <chrissie.c.l@gmail.com>
Co-authored-by: Matthew Silverman <ma.silv11@gmail.com>
Co-authored-by: David Wierichs <david.wierichs@xanadu.ai>
Co-authored-by: Edward Jiang <34989448+eddddddy@users.noreply.github.com>
Co-authored-by: Utkarsh <utkarshazad98@gmail.com>
mlxd pushed a commit that referenced this pull request Aug 23, 2023
* Change seed setting in spsa_grad.

* Update changelog.

* Adapt tests. Note that lots of tests still set a global seed!

* Update pennylane/gradients/spsa_gradient.py

Co-authored-by: Christina Lee <christina@xanadu.ai>

* Update pennylane/gradients/spsa_gradient.py

Co-authored-by: Christina Lee <christina@xanadu.ai>

* use Shots class in gradients module (#4152)

* linting

* add num_copies property to shots

* change gradients to use new Shots class

* fix missing update in vjp

* fix stacking and single-shots in shot_adaptive

* remove unneeded cast to tuple

* type-hints and touch-ups

* code review feedback

* changelog

---------

Co-authored-by: Romain Moyard <rmoyard@gmail.com>

* Qutrit Rotations #2 (TRY) (#2846)

* Adding tests for tensor observables

* Added tests for tensor sample

* Updated tests

* Apply suggestions from code review

* Partition device apply ops test case.

* Run black

* Fix pylint

* Update pennylane/devices/default_qutrit.py

* black and pylint

* Update pennylane/devices/default_qutrit.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_non_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Updated test_default_qutrit.py

* Updated _apply_tadd documentation

* Added eigvals method for TSWAP

* Reverted TSWAP eigval changes

* Update tests/devices/test_default_qutrit.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update pennylane/devices/default_qutrit.py

Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca>

* Added TSWAP eigvals

* Updated changelog-dev.md to include GellMannObs

* Removed empty file

* Added linting comments

* Updated tests to use gate_data

* Updated test parameter names to be more accurate

* Remove unused file

* Updated GellMannObs doc-string

* Update changelog-dev.md

* Update tests/devices/test_default_qutrit.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/devices/test_default_qutrit.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/devices/test_default_qutrit.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update pennylane/ops/qutrit/observables.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Added changes to GellMann to address PR comments

* Updated test

* Reformatting

* Trying out changes to Gell-Mann docstring

* Updated Changelog

* Update pennylane/ops/qutrit/observables.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Testing LaTeX align

* Added non-diag tests

* Added diag, complex case for tensor sample

* Added example to doc string

* Fixed label test

* Update pennylane/ops/qutrit/observables.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update pennylane/ops/qutrit/observables.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/devices/test_default_qutrit.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/devices/test_default_qutrit.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Added tests for controlled qutrit unitary

* Fix broadcasting, finish tests for CQutritUnitary

* Added TRX and created skeleton files

* Adding tests for TRX

* Fixed broadcasting issue in controlled qutrit unitary

* Fixed broadcasting issue with ControlledQutritUnitary

* Fixed broadcasting issue in TRX

* Updated TRX documentation

* Added tests

* Added tests for TRX

* Removed unused imports

* Removed unused imports, linting changes

* Added TRX parameter frequencies

* Updated matrix dtype for TRX generator

* Added test for param frequencies

* Added param-shift capability for qutrit devices

* Updated changelog

* Update changelog

* Added change for TRX generator

* Updated utils.py to support higher dimensions

* Added tests for updated utils.sparse_hamiltonian

* Added Identity as supported obs

* Updated TRX docstring

* Update tests/ops/qutrit/test_qutrit_non_parametric_ops.py

Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca>

* Update pennylane/ops/qutrit/observables.py

Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca>

* Update pennylane/ops/qutrit/observables.py

Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca>

* Added ControlledQutritUnitary

* Update changelog-dev.md

* Removed empty files

* Update tests/ops/qutrit/test_qutrit_matrix_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_matrix_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_matrix_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_matrix_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Updated to address PR

* Fixed uncommented lines in test suite

* Added complex values to state

* Updated test_mixed_polarity_controls

* Fixed QutritUnitary._controlled

* Updated test_controlled for matrix ops

* Updated ControlledQutritUnitary._controlled

* Reformatting

* Update pennylane/ops/qutrit/matrix_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Updated ControlledQutritUnitary and tests

* Addressing PR review

* Updated sparse_hamiltonian, fixed TRX docstring

* Addressing PR review

* Refactoring

* Fixed changelog

* Update pennylane/devices/default_qutrit.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update pennylane/ops/qutrit/parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update pennylane/ops/qutrit/parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update pennylane/ops/qutrit/parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update pennylane/ops/qutrit/parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/test_qnode.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Reverted changes to sparse_hamiltonian

* Fixed sparse_hamiltonian test

* Updated changelog

* Updated TRX documentation

* Fixed generator

* Adding levels to sparse_hamiltonian

* Updated test sparse hamiltonian

* Fixed sparse hamiltonian test

* Fixed constant level kwarg

* Updated changelog, added test coverage

* Fixed coverage

* Updated test suite

* Updated files to address PR review

* Updated tests to include subspace error tests

* Added TRX tests for parameter shift

* Update doc/releases/changelog-dev.md

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update pennylane/utils.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update utils.py to remove trailing whitespace

* Updated to address PR review

* Fixed class/object confusion bug

* Testing changes to adjust lines changed in PR

* Fixing changes

* Fixing changes

* Resetting problem files

* Fixing changes

* updated TRX docs

* Fixed TRX docs

* Updated TRX docs

* Fixed PR too many lines changed issue

* Updated subspace error tests

* Tweaked THadamard docs to fix rendering

* Test dos2unix

* Fixed subspace testing

* Merge changes

* Started adding tests for grad

* Updated tests to parametrize diff-method

* Linted tests

* Fiex tests using in-place inversion

* Added diff tests

* Update pennylane/ops/qutrit/parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Update tests/ops/qutrit/test_qutrit_parametric_ops.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Fixed formatting

* Update pennylane/utils.py

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Updated TRY and tests

* Updated utils.py

* Fixed TRX generator

* Updated generator TRY

* Updated subspace validation for TRY

* Updated subspace validation

* Update pennylane/ops/qutrit/parametric_ops.py

Co-authored-by: Christina Lee <chrissie.c.l@gmail.com>

* Update pennylane/ops/qutrit/parametric_ops.py

Co-authored-by: Matthew Silverman <ma.silv11@gmail.com>

* Update pennylane/ops/qutrit/parametric_ops.py

Co-authored-by: Matthew Silverman <ma.silv11@gmail.com>

* Reverted `validate_subspace` changes

* Updated test

* Added parameter shift test

* Fixed test

* Update doc/releases/changelog-dev.md

* Update changelog

* Updated grad tests

* Apply suggestions from code review

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>

* Updated subspace docstring

---------

Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>
Co-authored-by: Olivia Di Matteo <dimatteo.olivia@protonmail.com>
Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca>
Co-authored-by: Christina Lee <chrissie.c.l@gmail.com>
Co-authored-by: Matthew Silverman <ma.silv11@gmail.com>

* jax integration for for DefaultQubit2 (#4137)

* copy-paste autograd test file

* port to jax in tests; update shots in jax interface

* add argnums when needed; skip tests that do not work with jax

* use pytest imports to skip

* pylint tests

* changelog

* take shots change from Christina's PR

* Update doc/releases/changelog-dev.md

Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>

* copy changes to autograd as well

* rename to indicate bool; slight autograd fixup

---------

Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>

* Treat identities as equivalent in `pauli.are_identical_pauli_words` (#4161)

* fix hamiltonian grouping indices bug

* Update doc/releases/changelog-dev.md

* Take wire ordering in the `wires` argument to `qml.density_matrix` into account (#4072)

* include wire ordering, test for that, raise error for broadcasting, test for that

* reduce

* changelog

* add test for qinfo transform

* more tests for math module

* lint math tests

* lint

* black

* introduce, use and test input_is_dm kwarg to reduced_dm

* tmp

* reverting

* seed fix

---------

Co-authored-by: Edward Jiang <34989448+eddddddy@users.noreply.github.com>

* CY inherits from ControlledOp (#4116)

`qml.CY` has been moved from `qml.ops.qubit.non_parametric_ops` to `qml.ops.op_math.controlled_ops`
  and now inherits from `qml.ops.op_math.ControlledOp`.
---------
Co-authored-by: Matthew Silverman <matthews@xanadu.ai>
Co-authored-by: Christina Lee <christina@xanadu.ai>

* Empty hamiltonians are compatible with `qml.pauli_sentence()` (#4171)

* fix ps rep for empty hamiltonian

* changelog

* Update doc/releases/changelog-dev.md

Co-authored-by: Utkarsh <utkarshazad98@gmail.com>

---------

Co-authored-by: Utkarsh <utkarshazad98@gmail.com>

* Update tests/interfaces/test_torch_qnode.py

Co-authored-by: Christina Lee <christina@xanadu.ai>

* Python 3.8 compatibility and increase num_directions, since spsa_grad, with num_directions=1, fails sometimes, depending on the seed.

* Fix failing tests

* Fix docs.

* Fix unsupported NoneType import

* Undo irrelevant change.

* Fix failing tests. Still not reliable.

* Fix tolerance issue with SPSA second derivative.

* Increase tolerance. This test has also been failing spontaneously on the master branch 3468885

* Switch to sampler_rng kwarg and fix tolerance issues.

* More migration to sampler_rng

* Migrate more tests to sampler_rng

* Migrate legacy tests to sampler_rng

* black

* Deprecated the sampler_seed argument

* black

* Increase tolerance for test_hamiltonian_expansion_finite_shots tests.

* Fix tol

* Pin autoray for CI

* Set num_directions=20 in all hamiltonian_expansion_finite_shots tests.

* Make black and pylint happy

* Set device seed for DQ2 tests.

* Add tests for new return type system.

* Fix bug

* Adapt dq2 tests for spsa

* Remove qml.disable_return()

* Change DQ2 tests to new seed setting system.

* Fix bug

* Fix failing tests. TF tests pass locally. Not sure what the problem is.

* Fix missing grad_kwarg

* black

* Increase tol

* Increase num_directions

* Apply suggestions from code review

Co-authored-by: David Wierichs <david.wierichs@xanadu.ai>

* Update pennylane/gradients/spsa_gradient.py

Co-authored-by: David Wierichs <david.wierichs@xanadu.ai>

* Copy TestRademacherSampler into new tests

* Make docs more precise and add tests for rng kwarg of samplers.

* black

* black

* Fix error message in _spsa_grad_legacy

* pylint

* Update changelog-dev.md

* black

* Increase num_directions for Hessian test.

---------

Co-authored-by: Christina Lee <christina@xanadu.ai>
Co-authored-by: Matthew Silverman <matthews@xanadu.ai>
Co-authored-by: Romain Moyard <rmoyard@gmail.com>
Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
Co-authored-by: Olivia Di Matteo <2068515+glassnotes@users.noreply.github.com>
Co-authored-by: Olivia Di Matteo <dimatteo.olivia@protonmail.com>
Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca>
Co-authored-by: Christina Lee <chrissie.c.l@gmail.com>
Co-authored-by: Matthew Silverman <ma.silv11@gmail.com>
Co-authored-by: David Wierichs <david.wierichs@xanadu.ai>
Co-authored-by: Edward Jiang <34989448+eddddddy@users.noreply.github.com>
Co-authored-by: Utkarsh <utkarshazad98@gmail.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