Add the capability to accept group Paulis that can be measured using same measurement results#7236
Conversation
…een measured using the same measurement results
|
Hey @eliottrosenberg and @NoureldinYosri if you could take a look at this. Thanks! |
eliottrosenberg
left a comment
There was a problem hiding this comment.
LGTM! Thanks, @ddddddanni!
| return op1 == op2 | ||
|
|
||
|
|
||
| def _are_two_qwc( |
There was a problem hiding this comment.
please use a more descriptive name
| first_value = next(iter(circuits_to_pauli.values())) | ||
| for circuit, pauli_strs_list in circuits_to_pauli.items(): | ||
| if not isinstance(pauli_strs_list, list): | ||
| raise TypeError( |
There was a problem hiding this comment.
this is too restricitve ... what if the variable is a tuple or iterator? same below
There was a problem hiding this comment.
Done! Change to check sequence instead of list.
| for circuit, paulis in circuits_to_pauli.items(): | ||
| normalized_circuits_to_pauli[circuit] = [[ps] for ps in paulis] # type: ignore[list-item] | ||
| return normalized_circuits_to_pauli | ||
| return circuits_to_pauli # type: ignore |
There was a problem hiding this comment.
why are all these ignore statements here?
There was a problem hiding this comment.
Done! I use some cast to make the type as expected.
NoureldinYosri
left a comment
There was a problem hiding this comment.
thanks @ddddddanni
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7236 +/- ##
========================================
Coverage 98.67% 98.67%
========================================
Files 1108 1108
Lines 96220 96407 +187
========================================
+ Hits 94942 95129 +187
Misses 1278 1278 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…same measurement results (#7236) * Modify the pauli string measurement tool to allow a group of paulis been measured using the same measurement results * Add more tests and fix some code * Fix format * Fix type * Fix lint * Make changes based on @NoureldinYosri's comments. * Fix format and coverage. Also optimize group pauli tests to make them finish quicker. --------- Co-authored-by: Noureldin <noureldinyosri@google.com>
…same measurement results (quantumlib#7236) * Modify the pauli string measurement tool to allow a group of paulis been measured using the same measurement results * Add more tests and fix some code * Fix format * Fix type * Fix lint * Make changes based on @NoureldinYosri's comments. * Fix format and coverage. Also optimize group pauli tests to make them finish quicker. --------- Co-authored-by: Noureldin <noureldinyosri@google.com>
…uli_strings``` method (#7416) [PR #7236](#7236) adds the feature to measure groups of qubit-wise-commuting Pauli operators simultaneously. However, the current implementation generates a separate readout circuit for each individual Pauli operator within a group. This leads to non-simultaneous measurements, which is corrected in this PR.
…uli_strings``` method (quantumlib#7416) [PR quantumlib#7236](quantumlib#7236) adds the feature to measure groups of qubit-wise-commuting Pauli operators simultaneously. However, the current implementation generates a separate readout circuit for each individual Pauli operator within a group. This leads to non-simultaneous measurements, which is corrected in this PR.
…uli_strings``` method (quantumlib#7416) [PR quantumlib#7236](quantumlib#7236) adds the feature to measure groups of qubit-wise-commuting Pauli operators simultaneously. However, the current implementation generates a separate readout circuit for each individual Pauli operator within a group. This leads to non-simultaneous measurements, which is corrected in this PR.
This PR introduces an optimization to the tool responsible for measuring expectation values of Pauli strings (the tool was added in #7067). Previously, each Pauli string required separate measurement results for expectation calculation. By allowing gwc Pauli strings as a group, the tool can now measure the expectation values for multiple gwc pauli strings using a single set of measurement results.