-
Notifications
You must be signed in to change notification settings - Fork 604
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
AmplitudeEmbedding inherits from StatePrep #4583
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #4583 +/- ##
==========================================
- Coverage 99.64% 99.64% -0.01%
==========================================
Files 376 376
Lines 33247 33238 -9
==========================================
- Hits 33128 33119 -9
Misses 119 119
☔ View full report in Codecov by Sentry. |
[sc-44390] |
# Conflicts: # tests/tape/test_tape.py
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 good, just a few small comments then happy to approve. Also for the tests, the doc-strings and test names should be changed to reflect the new thing we are testing/
# Conflicts: # doc/releases/changelog-dev.md
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.
Nice, thanks for putting up with my comments! Happy to merge for now and we can revisit and deprecate this pipeline once we swap the devices
**Context:** While porting DQ2, the merge_amplitude_embedding tests were failing because `AmplitudeEmbedding` was being decomposed. I figured that since it behaves like a `StatePrep` op, we should make it inherit from it and gain the benefit! **Description of the Change:** `AmplitudeEmbedding` inherits from `StatePrep`, gaining its `state_vector` implementation and various properties. The only real change now that it inherits from `StatePrep` is that it will return True for `isinstance(op, StatePrep)` checks but I think this is not a problem. **Benefits:** `AmplitudeEmbedding` will behave the same on DQ2 as it did on DQL (it would decompose once to `StatePrep`, then be "supported" by DQL, and then it would have the custom apply function - on DQ2, it was decomposing all the way, and then I hit a bug where it thought it could support batching but the full decomposition disagreed). I confirmed locally that all changed tests, `test_amplitude.py`, and `test_merge_amplitude_embeddings.py` all passed with DQ2 as well. **Possible Drawbacks:** If someone somehow calls `expand_tape_state_prep` with `AmplitudeEmbedding` and `skip_first=False`, it will decompose once to a `StatePrep` and call it a day. This is reflected in tests, but I figured it shouldn't be too much of a concern... users don't even have a way to set `skip_first` to False (...yet?)
Context:
While porting DQ2, the merge_amplitude_embedding tests were failing because
AmplitudeEmbedding
was being decomposed. I figured that since it behaves like aStatePrep
op, we should make it inherit from it and gain the benefit!Description of the Change:
AmplitudeEmbedding
inherits fromStatePrep
, gaining itsstate_vector
implementation and various properties.The only real change now that it inherits from
StatePrep
is that it will return True forisinstance(op, StatePrep)
checks but I think this is not a problem.Benefits:
AmplitudeEmbedding
will behave the same on DQ2 as it did on DQL (it would decompose once toStatePrep
, then be "supported" by DQL, and then it would have the custom apply function - on DQ2, it was decomposing all the way, and then I hit a bug where it thought it could support batching but the full decomposition disagreed). I confirmed locally that all changed tests,test_amplitude.py
, andtest_merge_amplitude_embeddings.py
all passed with DQ2 as well.Possible Drawbacks:
If someone somehow calls
expand_tape_state_prep
withAmplitudeEmbedding
andskip_first=False
, it will decompose once to aStatePrep
and call it a day. This is reflected in tests, but I figured it shouldn't be too much of a concern... users don't even have a way to setskip_first
to False (...yet?)