-
Notifications
You must be signed in to change notification settings - Fork 578
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
Register ParameterizedEvolution #4598
Conversation
# Conflicts: # tests/devices/test_default_qubit_legacy.py
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #4598 +/- ##
==========================================
- Coverage 99.64% 99.64% -0.01%
==========================================
Files 375 375
Lines 33331 33370 +39
==========================================
+ Hits 33214 33252 +38
- Misses 117 118 +1
☔ View full report in Codecov by Sentry. |
Hello. You may have forgotten to update the changelog!
|
[sc-44329] |
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.
looks great! just left some comments about batching and import errors, but the rest looks nice 🕴️ also - don't forget a changelog entry!
to fix coverage issues, can you add an integration test that uses the new DQ and custom wires (eg. copy-paste one with regular wires and change them to custom ones like ['a', 'b', 'c']
). if you wanna add an explicit test for ParametrizedEvolution.map_wires
and double-check the ParametrizedHamiltonian
s on it also get mapped, it wouldn't hurt :p
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.
This looks good to me. Just needs the doc string for the ParametrizedEvolution
dispatcher to be updated, and there's also the question about broadcasting. Once resolved and tests are added for coverage, I'm ready to approve.
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.
fantastic! (pls merge the pending suggestions before merging but otherwise looks ready to go )
# Conflicts: # doc/releases/changelog-dev.md
Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
**Context:** On the old device API, a `ParametrizedEvolution` uses the default `apply_operation` behaviour if it is preferable to evolve the matrix and apply (small matrix on a large state), but has special handling for if the matrix gets bigger (specifically, if the wires for the matrix exceed half the wires for the state, it evolves the state instead). Adding this made things much faster and people were very happy. **Description of the Change:** Adds the same behaviour here, now based on the size of the state instead of the number of device wires. **Benefits:** Presumably confers the speedups observed on DQL to DQ2. **Possible Drawbacks:** I tested whether the correct function was called based on the number of calls to `math.einsum`, because `mocker.spy` can't access the `devices.qubit.apply_operation` module due to ambiguity between the module and the function of the same name. It's the best thing I could come up with. It does not seem very reliable if anything changes in the future. --------- Co-authored-by: Matthew Silverman <matthews@xanadu.ai> Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
Context:
On the old device API, a
ParametrizedEvolution
uses the defaultapply_operation
behaviour if it is preferable to evolve the matrix and apply (small matrix on a large state), but has special handling for if the matrix gets bigger (specifically, if the wires for the matrix exceed half the wires for the state, it evolves the state instead). Adding this made things much faster and people were very happy.Description of the Change:
Adds the same behaviour here, now based on the size of the state instead of the number of device wires.
Benefits:
Presumably confers the speedups observed on DQL to DQ2.
Possible Drawbacks:
I tested whether the correct function was called based on the number of calls to
math.einsum
, becausemocker.spy
can't access thedevices.qubit.apply_operation
module due to ambiguity between the module and the function of the same name. It's the best thing I could come up with. It does not seem very reliable if anything changes in the future.