-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Update metadata of Primitives V2 #12784
Conversation
One or more of the following people are relevant to this code:
|
Pull Request Test Coverage Report for Build 10164614695Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
989e4f6
to
deee983
Compare
@@ -238,7 +238,6 @@ def _preprocess_pub(self, pub: EstimatorPub) -> _PreprocessedData: | |||
param_indices = np.fromiter(np.ndindex(param_shape), dtype=object).reshape(param_shape) | |||
bc_param_ind, bc_obs = np.broadcast_arrays(param_indices, observables) | |||
|
|||
# calculate expectation values for each pair of parameter value set and pauli |
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.
Removed a wrong and unnecessary comment
FYI: neko is failing due to #12833 |
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.
1 small comment but not a blocker.
@@ -213,7 +219,9 @@ def _postprocess_pub( | |||
meas = { | |||
item.creg_name: BitArray(arrays[item.creg_name], item.num_bits) for item in meas_info | |||
} | |||
return SamplerPubResult(DataBin(**meas, shape=shape), metadata={}) | |||
return SamplerPubResult( | |||
DataBin(**meas, shape=shape), metadata={"circuit_metadata": circuit_metadata} |
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.
Shouldn't this have shots
too? Given EstimatorPubResult
has target_precision
. We should update the QRT Sampler to also return shots.
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.
Thank you for reviewing this PR.
Qiskit Runtime Sampler V2 does not have shots
in the metadata because it can be obtained by result[i].data.{creg}.num_shots
. I removed shots
from the metadata of StatevectorSampler
in this PR because of the same reason.
On the other hand, Estimator V2 has shots
in the metadata.
SamplerV2 of qiskit-ibm-runtime returns the following metadata with the default option.
result.metadata = {'version': 2}
result[i].metadata = {'circuit_metadata': {}}
EstimatorV2 of qiskit-ibm-runtime returns the following metadata
result.metadata = {'dynamical_decoupling': {'enable': False, 'sequence_type': 'XX', 'extra_slack_distribution': 'middle', 'scheduling_method': 'alap'}, 'twirling': {'enable_gates': False, 'enable_measure': True, 'num_randomizations': 'auto', 'shots_per_randomization': 'auto', 'interleave_randomizations': True, 'strategy': 'active-accum'}, 'resilience': {'measure_mitigation': True, 'zne_mitigation': False, 'pec_mitigation': False}, 'version': 2}
result[i].metadata = {'shots': 128, 'target_precision': 0.1, 'circuit_metadata': {}, 'resilience': {}, 'num_randomizations': 2}
Adding PR to the queue after approval and offline confirmation from @jyu00 |
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.
LGTM (also based on offline discussion with @t-imamichi and @jyu00)
099189b
to
f29a067
Compare
* update metadata of primitives v2 * remove `shots` and add reno * add version * add shots to SamplerV2 metadata * udpate reno --------- Co-authored-by: Elena Peña Tapia <[email protected]> (cherry picked from commit 68687d3)
* update metadata of primitives v2 * remove `shots` and add reno * add version * add shots to SamplerV2 metadata * udpate reno --------- Co-authored-by: Elena Peña Tapia <[email protected]> (cherry picked from commit 68687d3) Co-authored-by: Takashi Imamichi <[email protected]>
* update metadata of primitives v2 * remove `shots` and add reno * add version * add shots to SamplerV2 metadata * udpate reno --------- Co-authored-by: Elena Peña Tapia <[email protected]>
Summary
This PR updates the metadata of Primitives V2 to be compatible with that of real devices.
precision
->target_precision
shots
shots
If I need to keep the compatibility of the metadata within Qiskit 1.*, I will revert the rename and removal.
I'm wondering
StatevectorEstimator
because it does not compute expectation values directly from the state vector not based on shots. So, there is not relevant information about shots and I did not addshots
toStatevectorEstimator
yet. If necessary, I can add something likeshots=inf
, for example.Addresses Qiskit/qiskit-ibm-runtime#1724
Summary of discussion:
1-a. Shall we add
shots=inf
toStatevectorEstimator
or not addshots
?precision
ofStatevectorEstimator
andshots
ofStatevectorSampler
.TODO
Details and comments
SamplerV2 of qiskit-ibm-runtime returns the following metadata
EstimatorV2 of qiskit-ibm-runtime returns the following metadata