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

default.qubit returns the new DefaultQubit device #4436

Merged
merged 112 commits into from
Sep 20, 2023

Conversation

timmysilv
Copy link
Contributor

@timmysilv timmysilv commented Aug 3, 2023

Note: kindly ignore the codecov failure, it seems totally unrelated to this PR.

Context:
It's time for qml.device("default.qubit") to return the new device (look, no wires!).

Description of the Change:

  • 99% of this PR is changing dev.batch_execute to dev.execute
  • I am sorry about all the pylint changes - it’s from before I silenced them
  • I couldn’t keep track but there were some little things that we asserted didn’t work, but now they do! Like custom wires with some measurement processes
  • test_state.py used to try to test different dtypes, but the returned state should now always be complex, so that's what I test for.
  • One stupid qcut torch test fails on CI only… idk why. it just says UNSUPPORTED DTYPE (that's it because it's jit-compiled)
  • I changed math.size for tensorflow because autoray changed it in 0.6.4 (I was still on 0.6.3 locally), but we actually want to use the base tf.size(x)

Test formatting changes:

  • Duplicated tests in test_hadamard_gradient.py for legacy devices
  • Any test that used default.qubit.some_interface has been parametrized to also test with default.qubit to make sure interface-specific stuff also works with DQ2
  • test_qnode.py uses legacy because it’s deeply steeped in legacy
  • test_vqe.py uses the new device but the results are nonsense. I commented the actual expected results out
  • Pulse and qchem tests are being fixed in other PRs
  • test_return_types.py uses legacy - test_return_types_dq2.py is a copy-paste with DQ2
  • The things in test_tensor_measurements.py just felt unnecessary and too hard to move over

Benefits:
We use the new device!

Possible Drawbacks:
3 things that have changed afaik:

  • Non-hermitian observables fail hard now, still needs investigation
  • expval(SparseHamiltonian) used to fail nicely, now it raises a DiagGatesUndefined error
  • qml.Snapshot() instances are manually spotted and skipped while doing adjoint_jacobian (when diff_method="adjoint")

pennylane/qnode.py Outdated Show resolved Hide resolved
tests/test_qubit_device.py Outdated Show resolved Hide resolved
@timmysilv timmysilv requested a review from a team September 18, 2023 20:00
@timmysilv timmysilv marked this pull request as ready for review September 19, 2023 19:03
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.

Fantastic work 🎉 So excited to have this finally here. 🚀

For the code-cov issues, I am willing to override, but let's mark them down to investigate after this PR goes through.

For the qcut thing, I am still rather curious what is happening, but indulging my curiosity is not worth holding up any of the work we need to do. It can also be marked as "Further investigation for when we have time". If we ever actually have time for something like that.

@albi3ro albi3ro merged commit c6542b4 into master Sep 20, 2023
36 checks passed
@albi3ro albi3ro deleted the replace-dq-entry-with-dq2 branch September 20, 2023 19:19
mudit2812 pushed a commit that referenced this pull request Sep 20, 2023
Note: kindly ignore the codecov failure, it seems totally unrelated to
this PR.

**Context:**
It's time for `qml.device("default.qubit")` to return the new device
(look, no wires!).

**Description of the Change:**
- 99% of this PR is changing `dev.batch_execute` to `dev.execute`
- I am sorry about all the pylint changes - it’s from before I silenced
them
- I couldn’t keep track but there were some little things that we
asserted didn’t work, but now they do! Like custom wires with some
measurement processes
- `test_state.py` used to try to test different dtypes, but the returned
state should now _always_ be complex, so that's what I test for.
- One stupid qcut torch test fails on CI only… idk why. it just says
`UNSUPPORTED DTYPE` (that's it because it's jit-compiled)
- I changed `math.size` for tensorflow because autoray [changed
it](jcmgray/autoray@58f02d5)
in 0.6.4 (I was still on 0.6.3 locally), but we actually want to use the
base `tf.size(x)`

Test formatting changes:
- Duplicated tests in `test_hadamard_gradient.py` for legacy devices
- Any test that used `default.qubit.some_interface` has been
parametrized to also test with `default.qubit` to make sure
interface-specific stuff also works with DQ2
- test_qnode.py uses legacy because it’s deeply steeped in legacy
- test_vqe.py uses the new device but the results are nonsense. I
commented the actual expected results out
- Pulse and qchem tests are being fixed in other PRs
- test_return_types.py uses legacy - test_return_types_dq2.py is a
copy-paste with DQ2
- The things in `test_tensor_measurements.py` just felt unnecessary and
too hard to move over

**Benefits:**
We use the new device!

**Possible Drawbacks:**
3 things that have changed afaik:
- Non-hermitian observables fail hard now, still needs investigation
- `expval(SparseHamiltonian)` used to fail nicely, now it raises a
`DiagGatesUndefined` error
- `qml.Snapshot()` instances are manually spotted and skipped while
doing `adjoint_jacobian` (when `diff_method="adjoint"`)

---------

Co-authored-by: Christina Lee <christina@xanadu.ai>
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.

3 participants