Skip to content

Commit

Permalink
Update how finite shots are validated for MCM configuration (#6067)
Browse files Browse the repository at this point in the history
As name says. Original implementation was using `override_shots` and/or
device shots, which is correct, but outdated behaviour. I just changed
it to use `tape.shots` instead.
  • Loading branch information
mudit2812 committed Aug 5, 2024
1 parent 6de1ec7 commit eafd446
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions pennylane/workflow/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,15 +720,7 @@ def cost_fn(params, x):

# Mid-circuit measurement configuration validation
mcm_interface = interface or _get_interface_name(tapes, "auto")
finite_shots = (
(
qml.measurements.Shots(device.shots)
if isinstance(device, qml.devices.LegacyDevice)
else device.shots
)
if override_shots is False
else override_shots
)
finite_shots = any(tape.shots for tape in tapes)
_update_mcm_config(config.mcm_config, mcm_interface, finite_shots)

is_gradient_transform = isinstance(gradient_fn, qml.transforms.core.TransformDispatcher)
Expand Down

0 comments on commit eafd446

Please sign in to comment.