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 an error in MottonenStatePreparation with qml.math.cast #1400

Merged
merged 15 commits into from
Jun 18, 2021

Conversation

antalszava
Copy link
Contributor

@antalszava antalszava commented Jun 9, 2021

Fixes a bug where using qml.MottonenStatePrepration resulted in an error due to no conversion between NumPy and Torch when using the Torch interface.

@antalszava antalszava changed the base branch from master to v0.16.0-rc0 June 17, 2021 21:19
@antalszava antalszava added this to the v0.16.0 milestone Jun 18, 2021
@codecov
Copy link

codecov bot commented Jun 18, 2021

Codecov Report

❗ No coverage uploaded for pull request base (v0.16.0-rc0@08ff413). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@              Coverage Diff               @@
##             v0.16.0-rc0    #1400   +/-   ##
==============================================
  Coverage               ?   98.23%           
==============================================
  Files                  ?      160           
  Lines                  ?    11936           
  Branches               ?        0           
==============================================
  Hits                   ?    11725           
  Misses                 ?      211           
  Partials               ?        0           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 08ff413...1b4259c. Read the comment docs.

@rmoyard rmoyard marked this pull request as ready for review June 18, 2021 15:38
.github/CHANGELOG.md Outdated Show resolved Hide resolved
rmoyard and others added 4 commits June 18, 2021 18:01
Co-authored-by: antalszava <antalszava@gmail.com>
…ep.py

Co-authored-by: antalszava <antalszava@gmail.com>
…ep.py

Co-authored-by: antalszava <antalszava@gmail.com>
…ep.py

Co-authored-by: antalszava <antalszava@gmail.com>
rmoyard and others added 2 commits June 18, 2021 18:02
Co-authored-by: antalszava <antalszava@gmail.com>
…ep.py

Co-authored-by: antalszava <antalszava@gmail.com>
@qml.qnode(dev, interface="torch")
def circuit(inputs, weights):
qml.templates.MottonenStatePreparation(inputs, wires=[0, 1])
qml.templates.StronglyEntanglingLayers(weights, wires=[0, 1])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Couple of thoughts here:

  • Looks we can get away with not having qml.templates.StronglyEntanglingLayers in the test as the error can be reproduced without it,
  • Maybe worth also checking the output of the circuit execution. This can be done by making inputs be something simple like torch.tensor([0.5,0,0,0.5], requires_grad=True), so that we can assert the probabilities well

