[BUGFIX] shadow_expval doesn't work with parameter broadcasting#6464
Merged
PietropaoloFrisoni merged 5 commits intov0.39.0-rc0from Oct 29, 2024
Merged
Conversation
Contributor
|
Hello. You may have forgotten to update the changelog!
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## v0.39.0-rc0 #6464 +/- ##
==============================================
Coverage ? 99.38%
==============================================
Files ? 452
Lines ? 42797
Branches ? 0
==============================================
Hits ? 42535
Misses ? 262
Partials ? 0 ☔ View full report in Codecov by Sentry. |
mudit2812
reviewed
Oct 29, 2024
Contributor
mudit2812
left a comment
There was a problem hiding this comment.
Looks good to me. I don't think there is a way around dispatching pre-processing to the device, but this PR only makes broadcasting compatible with shadow measurements if using default.qubit. We should probably specify that in the changelog.
mudit2812
approved these changes
Oct 29, 2024
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: WIth
default.qubit, parameter broadcasting does not work withshadow_expval(orclassical_shadow) as the measurement process.These latest developments might be relevant for historical reasons:
In this PR, support for parameter broadcasting was added for
measureandmeasure_with_samples(presumably as an effort for the new device API). Specifically, a new keyword argumentis_state_batchedhas been introduced to these functions to deal with the parameter broadcasting case.In this PR, the classical shadow measurement process was integrated into the new device API as well. A new logical branch was integrated into
measure_with_samplesadding a new_measure_classical_shadow function. This function did not receive theis_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, the
is_state_batchedargument 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.qubitsuch that theqml.transforms.broadcast_expandis conditionally applied ifShadowExpvalMPorClassicalShadowMPare found in the tape measurement process.Benefits: Now
default.qubitsupports (non-native) parameter broadcasting with shadow measurement processes.Possible Drawbacks: Since we are applying the
broadcast_expandquantum transform, we are not supporting native parameter broadcasting, This should not be a big deal.Related GitHub Issues: #6301
Related ShortCut Stories: [sc-74387]