Skip to content

Commit

Permalink
Add interface to lightning.qubit MCM preprocessing (#760)
Browse files Browse the repository at this point in the history
**Context:**
Currently blocked by PennyLaneAI/pennylane#5791.
Device preprocessing is being moved inside the ML boundary, so the
interface information needed for correct `hw-like` postselection is
being lost when using `dynamic_one_shot`.

**Description of the Change:**
`qml.devices.preprocess.mid_circuit_measurements` accepts an additional
`interface` kwarg, which is now being used in
`LightningQubit.preprocess`.

**Benefits:**
Expected behaviour with `mcm_method="one-shot"`,
`postselect_mode="hw-like"`, and `jax.jit`.

**Possible Drawbacks:**

**Related GitHub Issues:**

---------

Co-authored-by: ringo-but-quantum <github-ringo-but-quantum@xanadu.ai>
Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>
  • Loading branch information
3 people authored Jun 13, 2024
1 parent 56c3064 commit f15665c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@
* `lightning.qubit` and `lightning.kokkos` use `qml.ops.Conditional.base` instead of `qml.ops.Conditional.then_op`.
[(#752)](https://github.com/PennyLaneAI/pennylane-lightning/pull/752)

* The preprocessing step in `lightning.qubit` now uses interface information to properly support the hardware-like postselection for mid-circuit measurements.
[(#760)](https://github.com/PennyLaneAI/pennylane-lightning/pull/760)

* Fix AVX streaming operation support with newer GCC.
[(#729)](https://github.com/PennyLaneAI/pennylane-lightning/pull/729)

Expand Down
2 changes: 1 addition & 1 deletion pennylane_lightning/core/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
Version number (major.minor.patch[-label])
"""

__version__ = "0.37.0-dev34"
__version__ = "0.37.0-dev35"
5 changes: 4 additions & 1 deletion pennylane_lightning/lightning_qubit/lightning_qubit.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,10 @@ def preprocess(self, execution_config: ExecutionConfig = DefaultExecutionConfig)
program.add_transform(validate_observables, accepted_observables, name=self.name)
program.add_transform(validate_device_wires, self.wires, name=self.name)
program.add_transform(
mid_circuit_measurements, device=self, mcm_config=exec_config.mcm_config
mid_circuit_measurements,
device=self,
mcm_config=exec_config.mcm_config,
interface=exec_config.interface,
)
program.add_transform(
decompose,
Expand Down
2 changes: 1 addition & 1 deletion tests/new_api/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def test_preprocess(self, adjoint):
expected_program.add_transform(validate_observables, accepted_observables, name=device.name)
expected_program.add_transform(validate_device_wires, device.wires, name=device.name)
expected_program.add_transform(
mid_circuit_measurements, device=device, mcm_config=MCMConfig()
mid_circuit_measurements, device=device, mcm_config=MCMConfig(), interface=None
)
expected_program.add_transform(
decompose,
Expand Down

0 comments on commit f15665c

Please sign in to comment.