@rmoyard rmoyard self-requested a review June 18, 2021 16:46
@rmoyard rmoyard merged commit 277b97e into v0.16.0-rc0 Jun 18, 2021
@rmoyard rmoyard deleted the mottonen_cast_fix branch June 18, 2021 23:30
antalszava added a commit that referenced this pull request Jun 22, 2021
* Review of new features and their documentation for 0.16.0 release (#1409)

* Correction Fourier and Kernel

* Typo cycle _inner_out_flow

* Autoray backend corrections for doc.

* 1380 typo jax

* 1316 Non appearing doc.

* 1316 import apply_control_Q.

* is_returned_observable private

* Changelog edit

* Init for apply_controlled_q

* Typo

* Remove changelog.

* Ensure that the IsingXX and IsingZZ gates are differentiable (#1390)

* Tensor flow

* Ising operations for autograd, jax and tensor flow.

* Test ising xx autograd

* Add test for IsingXX

* Typo IsingXX

* All tests pass

* Linting and black.

* Fix documentation.

* Docstrings.

* Typo indent.

* Update tests/interfaces/test_qnode_jax.py

Co-authored-by: antalszava <antalszava@gmail.com>

* Move tests to folder test_qubits_ops.

* Changelog modified.

* Add support for adjoint method.

* Update tests/ops/test_qubit_ops.py

Co-authored-by: antalszava <antalszava@gmail.com>

* Update tests/ops/test_qubit_ops.py

Co-authored-by: antalszava <antalszava@gmail.com>

* Update tests/ops/test_qubit_ops.py

Co-authored-by: antalszava <antalszava@gmail.com>

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

* Revert "Merge branch 'master' into v0.16.0-rc0"

This reverts commit 383f384, reversing
changes made to 0ef82e6.

* Warnings for adjoint diff with finite shots (#1406)

* warnings for adjoint diff finite shots

* Update .github/CHANGELOG.md

* adding reversible

* add extra integration tests

* changelog

* Apply suggestions from code review

Co-authored-by: antalszava <antalszava@gmail.com>

Co-authored-by: antalszava <antalszava@gmail.com>

* Copy for `ControlledQubitUnitary` (#1411)

* test copy method, fix copy for controlledqubitunitary

* changelog

* change copy method

* Fix an error in `MottonenStatePreparation` with `qml.math.cast` (#1400)

* qml.math.cast

* Add test and update changelog.

* Typo.

* Import torch change.

* Update pennylane/templates/state_preparations/mottonen.py

Co-authored-by: antalszava <antalszava@gmail.com>

* Update tests/templates/test_state_preparations/test_mottonen_state_prep.py

Co-authored-by: antalszava <antalszava@gmail.com>

* Update tests/templates/test_state_preparations/test_mottonen_state_prep.py

Co-authored-by: antalszava <antalszava@gmail.com>

* Update tests/templates/test_state_preparations/test_mottonen_state_prep.py

Co-authored-by: antalszava <antalszava@gmail.com>

* Update .github/CHANGELOG.md

Co-authored-by: antalszava <antalszava@gmail.com>

* Update tests/templates/test_state_preparations/test_mottonen_state_prep.py

Co-authored-by: antalszava <antalszava@gmail.com>

* Tensor to array.

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

* Update parameters (#1420)

* Fixes `mitigate_depolarizing_noise` to not raise a warning for `true_divide` (#1417)

* fix division issues that might arise with the split version of depolarizing noise mitigation

* Add test

* format

* update to raise error; test too

* formatting

* allow =<; error when non-specified method; add tests

* adjust checks; format

* adjust message; test

* adjust message; format

* test case for average; format

* Update pennylane/kernels/postprocessing.py

Co-authored-by: Johannes Jakob Meyer <46889760+johannesjmeyer@users.noreply.github.com>

* Update pennylane/kernels/postprocessing.py

* Update tests/kernels/test_kernels.py

Co-authored-by: Johannes Jakob Meyer <46889760+johannesjmeyer@users.noreply.github.com>

* Fix typo for Pauli group in CHANGELOG.

* V0.16.0 bump (#1414)

* changelog new features sections

* version bump, organize changelog

* qchem version

* contributors list

* changelog and remove assign bugs for Unitary HACK

* qchem changelog

* updated contributors; qchem intro PR item

* Update .github/CHANGELOG.md

Co-authored-by: Nathan Killoran <co9olguy@users.noreply.github.com>

* depth=1 for ControlledCX

* Update module headers based on Josh's suggestion

* shorten kernels example, indentation care

* qaoa and pauli group headers

* link qaoa cycle

* no mixer

* reorder qmc

* specs rephrase

* reorganize new ops as suggested

* rephrase custom observable support

* move around items as suggested

* Update .github/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update .github/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update code example as suggested

* Update .github/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* separate python and pycon as suggested

* Update .github/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update .github/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update .github/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update .github/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update .github/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* pycon

* perf improvement comment adjoint

* group Projector improvement with main addition

* groupped decomposition entries

* no CSWAP separately

* further decomposition entries

* Update .github/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update .github/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* add ongoing deprecations to Breaking changes

* Add QMC transform example

* Update QMC in changelog (#1422)

* Update changelog

* Edit

* Projector example

* add example for diff observable change

* bracket

* wires, num_wires and dev for kernels example

* pauli group typo fix

* add prefix qml.utils when calling sparse_hamiltonian

* custom obs diff example adjust

* update QMC docs to use qml.specs

* Update .github/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update .github/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update .github/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update .github/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update qchem/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* shorten def of SpecialObject; add disclaimer

Co-authored-by: Nathan Killoran <co9olguy@users.noreply.github.com>
Co-authored-by: Josh Izaac <josh146@gmail.com>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>

* Update .github/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update pennylane/_version.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* version depends on the _version.py file

* Update doc/introduction/operations.rst

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update pennylane/devices/default_qubit.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update pennylane/devices/tests/test_gates.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* isingyy in test

* Update pennylane/devices/tests/test_gates.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* isingyy is ops

* Update qchem/pennylane_qchem/_version.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update pennylane/ops/qubit.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update qchem/CHANGELOG.md

Co-authored-by: Josh Izaac <josh146@gmail.com>

* isingyy is default.qubit tests

* Update tests/ops/test_qubit_ops.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update tests/tape/test_reversible.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Update tests/ops/test_qubit_ops.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* isingyy decomp test

* correct order of tests

* new lines in ops

Co-authored-by: Romain <rmoyard@gmail.com>
Co-authored-by: Christina Lee <christina@xanadu.ai>
Co-authored-by: Josh Izaac <josh146@gmail.com>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Johannes Jakob Meyer <46889760+johannesjmeyer@users.noreply.github.com>
Co-authored-by: Olivia Di Matteo <dimatteo.olivia@gmail.com>
Co-authored-by: Nathan Killoran <co9olguy@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

2 participants