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

Add MCM support in LQ (new device API) #650

Merged
merged 311 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
311 commits
Select commit Hold shift + click to select a range
15498f8
Merge branch 'lightning-qubit2-add-simulate' into lightning-qubit2-in…
albi3ro Feb 22, 2024
44bc987
remove old comment
AmintorDusko Feb 22, 2024
5a5b20a
some review suggestions
AmintorDusko Feb 22, 2024
dcdd9ff
Merge branch 'master' into lightning-qubit2-add-simulate
AmintorDusko Feb 22, 2024
a64cf78
Auto update version
github-actions[bot] Feb 22, 2024
ad1e3a4
remove print
AmintorDusko Feb 22, 2024
aec5c07
update state vector class
AmintorDusko Feb 22, 2024
286fd4c
add state vector class tests
AmintorDusko Feb 22, 2024
4ee6609
adding measurement tests
albi3ro Feb 22, 2024
c262650
Merge branch 'lightning-qubit2-add-simulate' of https://github.com/Pe…
albi3ro Feb 22, 2024
e8b606e
update state vector and tests
AmintorDusko Feb 23, 2024
7ab3ade
move and rename test files, and format
AmintorDusko Feb 23, 2024
36c6b79
Merge branch 'master' into lightning-qubit2-add-simulate
AmintorDusko Feb 23, 2024
9aa3e35
Auto update version
github-actions[bot] Feb 23, 2024
b9fa21d
skip measurements class for other devices and in the absence of binaries
AmintorDusko Feb 23, 2024
48c6724
format
AmintorDusko Feb 23, 2024
2a67020
add LightningQubit2 to init and format
AmintorDusko Feb 23, 2024
a716611
update measurements class
AmintorDusko Feb 23, 2024
261cb6d
expand measurement class testing
AmintorDusko Feb 23, 2024
aca8468
garbage collection
AmintorDusko Feb 23, 2024
80e3494
typo
AmintorDusko Feb 23, 2024
3aa71fb
Merge branch 'master' into lightning-qubit2-add-simulate
AmintorDusko Feb 26, 2024
a284d78
update coverage and StateVector class
AmintorDusko Feb 26, 2024
43f72f6
expand measurements class coverage
AmintorDusko Feb 26, 2024
2a973d9
Auto update version
github-actions[bot] Feb 26, 2024
f42f298
add coverage for n-controlled operations
AmintorDusko Feb 27, 2024
9cd5471
add map to standard wires to get_final_state for safety
AmintorDusko Feb 27, 2024
cd3096c
update jax config import
AmintorDusko Feb 27, 2024
099e180
Merge branch 'master' into lightning-qubit2-add-simulate
AmintorDusko Feb 27, 2024
98db9db
Auto update version
github-actions[bot] Feb 27, 2024
4f746d0
trigger CI
AmintorDusko Feb 27, 2024
0395945
update state vector class and tests for improved coverage
AmintorDusko Feb 28, 2024
4a863ba
update measurement class tests
AmintorDusko Feb 28, 2024
4374680
Merge branch 'master' into lightning-qubit2-add-simulate
AmintorDusko Feb 28, 2024
4b44e4f
update dev version
AmintorDusko Feb 28, 2024
812f283
Merge branch 'lightning-qubit2-add-simulate' into lightning-qubit2-in…
AmintorDusko Feb 28, 2024
3a87ca8
add cpp binary available variable
AmintorDusko Feb 28, 2024
62c43f0
remove device definition
AmintorDusko Feb 28, 2024
7956c16
Merge branch 'master' into lightning-qubit2-add-simulate
AmintorDusko Feb 28, 2024
dd192da
merge master
AmintorDusko Feb 28, 2024
2d26288
update dev version
AmintorDusko Feb 28, 2024
3427562
Auto update version
github-actions[bot] Feb 28, 2024
98a0d32
Merge branch 'lightning-qubit2-add-simulate' into lightning-qubit2-in…
AmintorDusko Feb 29, 2024
dcfb190
reduce dependency on DefaultQubit for tests
AmintorDusko Feb 29, 2024
6660818
update LightningQubit2
AmintorDusko Feb 29, 2024
8a9b9a5
clean test_measurements_class.py
AmintorDusko Feb 29, 2024
36d810e
isort+black
AmintorDusko Feb 29, 2024
816955f
review suggestion
AmintorDusko Feb 29, 2024
940644c
fix docs
AmintorDusko Feb 29, 2024
4a3f95f
Merge branch 'lightning-qubit2-add-simulate' into lightning-qubit2-in…
AmintorDusko Feb 29, 2024
3922c32
Add qml.var support.
vincentmr Mar 4, 2024
140654a
Merge branch 'master' into lightning-qubit2-add-simulate
AmintorDusko Mar 4, 2024
5b31b07
Add probs support.
vincentmr Mar 5, 2024
b54d3ea
increase tolerance
AmintorDusko Mar 5, 2024
e1e9c05
Merge branch 'master' into lightning-qubit2-add-simulate
AmintorDusko Mar 5, 2024
3703b94
Auto update version
github-actions[bot] Mar 5, 2024
8519c1c
isort
AmintorDusko Mar 5, 2024
60aef32
Add double-obs tests.
vincentmr Mar 5, 2024
6308ba2
Pin pytest version (#624)
AmintorDusko Mar 4, 2024
3a08c62
Version Bump (#626)
github-actions[bot] Mar 4, 2024
daab5ad
increase tolerance
AmintorDusko Mar 5, 2024
078c8d8
Introduce isort. (#623)
vincentmr Mar 5, 2024
4ecf2fb
Auto update version
github-actions[bot] Mar 5, 2024
3bab48b
isort
AmintorDusko Mar 5, 2024
11f6a1b
Add qml.var support.
vincentmr Mar 4, 2024
186e53b
Add probs support.
vincentmr Mar 5, 2024
0222336
Add measurement tests with wires.
vincentmr Mar 5, 2024
6ea2ee8
Merge remote-tracking branch 'origin/lightning-qubit2-add-simulate' i…
vincentmr Mar 5, 2024
0d7db96
Merge remote-tracking branch 'origin/lightning-qubit2-interface' into…
vincentmr Mar 5, 2024
bdc28f8
review suggestions
AmintorDusko Mar 5, 2024
45b5448
remove unused imports
AmintorDusko Mar 5, 2024
25374dd
Introduce _new_API and fix/skip few tests.
vincentmr Mar 5, 2024
e57642c
Fix few more tests.
vincentmr Mar 5, 2024
1c8f20c
Skip shots, adjoint, vjp with new API.
vincentmr Mar 5, 2024
5e80afb
remove diagonalization gate application from state vector
AmintorDusko Mar 5, 2024
96618ca
pytest.skip tests
vincentmr Mar 5, 2024
437e300
Merge branch 'lightning-qubit2-add-simulate' into lightning-qubit2-ad…
vincentmr Mar 5, 2024
edd65a8
Merge branch 'master' into lightning-qubit2-add-measurements
AmintorDusko Mar 6, 2024
24976a9
Auto update version
github-actions[bot] Mar 6, 2024
1c75bbf
Merge branch 'lightning-qubit2-add-measurements' into lightning-qubit…
vincentmr Mar 6, 2024
fda2b3e
Fix format
vincentmr Mar 6, 2024
8e20f9a
Merge remote-tracking branch 'origin/lightning-qubit2-add-measurement…
vincentmr Mar 6, 2024
4adccf2
Fix no-bin interface.
vincentmr Mar 6, 2024
09f3bfa
WIP
vincentmr Mar 5, 2024
aa1d1a8
Initial shots support + fix test_measurement tests.
vincentmr Mar 6, 2024
e844ccb
Merge branch 'master' into lightning-qubit2-add-jacobian
AmintorDusko Mar 6, 2024
095fc5c
update
albi3ro Feb 16, 2024
3a93d1d
adding tests from add-simulate branch
albi3ro Feb 16, 2024
d172e61
merge conflicts
albi3ro Feb 16, 2024
5eb9fa4
create state vector on initialization
albi3ro Feb 16, 2024
ff1eef5
remove import of modifier from lightning
albi3ro Feb 16, 2024
369700a
Update pennylane_lightning/lightning_qubit/lightning_qubit2.py
albi3ro Feb 16, 2024
a2056f1
minor test updates
albi3ro Feb 21, 2024
07041bc
register with setup.py, state vector fixes
albi3ro Feb 21, 2024
7229bbf
add LightningQubit2 to init and format
AmintorDusko Feb 23, 2024
3cca273
add cpp binary available variable
AmintorDusko Feb 28, 2024
be6fb51
reduce dependency on DefaultQubit for tests
AmintorDusko Feb 29, 2024
d6fdb79
update LightningQubit2
AmintorDusko Feb 29, 2024
1d45164
Fixing rebase artifacts
mudit2812 Mar 6, 2024
57869f4
Add fewLQ2 tests.
vincentmr Mar 6, 2024
b0cf5ef
Merge remote-tracking branch 'origin/lightning-qubit2-interface' into…
vincentmr Mar 6, 2024
13130c4
remove adjoint diff support from supports derivatives
albi3ro Mar 6, 2024
7d24981
Merge remote-tracking branch 'origin/lightning-qubit2-interface' into…
vincentmr Mar 6, 2024
dd354f4
Merge branch 'lightning-qubit2-upgrade-API' into lightning-qubit2-add…
vincentmr Mar 6, 2024
968acff
Remove print from test_apply
vincentmr Mar 6, 2024
4981e8b
Add expval/var tests.
vincentmr Mar 6, 2024
4eccac3
Remove duplicate class data.
vincentmr Mar 6, 2024
11227a9
Include LQ2 in linux ests.
vincentmr Mar 6, 2024
e61f534
Merge branch 'lightning-qubit2-upgrade-API' into lightning-qubit2-add…
vincentmr Mar 6, 2024
6da12f4
Add _group_measurements support.
vincentmr Mar 6, 2024
bc870e5
--cov-append
vincentmr Mar 6, 2024
ee01c2f
Add mcmc capability + tests.
vincentmr Mar 6, 2024
2c52cf1
Auto update version
github-actions[bot] Mar 7, 2024
bc89bd1
Merge branch 'master' into lightning-qubit2-add-jacobian
AmintorDusko Mar 7, 2024
357973a
update dev version
AmintorDusko Mar 7, 2024
85128b5
add LightningAdjointJacobian class
AmintorDusko Mar 7, 2024
f95e16b
add unit tests for the LightningAdjointJacobian class
AmintorDusko Mar 7, 2024
724532b
format
AmintorDusko Mar 7, 2024
e938f97
add changelog for PR #613
AmintorDusko Mar 7, 2024
a95b5b1
[skip ci] Added skeleton file for LQ2 unit tests
mudit2812 Mar 7, 2024
a1d5f14
update changelog
AmintorDusko Mar 7, 2024
74dec3a
Merge branch 'master' into lightning-qubit2-interface
mudit2812 Mar 7, 2024
424c8e9
update adjoint Jacobian
AmintorDusko Mar 7, 2024
c91ff39
Auto update version
github-actions[bot] Mar 7, 2024
b005b9b
codefactor
AmintorDusko Mar 7, 2024
1d6afc2
Add shots tests and fix bugs in LQ, LQ2.
vincentmr Mar 7, 2024
7dd8b84
Lightning qubit2 upgrade api (#628)
vincentmr Mar 7, 2024
2747a84
fix processing_fn_expval
AmintorDusko Mar 7, 2024
4959e77
make a proper new_tape
AmintorDusko Mar 7, 2024
0c306b8
Added init tests; Added skeleton tests for helpers
mudit2812 Mar 7, 2024
9e6cc02
Fix more bug with shots.
vincentmr Mar 7, 2024
75c116a
trigger CI
AmintorDusko Mar 7, 2024
fa2ade4
Merge remote-tracking branch 'origin/lightning-qubit2-interface' into…
vincentmr Mar 7, 2024
84d7239
Change pennylane branch for CI.
vincentmr Mar 7, 2024
e3bc241
Update .github/CHANGELOG.md
AmintorDusko Mar 7, 2024
ef35f9d
Update pennylane_lightning/lightning_qubit/_adjoint_jacobian.py
AmintorDusko Mar 7, 2024
e159b55
Update pennylane_lightning/lightning_qubit/_adjoint_jacobian.py
AmintorDusko Mar 7, 2024
4363687
Add probs support.
vincentmr Mar 5, 2024
c1d2ee6
Add double-obs tests.
vincentmr Mar 5, 2024
5535a68
Add qml.var support.
vincentmr Mar 4, 2024
9f5e70f
Add probs support.
vincentmr Mar 5, 2024
ef33d29
Add measurement tests with wires.
vincentmr Mar 5, 2024
1fdab8c
pytest.skip tests
vincentmr Mar 5, 2024
3d9eb6f
Fix format
vincentmr Mar 6, 2024
c3d3395
update
albi3ro Feb 16, 2024
aae5771
adding tests from add-simulate branch
albi3ro Feb 16, 2024
a92d73a
merge conflicts
albi3ro Feb 16, 2024
d7b38a2
create state vector on initialization
albi3ro Feb 16, 2024
6a73755
remove import of modifier from lightning
albi3ro Feb 16, 2024
0ec5089
Update pennylane_lightning/lightning_qubit/lightning_qubit2.py
albi3ro Feb 16, 2024
5646c82
minor test updates
albi3ro Feb 21, 2024
5bae4ac
register with setup.py, state vector fixes
albi3ro Feb 21, 2024
56d76a2
add LightningQubit2 to init and format
AmintorDusko Feb 23, 2024
8f85bab
add cpp binary available variable
AmintorDusko Feb 28, 2024
e2929a5
reduce dependency on DefaultQubit for tests
AmintorDusko Feb 29, 2024
b38c242
update LightningQubit2
AmintorDusko Feb 29, 2024
9480844
Fixing rebase artifacts
mudit2812 Mar 6, 2024
76fb7d9
remove adjoint diff support from supports derivatives
albi3ro Mar 6, 2024
c9f72d0
[skip ci] Added skeleton file for LQ2 unit tests
mudit2812 Mar 7, 2024
86ade7b
Lightning qubit2 upgrade api (#628)
vincentmr Mar 7, 2024
6d134d6
Added init tests; Added skeleton tests for helpers
mudit2812 Mar 7, 2024
5736055
Resolving rebase artifacts
mudit2812 Mar 7, 2024
283cf5b
Refactor shots test.
vincentmr Mar 7, 2024
72a42d8
Merge remote-tracking branch 'origin/lightning-qubit2-upgrade-API' in…
vincentmr Mar 7, 2024
f66419a
Merge remote-tracking branch 'origin/lightning-qubit2-interface' into…
vincentmr Mar 7, 2024
0dd4229
Added tests; integrated jacobian
mudit2812 Mar 8, 2024
413e684
Merge branch 'master' into lightning-qubit2-interface
mudit2812 Mar 8, 2024
62d0aa7
Update pennylane_lightning/lightning_qubit/lightning_qubit2.py
mudit2812 Mar 8, 2024
41772f6
Auto update version
github-actions[bot] Mar 8, 2024
4f6f609
Small update to simulate_and_jacobian
mudit2812 Mar 8, 2024
9275c27
Merge remote-tracking branch 'origin/lightning-qubit2-interface' into…
vincentmr Mar 8, 2024
c6c360e
Merge remote-tracking branch 'origin/master' into lightning-qubit2-ad…
vincentmr Mar 18, 2024
7c4db25
Auto update version
github-actions[bot] Mar 18, 2024
02394dd
Rerun isort.
vincentmr Mar 18, 2024
3f24255
Uncomment integration tests.
vincentmr Mar 18, 2024
62411b6
Reformat
vincentmr Mar 18, 2024
791600e
Delete symlink
vincentmr Mar 18, 2024
a39f7a6
Fix pylint.
vincentmr Mar 18, 2024
b15aeaf
Merge branch 'master' of https://github.com/PennyLaneAI/pennylane-lig…
AmintorDusko Mar 18, 2024
12ba757
Run linux tests in parallel (when possible).
vincentmr Mar 18, 2024
147e75e
Run double obs tests with shots.
vincentmr Mar 18, 2024
d4416f8
Revert linux tests
vincentmr Mar 18, 2024
349400b
Fix bg in diag_gates.
vincentmr Mar 18, 2024
f96b4d7
Call isort/black with python -m
vincentmr Mar 18, 2024
ccd5fec
Merge branch 'lightning-qubit2-add-shots' into lightning-qubit-new-api
AmintorDusko Mar 18, 2024
de17699
update dev version
AmintorDusko Mar 18, 2024
ad66e76
Add docstrings, rm C_DTYPE.
vincentmr Mar 18, 2024
e1a1c68
Merge branch 'master' into lightning-qubit2-add-shots
vincentmr Mar 18, 2024
70c5494
Auto update version
github-actions[bot] Mar 18, 2024
cff6f25
Merge branch 'lightning-qubit2-add-shots' of https://github.com/Penny…
AmintorDusko Mar 19, 2024
65c8853
Merge branch 'master' of https://github.com/PennyLaneAI/pennylane-lig…
AmintorDusko Mar 19, 2024
e8f65db
Merge branch 'lightning-qubit2-add-shots' into lightning-qubit-new-api
AmintorDusko Mar 19, 2024
4a2aaa2
Merge branch 'master' into lightning-qubit-new-api
AmintorDusko Mar 19, 2024
f91a1d8
comment isort check
AmintorDusko Mar 19, 2024
c52fd10
trigger ci
vincentmr Mar 19, 2024
4873022
Update tests/test_expval.py
vincentmr Mar 19, 2024
3481ef2
Init mcmc params to None in measurements.
vincentmr Mar 19, 2024
cad382a
Reformat with python3.11
vincentmr Mar 19, 2024
c175572
Reformat black
vincentmr Mar 19, 2024
ebeb417
Merge branch 'master' of https://github.com/PennyLaneAI/pennylane-lig…
AmintorDusko Mar 19, 2024
0f83b9f
Merge branch 'lightning-qubit2-add-shots' of https://github.com/Penny…
AmintorDusko Mar 19, 2024
7731a75
Merge branch 'lightning-qubit2-add-shots' into lightning-qubit-new-api
AmintorDusko Mar 19, 2024
37e1e58
Merge branch 'master' into lightning-qubit-new-api
AmintorDusko Mar 19, 2024
16d019e
Auto update version
github-actions[bot] Mar 19, 2024
0c8ffc4
Merge branch 'lightning-qubit-new-api' of https://github.com/PennyLan…
AmintorDusko Mar 19, 2024
2cf45e9
update QuantumScriptSerializer
AmintorDusko Mar 19, 2024
f63d6af
remove LightningQubit2 from init
AmintorDusko Mar 19, 2024
080d037
update setup.py
AmintorDusko Mar 19, 2024
c5442a6
remove lightning.qubit2 from tests configuration
AmintorDusko Mar 19, 2024
83bf167
remove extra tests for lightning.qubit2
AmintorDusko Mar 19, 2024
3d831d0
migrate lightning.qubit2 to lightning.qubit on tests
AmintorDusko Mar 19, 2024
c30f94f
make lightning.qubit2 the new lightning.qubit
AmintorDusko Mar 19, 2024
d557b65
add device name (necessary for pl-device-test)
AmintorDusko Mar 19, 2024
472e0ff
Add _measure_hamiltonian_with_samples _measure_sum_with_samples
vincentmr Mar 19, 2024
f1b0a62
fix tests without binary
AmintorDusko Mar 19, 2024
80425ee
Merge branch 'lightning-qubit-new-api' of https://github.com/PennyLan…
AmintorDusko Mar 19, 2024
1803e39
check for jac size before reshaping
AmintorDusko Mar 19, 2024
a4c73ca
remove obsolete tests
AmintorDusko Mar 19, 2024
e359c30
organize tests
AmintorDusko Mar 19, 2024
739f0b4
fix test for Windows wheels
AmintorDusko Mar 19, 2024
3b5f937
fix the fix for LightningKokkos
AmintorDusko Mar 19, 2024
cf2a6dd
Add MCM support initial work.
vincentmr Mar 19, 2024
1c8c14a
Update changelog.
vincentmr Mar 19, 2024
f17fc2c
Fix test_preprocess
vincentmr Mar 19, 2024
48e09e6
Try & parallelize pytest
vincentmr Mar 20, 2024
8aa01e3
Increase timeout to 60 min.
vincentmr Mar 20, 2024
4241923
Limit OMP_NUM_THREADS.
vincentmr Mar 20, 2024
349350d
Do not parallelize Kokkos tests.
vincentmr Mar 20, 2024
f9b6f5f
Update tests/test_native_mcm.py
vincentmr Mar 21, 2024
c6204f0
Update tests/test_native_mcm.py
vincentmr Mar 21, 2024
29a8768
Update tests/test_native_mcm.py
vincentmr Mar 21, 2024
4d903a4
Update tests/test_native_mcm.py
vincentmr Mar 21, 2024
76aff95
Auto update version
github-actions[bot] Mar 21, 2024
eec5298
Update tests/test_native_mcm.py
vincentmr Mar 21, 2024
d9b3563
Update tests/test_native_mcm.py
vincentmr Mar 21, 2024
850823f
Update tests/test_native_mcm.py
vincentmr Mar 21, 2024
4c4d5a4
Update tests/test_native_mcm.py
vincentmr Mar 21, 2024
3c231ef
Update tests/test_native_mcm.py
vincentmr Mar 21, 2024
9341bec
format
vincentmr Mar 21, 2024
dc3f776
Merge remote-tracking branch 'origin/master' into feature/new_api_mcms
vincentmr Mar 21, 2024
1cf9a5a
Auto update version
github-actions[bot] Mar 21, 2024
efeed6b
trigger ci
vincentmr Mar 21, 2024
498c030
Update Makefile
vincentmr Mar 21, 2024
08503c6
Update tests/test_native_mcm.py
vincentmr Mar 21, 2024
21dbba9
Update tests/test_native_mcm.py
vincentmr Mar 21, 2024
a4224d5
Fix docstrings.
vincentmr Mar 21, 2024
2c6034d
Merge remote-tracking branch 'origin/master' into feature/new_api_mcms
vincentmr Mar 22, 2024
6218094
Auto update version
github-actions[bot] Mar 22, 2024
3af7924
Update format.yml
vincentmr Mar 22, 2024
1c29525
Update format.yml
vincentmr Mar 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

### New features since last release

* `lightning.qubit` supports mid-circuit measurements.
[(#650)](https://github.com/PennyLaneAI/pennylane-lightning/pull/650)

* Add finite shots support in `lightning.qubit2`.
[(#630)](https://github.com/PennyLaneAI/pennylane-lightning/pull/630)

Expand Down
27 changes: 15 additions & 12 deletions .github/workflows/tests_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
matrix:
os: [ubuntu-22.04]
pl_backend: ["lightning_qubit"]
timeout-minutes: 30
timeout-minutes: 60
vincentmr marked this conversation as resolved.
Show resolved Hide resolved
name: C++ tests
runs-on: ${{ matrix.os }}

Expand Down Expand Up @@ -106,7 +106,7 @@ jobs:
matrix:
os: [ubuntu-22.04]
pl_backend: ["lightning_qubit"]
timeout-minutes: 30
timeout-minutes: 60
name: Python tests
runs-on: ${{ matrix.os }}

Expand Down Expand Up @@ -184,7 +184,8 @@ jobs:
run: |
cd main/
DEVICENAME=`echo ${{ matrix.pl_backend }} | sed "s/_/./g"`
PL_DEVICE=${DEVICENAME} python -m pytest tests/ $COVERAGE_FLAGS
OMP_NUM_THREADS=1 PL_DEVICE=${DEVICENAME} python -m pytest -n auto tests/ -k "not unitary_correct" $COVERAGE_FLAGS
PL_DEVICE=${DEVICENAME} python -m pytest tests/ -k "unitary_correct" $COVERAGE_FLAGS --cov-append
pl-device-test --device ${DEVICENAME} --skip-ops --shots=20000 $COVERAGE_FLAGS --cov-append
pl-device-test --device ${DEVICENAME} --shots=None --skip-ops $COVERAGE_FLAGS --cov-append
mv .coverage .coverage-${{ github.job }}-${{ matrix.pl_backend }}
Expand All @@ -203,7 +204,7 @@ jobs:
matrix:
os: [ubuntu-22.04]
pl_backend: ["lightning_qubit"]
timeout-minutes: 30
timeout-minutes: 60
name: C++ tests (OpenBLAS)
runs-on: ${{ matrix.os }}

Expand Down Expand Up @@ -259,7 +260,7 @@ jobs:
matrix:
os: [ubuntu-22.04]
pl_backend: ["lightning_qubit"]
timeout-minutes: 30
timeout-minutes: 60
name: C++ tests (OpenBLAS without LAPACK)
runs-on: ${{ matrix.os }}

Expand Down Expand Up @@ -314,7 +315,7 @@ jobs:
matrix:
os: [ubuntu-22.04]
pl_backend: ["lightning_qubit"]
timeout-minutes: 30
timeout-minutes: 60
name: Python tests with OpenBLAS
runs-on: ${{ matrix.os }}

Expand Down Expand Up @@ -392,7 +393,8 @@ jobs:
run: |
cd main/
DEVICENAME=`echo ${{ matrix.pl_backend }} | sed "s/_/./g"`
PL_DEVICE=${DEVICENAME} python -m pytest tests/ $COVERAGE_FLAGS
OMP_NUM_THREADS=1 PL_DEVICE=${DEVICENAME} python -m pytest -n auto tests/ -k "not unitary_correct" $COVERAGE_FLAGS
PL_DEVICE=${DEVICENAME} python -m pytest tests/ -k "unitary_correct" $COVERAGE_FLAGS --cov-append
pl-device-test --device ${DEVICENAME} --skip-ops --shots=20000 $COVERAGE_FLAGS --cov-append
pl-device-test --device ${DEVICENAME} --shots=None --skip-ops $COVERAGE_FLAGS --cov-append
mv .coverage .coverage-${{ github.job }}-${{ matrix.pl_backend }}
Expand All @@ -419,7 +421,7 @@ jobs:
pl_backend: ["lightning_kokkos"]
exec_model: ${{ fromJson(needs.build_and_cache_Kokkos.outputs.exec_model) }}
kokkos_version: ${{ fromJson(needs.build_and_cache_Kokkos.outputs.kokkos_version) }}
timeout-minutes: 30
timeout-minutes: 60
name: C++ tests (Kokkos)
runs-on: ${{ matrix.os }}

Expand Down Expand Up @@ -494,7 +496,7 @@ jobs:
exclude:
- pl_backend: ["all"]
exec_model: OPENMP
timeout-minutes: 30
timeout-minutes: 60
name: Python tests with Kokkos
runs-on: ${{ matrix.os }}

Expand Down Expand Up @@ -609,10 +611,11 @@ jobs:
if: ${{ matrix.pl_backend == 'all' }}
run: |
cd main/
PL_DEVICE=lightning.qubit python -m pytest tests/ $COVERAGE_FLAGS
OMP_NUM_THREADS=1 PL_DEVICE=lightning.qubit python -m pytest -n auto tests/ -k "not unitary_correct" $COVERAGE_FLAGS
PL_DEVICE=lightning.qubit python -m pytest tests/ -k "unitary_correct" $COVERAGE_FLAGS --cov-append
pl-device-test --device lightning.qubit --skip-ops --shots=20000 $COVERAGE_FLAGS --cov-append
pl-device-test --device lightning.qubit --shots=None --skip-ops $COVERAGE_FLAGS --cov-append
PL_DEVICE=lightning.kokkos python -m pytest tests/ $COVERAGE_FLAGS
PL_DEVICE=lightning.kokkos python -m pytest tests/ $COVERAGE_FLAGS --cov-append
pl-device-test --device lightning.kokkos --skip-ops --shots=20000 $COVERAGE_FLAGS --cov-append
pl-device-test --device lightning.kokkos --shots=None --skip-ops $COVERAGE_FLAGS --cov-append
mv .coverage .coverage-${{ github.job }}-${{ matrix.pl_backend }}
Expand Down Expand Up @@ -682,7 +685,7 @@ jobs:
os: [ubuntu-22.04]
exec_model: ${{ fromJson(needs.build_and_cache_Kokkos.outputs.exec_model) }}
kokkos_version: ${{ fromJson(needs.build_and_cache_Kokkos.outputs.kokkos_version) }}
timeout-minutes: 30
timeout-minutes: 60
name: C++ tests (multiple backends)
runs-on: ${{ matrix.os }}

Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ PL_BACKEND ?= "$(if $(backend:-=),$(backend),lightning_qubit)"

ifdef check
CHECK := --check
ICHECK := --check --diff
vincentmr marked this conversation as resolved.
Show resolved Hide resolved
else
CHECK :=
ICHECK :=
endif

ifdef build_options
Expand Down Expand Up @@ -113,7 +115,7 @@ format-cpp:
./bin/format $(CHECK) ./pennylane_lightning

format-python:
isort --profile black ./pennylane_lightning/ ./mpitests ./tests $(CHECK)
isort --profile black ./pennylane_lightning/ ./mpitests ./tests $(ICHECK)
black -l 100 ./pennylane_lightning/ ./mpitests ./tests $(CHECK)

.PHONY: check-tidy
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.36.0-dev14"
__version__ = "0.36.0-dev15"
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ void registerBackendClassSpecificBindings(PyClass &pyclass) {
}
},
"Copy StateVector data into a Numpy array.")
.def("collapse", &StateVectorT::collapse,
"Collapse the statevector onto the 0 or 1 branch of a given wire.")
.def("normalize", &StateVectorT::normalize,
"Normalizes the statevector to norm 1.")
.def("applyControlledMatrix", &applyControlledMatrix<StateVectorT>,
"Apply controlled operation")
.def("kernel_map", &svKernelMap<StateVectorT>,
Expand Down
14 changes: 7 additions & 7 deletions pennylane_lightning/lightning_kokkos/lightning_kokkos.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@
from pennylane.ops.op_math import Adjoint
from pennylane.wires import Wires

# pylint: disable=import-error, no-name-in-module, ungrouped-imports
from pennylane_lightning.core._serialize import (
QuantumScriptSerializer,
global_phase_diagonal,
)
from pennylane_lightning.core._version import __version__

# pylint: disable=import-error, no-name-in-module, ungrouped-imports
from pennylane_lightning.lightning_kokkos_ops.algorithms import (
AdjointJacobianC64,
Expand All @@ -72,13 +79,6 @@
create_ops_listC128,
)

# pylint: disable=import-error, no-name-in-module, ungrouped-imports
from pennylane_lightning.core._serialize import (
QuantumScriptSerializer,
global_phase_diagonal,
)
from pennylane_lightning.core._version import __version__

maliasadi marked this conversation as resolved.
Show resolved Hide resolved
def _kokkos_dtype(dtype):
if dtype not in [np.complex128, np.complex64]: # pragma: no cover
raise ValueError(f"Data type is not supported for state-vector computation: {dtype}")
Expand Down
4 changes: 1 addition & 3 deletions pennylane_lightning/lightning_qubit/_measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@

from pennylane_lightning.core._serialize import QuantumScriptSerializer

from ._state_vector import LightningStateVector


class LightningMeasurements:
"""Lightning Measurements class
Expand All @@ -72,7 +70,7 @@ class LightningMeasurements:

def __init__(
self,
qubit_state: LightningStateVector,
qubit_state,
AmintorDusko marked this conversation as resolved.
Show resolved Hide resolved
mcmc: bool = None,
kernel_name: str = None,
num_burnin: int = None,
Expand Down
50 changes: 41 additions & 9 deletions pennylane_lightning/lightning_qubit/_state_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@
import numpy as np
import pennylane as qml
from pennylane import BasisState, DeviceError, StatePrep
from pennylane.measurements import MidMeasureMP
from pennylane.ops import Conditional
from pennylane.ops.op_math import Adjoint
from pennylane.tape import QuantumScript
from pennylane.wires import Wires

from ._measurements import LightningMeasurements


class LightningStateVector:
"""Lightning state-vector class.
Expand Down Expand Up @@ -220,10 +224,10 @@ def _apply_lightning_controlled(self, operation):
"""Apply an arbitrary controlled operation to the state tensor.

Args:
operation (~pennylane.operation.Operation): operation to apply
operation (~pennylane.operation.Operation): controlled operation to apply

Returns:
array[complex]: the output state tensor
None
"""
state = self.state_vector

Expand All @@ -246,14 +250,36 @@ def _apply_lightning_controlled(self, operation):
False,
)

def _apply_lightning(self, operations):
def _apply_lightning_midmeasure(self, operation: MidMeasureMP, mid_measurements: dict):
maliasadi marked this conversation as resolved.
Show resolved Hide resolved
"""Execute a MidMeasureMP operation and return the sample in mid_measurements.
Args:
operation (~pennylane.operation.Operation): mid-circuit measurement
mid_measurements (None, dict): Dictionary of mid-circuit measurements
vincentmr marked this conversation as resolved.
Show resolved Hide resolved
Returns:
None
"""
wires = self.wires.indices(operation.wires)
wire = list(wires)[0]
circuit = QuantumScript([], [qml.sample(wires=operation.wires)], shots=1)
sample = LightningMeasurements(self).measure_final_state(circuit)
sample = np.squeeze(sample)
if operation.postselect is not None and sample != operation.postselect:
mid_measurements[operation] = -1
return
mid_measurements[operation] = sample
getattr(self.state_vector, "collapse")(wire, bool(sample))
if operation.reset and bool(sample):
self.apply_operations([qml.PauliX(operation.wires)], mid_measurements=mid_measurements)

def _apply_lightning(self, operations, mid_measurements: dict = None):
"""Apply a list of operations to the state tensor.

Args:
operations (list[~pennylane.operation.Operation]): operations to apply
mid_measurements (None, dict): Dictionary of mid-circuit measurements

Returns:
array[complex]: the output state tensor
None
"""
state = self.state_vector

Expand All @@ -271,7 +297,12 @@ def _apply_lightning(self, operations):
method = getattr(state, name, None)
wires = list(operation.wires)

if method is not None: # apply specialized gate
if isinstance(operation, Conditional):
if operation.meas_val.concretize(mid_measurements):
self._apply_lightning([operation.then_op])
elif isinstance(operation, MidMeasureMP):
self._apply_lightning_midmeasure(operation, mid_measurements)
elif method is not None: # apply specialized gate
param = operation.parameters
method(wires, invert_param, param)
elif isinstance(operation, qml.ops.Controlled): # apply n-controlled gate
Expand All @@ -286,7 +317,7 @@ def _apply_lightning(self, operations):
# To support older versions of PL
method(operation.matrix, wires, False)

def apply_operations(self, operations):
def apply_operations(self, operations, mid_measurements: dict = None):
"""Applies operations to the state vector."""
# State preparation is currently done in Python
if operations: # make sure operations[0] exists
Expand All @@ -297,21 +328,22 @@ def apply_operations(self, operations):
self._apply_basis_state(operations[0].parameters[0], operations[0].wires)
operations = operations[1:]

self._apply_lightning(operations)
self._apply_lightning(operations, mid_measurements=mid_measurements)

def get_final_state(self, circuit: QuantumScript):
def get_final_state(self, circuit: QuantumScript, mid_measurements: dict = None):
"""
Get the final state that results from executing the given quantum script.

This is an internal function that will be called by the successor to ``lightning.qubit``.

Args:
circuit (QuantumScript): The single circuit to simulate
mid_measurements (None, dict): Dictionary of mid-circuit measurements

Returns:
LightningStateVector: Lightning final state class.

"""
self.apply_operations(circuit.operations)
self.apply_operations(circuit.operations, mid_measurements=mid_measurements)

return self
16 changes: 15 additions & 1 deletion pennylane_lightning/lightning_qubit/lightning_qubit.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@
from pennylane.devices.modifiers import simulator_tracking, single_tape_support
from pennylane.devices.preprocess import (
decompose,
mid_circuit_measurements,
no_sampling,
validate_adjoint_trainable_params,
validate_device_wires,
validate_measurements,
validate_observables,
)
from pennylane.measurements import MidMeasureMP
from pennylane.tape import QuantumScript, QuantumTape
from pennylane.transforms.core import TransformProgram
from pennylane.typing import Result, ResultBatch
Expand Down Expand Up @@ -71,6 +73,16 @@ def simulate(circuit: QuantumScript, state: LightningStateVector, mcmc: dict = N
if mcmc is None:
mcmc = {}
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)
if any(v == -1 for v in mid_measurements.values()):
return None, mid_measurements
return (
LightningMeasurements(final_state, **mcmc).measure_final_state(circuit),
mid_measurements,
)
final_state = state.get_final_state(circuit)
return LightningMeasurements(final_state, **mcmc).measure_final_state(circuit)

Expand Down Expand Up @@ -200,6 +212,8 @@ def simulate_and_jacobian(circuit: QuantumTape, state: LightningStateVector, bat
"QFT",
"ECR",
"BlockEncode",
"MidMeasureMP",
"Conditional",
}
)
# The set of supported operations.
Expand Down Expand Up @@ -432,7 +446,7 @@ def preprocess(self, execution_config: ExecutionConfig = DefaultExecutionConfig)
program.add_transform(validate_measurements, name=self.name)
program.add_transform(validate_observables, accepted_observables, name=self.name)
program.add_transform(validate_device_wires, self.wires, name=self.name)
program.add_transform(qml.defer_measurements, device=self)
program.add_transform(mid_circuit_measurements, device=self)
program.add_transform(decompose, stopping_condition=stopping_condition, name=self.name)
program.add_transform(qml.transforms.broadcast_expand)

Expand Down
4 changes: 3 additions & 1 deletion tests/new_api/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,9 @@ def test_preprocess(self, adjoint):
expected_program.add_transform(validate_measurements, name=device.name)
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(qml.defer_measurements, device=device)
expected_program.add_transform(
qml.devices.preprocess.mid_circuit_measurements, device=device
)
expected_program.add_transform(
decompose, stopping_condition=stopping_condition, name=device.name
)
Expand Down
Loading
Loading