-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Update metadata of Primitives V2 #12784
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
Changes from 4 commits
b6e77d3
deee983
c3449f1
1e71a43
57e5ed4
f29a067
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,7 +155,7 @@ def _run(self, pubs: list[SamplerPub]) -> PrimitiveResult[SamplerPubResult]: | |
# reconstruct the result of pubs | ||
for i, pub_result in zip(lst, pub_results): | ||
results[i] = pub_result | ||
return PrimitiveResult(results) | ||
return PrimitiveResult(results, metadata={"version": 2}) | ||
|
||
def _run_pubs(self, pubs: list[SamplerPub], shots: int) -> list[SamplerPubResult]: | ||
"""Compute results for pubs that all require the same value of ``shots``.""" | ||
|
@@ -183,7 +183,12 @@ def _run_pubs(self, pubs: list[SamplerPub], shots: int) -> list[SamplerPubResult | |
end = start + bound.size | ||
results.append( | ||
self._postprocess_pub( | ||
result_memory[start:end], shots, bound.shape, meas_info, max_num_bytes | ||
result_memory[start:end], | ||
shots, | ||
bound.shape, | ||
meas_info, | ||
max_num_bytes, | ||
pub.circuit.metadata, | ||
) | ||
) | ||
start = end | ||
|
@@ -197,6 +202,7 @@ def _postprocess_pub( | |
shape: tuple[int, ...], | ||
meas_info: list[_MeasureInfo], | ||
max_num_bytes: int, | ||
circuit_metadata: dict, | ||
) -> SamplerPubResult: | ||
"""Converts the memory data into an array of bit arrays with the shape of the pub.""" | ||
arrays = { | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this have There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 SamplerV2 of qiskit-ibm-runtime returns the following metadata with the default option.
EstimatorV2 of qiskit-ibm-runtime returns the following metadata
|
||
) | ||
|
||
|
||
def _analyze_circuit(circuit: QuantumCircuit) -> tuple[list[_MeasureInfo], int]: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
features_primitives: | ||
- | | ||
The metadata of Primitives V2 implementations, i.e., :class:`.StatevectorSampler`, | ||
:class:`.StatevectorEstimator`, :class:`.BackendSamplerV2` and :class:`.BackendEstimatorV2`, | ||
has been updated to match that of IBM quantum devices. |
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