Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update LQ's MCM treatment following dynamic_one_shot update. #724

Merged
merged 9 commits into from
May 10, 2024
Merged
9 changes: 6 additions & 3 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@

### Breaking changes

* `dynamic_one_shot` uses shot-vectors in the auxiliary tape to tell the device how many times to repeat the tape. Lightning-Qubit is updated accordingly.
[(#724)](https://github.com/PennyLaneAI/pennylane-lightning/pull/724)

* `dynamic_one_shot` deals with post-selection during the post-processing phase, so Lightning-Qubit does not return `None`-valued measurements for mismatching samples anymore.
[(#720)](https://github.com/PennyLaneAI/pennylane-lightning/pull/720)

### Improvements

* The various OpenMP configurations of Lightning-Qubit are tested in parallel on different Github Actions runners.
[(#712)](https://github.com/PennyLaneAI/pennylane-lightning/pull/712)

* Update Linux wheels to use manylinux_2_28 images.
[(#667)](https://github.com/PennyLaneAI/pennylane-lightning/pull/667)

* Add support for `qml.expval` and `qml.var` in the `lightning.tensor` device for the `quimb` interface and the MPS method.
[(#686)](https://github.com/PennyLaneAI/pennylane-lightning/pull/686)
[(#686)](https://github.com/PennyLaneAI/pennylane-lightning/pull/686)

* Changed the name of `lightning.tensor` to `default.tensor` with the `quimb` backend.
[(#719)](https://github.com/PennyLaneAI/pennylane-lightning/pull/719)
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-dev6"
__version__ = "0.37.0-dev7"
20 changes: 16 additions & 4 deletions pennylane_lightning/lightning_qubit/lightning_qubit.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,23 @@ def simulate(circuit: QuantumScript, state: LightningStateVector, mcmc: dict = N
state.reset_state()
has_mcm = any(isinstance(op, MidMeasureMP) for op in circuit.operations)
if circuit.shots and has_mcm:
mid_measurements = {}
final_state = state.get_final_state(circuit, mid_measurements=mid_measurements)
return LightningMeasurements(final_state, **mcmc).measure_final_state(
circuit, mid_measurements=mid_measurements
results = []
aux_circ = qml.tape.QuantumScript(
circuit.operations,
circuit.measurements,
shots=[1],
trainable_params=circuit.trainable_params,
)
for _ in range(circuit.shots.total_shots):
state.reset_state()
mid_measurements = {}
final_state = state.get_final_state(aux_circ, mid_measurements=mid_measurements)
results.append(
LightningMeasurements(final_state, **mcmc).measure_final_state(
aux_circ, mid_measurements=mid_measurements
)
)
return tuple(results)
final_state = state.get_final_state(circuit)
return LightningMeasurements(final_state, **mcmc).measure_final_state(circuit)

Expand Down
Loading