Support broadcasting in measure and measure_with_samples#4238
Merged
Support broadcasting in measure and measure_with_samples#4238
measure and measure_with_samples#4238Conversation
Contributor
|
Hello. You may have forgotten to update the changelog!
|
Contributor
Author
|
Changelog entry to come in the last PR of this series. |
Codecov Report
@@ Coverage Diff @@
## master #4238 +/- ##
========================================
Coverage 99.78% 99.78%
========================================
Files 352 352
Lines 31754 31882 +128
========================================
+ Hits 31686 31815 +129
+ Misses 68 67 -1
|
measure and measure_with_samples
albi3ro
reviewed
Jun 14, 2023
albi3ro
reviewed
Jun 14, 2023
Co-authored-by: Christina Lee <christina@xanadu.ai>
timmysilv
approved these changes
Jun 15, 2023
frederikwilde
pushed a commit
that referenced
this pull request
Jul 5, 2023
* Support broadcasting in state measurements * docs for is_state_batched * Support broadcasting in sample measurements * Apply suggestions from code review Co-authored-by: Christina Lee <christina@xanadu.ai> * black * black * Remove total_copies * fix --------- Co-authored-by: Christina Lee <christina@xanadu.ai>
PietropaoloFrisoni
added a commit
that referenced
this pull request
Oct 29, 2024
) **Context:** WIth `default.qubit`, parameter broadcasting does not work with `shadow_expval` (or `classical_shadow`) as the measurement process. These latest developments might be relevant for historical reasons: - In [this PR](#4238), support for parameter broadcasting was added for `measure` and `measure_with_samples` (presumably as an effort for the new device API). Specifically, a new keyword argument `is_state_batched` has been introduced to these functions to deal with the parameter broadcasting case. - In [this PR](#4162), the classical shadow measurement process was integrated into the new device API as well. A new logical branch was integrated into `measure_with_samples` adding a new `_measure_classical_shadow function`. This function did not receive the `is_state_batched argument`, so apparently supporting parameter broadcasting for classical shadows was not part of the requirements (the shortcut story was not linked so I cannot investigate further). - In [this PR](#4429), the `is_state_batched` argument has been added to `_measure_classical_shadow`, but support for parameter broadcasting was never implemented (the argument is unused). **Description of the Change:** We added an internal conditional quantum transform to `default.qubit` such that the `qml.transforms.broadcast_expand` is conditionally applied if `ShadowExpvalMP` or `ClassicalShadowMP` are found in the tape measurement process. **Benefits:** Now `default.qubit` supports (non-native) parameter broadcasting with shadow measurement processes. **Possible Drawbacks:** Since we are applying the `broadcast_expand` quantum transform, we are not supporting *native* parameter broadcasting, This should not be a big deal. **Related GitHub Issues:** #6301 **Related ShortCut Stories:** [sc-74387]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context:
Part of the development of the new qubit device in PennyLane.
Description of the Change:
Support broadcasting in the
measurefunction indevices/qubit/measure.pyand in themeasure_with_samplesfunction indevices/qubit/sampling.py. Add a new keyword argumentis_state_batchedthat tells these function if a batch dim exists. Integration withsimulateto come in a future PR.