Skip to content

Commit cd81829

Browse files
committed
chore: multi-observables job execution for IBMSimulatedDevice
1 parent 3d5fc06 commit cd81829

File tree

1 file changed

+21
-1
lines changed
  • mpqp/execution/providers

1 file changed

+21
-1
lines changed

mpqp/execution/providers/ibm.py

+21-1
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,27 @@ def run_aer(job: Job):
487487
result = extract_result(result_sim, job, job.device)
488488

489489
elif job.job_type == JobType.OBSERVABLE:
490-
result = compute_expectation_value(qiskit_circuit, job, backend_sim)
490+
if isinstance(job.device, (IBMDevice, IBMSimulatedDevice)):
491+
492+
results = []
493+
494+
for _ in job.measure.observables:
495+
expectation_value = compute_expectation_value(
496+
qiskit_circuit, job, backend_sim
497+
)
498+
499+
if isinstance(expectation_value, BatchResult):
500+
results.extend(expectation_value.results)
501+
elif isinstance(expectation_value, Result):
502+
results.append(expectation_value)
503+
else:
504+
raise TypeError(
505+
f"compute_expectation_value() returned {type(expectation_value)}, expected Result or BatchResult."
506+
)
507+
508+
# results.append(expectation_value)
509+
510+
result = BatchResult(results) if len(results) > 1 else results[0]
491511

492512
else:
493513
raise ValueError(f"Job type {job.job_type} not handled.")

0 commit comments

Comments
 (0)