Add process_expectation_values_pea#2948
Conversation
|
The extrapolation I/O changes were moved to a separate PR which will need to be merged first - #3000 (the tests will fail until this PR will be merged, but they pass combined with this PR code) |
…hods (Qiskit#3000) ### Summary Change the extrapolation input and output to align with the flow of the EM methods. ### Details and comments Related to Qiskit#2948 and Qiskit#2953 ### AI/LLM disclosure - [ ] I didn't use LLM tooling, or only used it privately. - [ ] I used the following tool to help write this PR description: - [X] I used the following tool to generate or modify code: bob --------- Co-authored-by: TsafrirA <113579969+TsafrirA@users.noreply.github.com>
TsafrirA
left a comment
There was a problem hiding this comment.
The code changes look good!
I left some nitpicks about doc strings and validations. The tests covering the post processing are essentially duplicated. We need to leave just one set of tests in.
(I stumbled upon #3037 while reviewing, but it's beyond the scope of this PR)
| pec_gammas = post_processor_data.get("pec_gammas", None) | ||
|
|
||
| # Extract pea mitigation data if present | ||
| pea_noise_factors = post_processor_data.get("pea_noise_factors", None) |
There was a problem hiding this comment.
At no point do you verify that pea_noise_factors and extrapolated_noise_factors are not None (when PEA is enabled). It's not clear to me how it passes static type checks.
|
|
||
|
|
||
| @ddt | ||
| class TestProcessExpectationValuesPEA(unittest.TestCase): |
There was a problem hiding this comment.
This class and TestCreatePubResultPea overlap completely.
What we did with PEC, was leaving just one set of tests.
There was a problem hiding this comment.
I removed the TestCreatePubResultPea tests
| # Shape: (num_randomizations, num_noise_scales, num_configs, shots, num_bits) | ||
| # where num_configs is the total number of (param_index, basis) pairs | ||
| raise ValueError(f"``item_result['_meas']`` has ``{data.ndim}`` axes, expected ``5``.") | ||
|
|
There was a problem hiding this comment.
Do we want to verify that the number of noise scales in the data is the same as in passthrough data?
There was a problem hiding this comment.
I added such check :)
process_expectation_values_pea
Summary
Add a post-process function to calculate the extrapolated expectation values when using PEA EM method.
Details and comments
Fixes #2947
AI/LLM disclosure