Summary
MeasuredEntry.expectation() on a ProgramSetQuantumTaskResult returns None (and warns "No observable was measured") whenever the entry has no attached observable, even though the entry contains the measurements needed to compute the expectation. The code path is explicitly unimplemented.
Location
src/braket/tasks/program_set_quantum_task_result.py, MeasuredEntry (verified present on main as of 2026-07):
self._expectation = (
expectation_from_measurements(counts, measured_qubits, self.observable, self.observable.targets)
if self.observable
else None
)
def expectation(self) -> float | None:
# TODO: Use program set payload to calculate expectation
if self._expectation is None:
warnings.warn("No observable was measured", stacklevel=1)
return self._expectation
Impact
Downstream consumers that request an expectation from a program-set result receive None/no usable value and can silently produce wrong results, despite the measurements being present and correct. We hit this via the PennyLane–Braket plugin, where qml.expval returns values off by up to ~1.5 for a program-set result on a QPU (filing a companion issue on that repo, will cross-link). Because the failure is silent (only a UserWarning) and the measurements look fine, the corruption is easy to miss, in our case it manufactured a spurious ~0.2 R² effect that looked like a hardware-fidelity difference.
Suggested fix
Implement the # TODO: when self.observable is absent but the requested observable is a computational-basis/diagonal observable (or is recoverable from the program-set payload), compute the expectation from measurements instead of returning None.
Environment
Reproduced on amazon-braket-sdk==1.113.1; the unimplemented path is still present on main (1.121.0). Device: Rigetti Cepheus-1-108Q. The measurement bitstrings on the entry are correct, only the computed expectation is missing.
Summary
MeasuredEntry.expectation()on aProgramSetQuantumTaskResultreturnsNone(and warns"No observable was measured") whenever the entry has no attached observable, even though the entry contains themeasurementsneeded to compute the expectation. The code path is explicitly unimplemented.Location
src/braket/tasks/program_set_quantum_task_result.py,MeasuredEntry(verified present onmainas of 2026-07):Impact
Downstream consumers that request an expectation from a program-set result receive
None/no usable value and can silently produce wrong results, despite the measurements being present and correct. We hit this via the PennyLane–Braket plugin, whereqml.expvalreturns values off by up to ~1.5 for a program-set result on a QPU (filing a companion issue on that repo, will cross-link). Because the failure is silent (only aUserWarning) and the measurements look fine, the corruption is easy to miss, in our case it manufactured a spurious ~0.2 R² effect that looked like a hardware-fidelity difference.Suggested fix
Implement the
# TODO: whenself.observableis absent but the requested observable is a computational-basis/diagonal observable (or is recoverable from the program-set payload), compute the expectation frommeasurementsinstead of returningNone.Environment
Reproduced on
amazon-braket-sdk==1.113.1; the unimplemented path is still present onmain(1.121.0). Device: Rigetti Cepheus-1-108Q. The measurement bitstrings on the entry are correct, only the computed expectation is missing.