Skip to content

Cannot run observables from non-indexed TensorProducts with ProgramSets #1166

@sesmart

Description

@sesmart

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.

Sub-issues

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions