amazon-braket-sdk-python icon indicating copy to clipboard operation
amazon-braket-sdk-python copied to clipboard

Cannot run observables from non-indexed TensorProducts with ProgramSets

Open sesmart opened this issue 1 month ago • 1 comments

Describe the bug

device.run(Circuit().h(0).h(1).expectation(Z() @ Z(), target=[0,1])).result() works fine. However,

device.run(ProgramSet.zip(circuits = [Circuit().h(0).h(1)], observables= [Z() @ Z()]), shots = 1000).result() fails.

Non-indexed TensorProducts lead to some sort of errors in programs.inputs where there is incorrectly a None object.

To reproduce

See above snippets. Uses LocalSimulator.

Alternatively:

"device.run(ProgramSet( CircuitBinding( circuit=Circuit().h(0).h(1), observables= [Z() @ Z()] ), shots_per_executable=100)).result() "

Expected behavior

TensorProducts without indices should be able to run okay.

Screenshots or logs

251 return ParameterSets(program.inputs) 252 num_observables = len(observables) 253 return ParameterSets({ 254 k: v[::num_observables] --> 255 for k, v in program.inputs.items() 256 if not k.startswith(EULER_OBSERVABLE_PREFIX) 257 })

AttributeError: 'NoneType' object has no attribute 'items'

System information A description of your system. Please provide:

  • Amazon Braket Python SDK version: 1.103.0
  • Amazon Braket Python Schemas version: 1.26.1
  • Amazon Braket Python Default Simulator version: 1.32.0
  • Python version: 3.12.10

Additional context Add any other context about the problem here.

sesmart avatar Nov 19 '25 18:11 sesmart

Definitely needs a clearer message; there's also the possibility of having implicit targets when the number of qubits in the observable matches that of the circuit.

speller26 avatar Dec 02 '25 21:12 speller26