-
Notifications
You must be signed in to change notification settings - Fork 575
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
Conversation
Codecov Report
@@ 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.
|
tests/templates/test_state_preparations/test_mottonen_state_prep.py
Outdated
Show resolved
Hide resolved
tests/templates/test_state_preparations/test_mottonen_state_prep.py
Outdated
Show resolved
Hide resolved
tests/templates/test_state_preparations/test_mottonen_state_prep.py
Outdated
Show resolved
Hide resolved
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>
tests/templates/test_state_preparations/test_mottonen_state_prep.py
Outdated
Show resolved
Hide resolved
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]) |
There was a problem hiding this comment.
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 liketorch.tensor([0.5,0,0,0.5], requires_grad=True)
, so that we can assert the probabilities well
* 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>
Fixes a bug where using
qml.MottonenStatePrepration
resulted in an error due to no conversion between NumPy and Torch when using the Torch interface.