Skip to content
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

Add simulator_metadata in metadata of SamplerV2 #2109

Merged
merged 4 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion qiskit_aer/primitives/sampler_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def _run_pub(self, pub: SamplerPub) -> PubResult:
for item in meas_info
}

metadata = {"shots": pub.shots}
if qargs:
circuit.measure_all()
result = self._backend.run(
Expand All @@ -181,6 +182,7 @@ def _run_pub(self, pub: SamplerPub) -> PubResult:
for item in meas_info:
ary = _samples_to_packed_array(samples_array, item.num_bits, item.qreg_indices)
arrays[item.creg_name][index] = ary
metadata["simulator_metadata"] = result.metadata
else:
for index in np.ndenumerate(parameter_values.shape):
samples = [""] * pub.shots
Expand All @@ -199,7 +201,7 @@ def _run_pub(self, pub: SamplerPub) -> PubResult:
item.creg_name: BitArray(arrays[item.creg_name], item.num_bits) for item in meas_info
}
data_bin = data_bin_cls(**meas)
return PubResult(data_bin, metadata={"shots": pub.shots})
return PubResult(data_bin, metadata=metadata)


def _preprocess_circuit(circuit: QuantumCircuit):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fixes:
- |
This fix adds `simulator_metadata` in the `metadata` of `PubResults`
for SamplerV2 primitive as similar to EstimatorV2 primitive
Loading