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 LGPU-MPI cpp backend #514

Merged
merged 177 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
177 commits
Select commit Hold shift + click to select a range
15e42fd
add LGPU cpp layer
multiphaseCFD Sep 12, 2023
ece63c6
update measurement
multiphaseCFD Sep 13, 2023
9431ef6
add openmp to adjgpu
multiphaseCFD Sep 13, 2023
44237ea
Merge branch 'master' into add_LGPU
multiphaseCFD Sep 13, 2023
39d144e
Auto update version
github-actions[bot] Sep 13, 2023
832dc68
Add support for building multiple backend simulators (#497)
maliasadi Sep 13, 2023
5b2220d
add python layer & isingxy gate in the cpp layer
multiphaseCFD Sep 15, 2023
b10494b
add batched adjoint method
multiphaseCFD Sep 15, 2023
62ee28b
Update DefaultQubit to DefaultQubitLegacy (#500)
AmintorDusko Sep 15, 2023
d921b4f
Auto update version
github-actions[bot] Sep 15, 2023
cd06aa6
add batch support for adjoint method
multiphaseCFD Sep 16, 2023
38bfad3
add gitignore
multiphaseCFD Sep 16, 2023
516447f
tidy up code
multiphaseCFD Sep 16, 2023
8de101a
Merge branch 'master' into add_LGPU
multiphaseCFD Sep 16, 2023
c7d6012
Auto update version
github-actions[bot] Sep 16, 2023
6bcd87c
make format
multiphaseCFD Sep 16, 2023
c9cbdaa
revert complexT delete in LKokkosBingds
multiphaseCFD Sep 18, 2023
108e1fe
make format
multiphaseCFD Sep 18, 2023
d94fc0e
update based on tidy
multiphaseCFD Sep 18, 2023
ee914a2
fix tidy format
multiphaseCFD Sep 18, 2023
e1a9bb0
add_gpu_runners_tests
multiphaseCFD Sep 18, 2023
ce49548
add cuquantum_sdk path to ci workflow
multiphaseCFD Sep 18, 2023
a99363c
debug
multiphaseCFD Sep 18, 2023
ad4b938
add path to cuquantum sdk
multiphaseCFD Sep 18, 2023
78bab88
add python layer tests in ci workflow
multiphaseCFD Sep 18, 2023
3c9e9c0
ci tests
multiphaseCFD Sep 18, 2023
b805ec2
quick fix
multiphaseCFD Sep 18, 2023
08412c4
skip pr ci for some workflows
multiphaseCFD Sep 18, 2023
f0dc631
quick fix
multiphaseCFD Sep 18, 2023
9639b41
quick fix
multiphaseCFD Sep 18, 2023
ba3bf42
update python ci tests
multiphaseCFD Sep 18, 2023
083fdd7
remove dependency on lightning_qubit in ci
multiphaseCFD Sep 18, 2023
ed6ea62
fix directory
multiphaseCFD Sep 18, 2023
c3ad7aa
fix directory
multiphaseCFD Sep 18, 2023
e7afb36
quick fix
multiphaseCFD Sep 18, 2023
d35628e
quick fix
multiphaseCFD Sep 18, 2023
4a58c98
test for cuda-12
multiphaseCFD Sep 19, 2023
81fc5b9
update measurement
multiphaseCFD Sep 19, 2023
c3db409
Merge branch 'master' into add_LGPU
multiphaseCFD Sep 20, 2023
61ffa3d
updata cu12 workflows
multiphaseCFD Sep 20, 2023
e5c2c4b
add getDataVector support to LQubitRaw
multiphaseCFD Sep 21, 2023
2ba7e96
Merge branch 'master' into add_LGPU
multiphaseCFD Sep 21, 2023
23e154d
install lightning.qubit before lightning.gpu in ci
multiphaseCFD Sep 21, 2023
a1ca506
update test_obs
multiphaseCFD Sep 21, 2023
f52fe36
activate all CI checks
multiphaseCFD Sep 22, 2023
2cc0242
quick fix
multiphaseCFD Sep 22, 2023
b6cde23
tidy up code
multiphaseCFD Sep 22, 2023
d76ec44
tidy up code
multiphaseCFD Sep 22, 2023
d48351e
make format
multiphaseCFD Sep 22, 2023
4f4e1fa
update ci for more tests
multiphaseCFD Sep 22, 2023
3a45666
tidy up code
multiphaseCFD Sep 22, 2023
443aae5
tidy up code
multiphaseCFD Sep 22, 2023
e8ac990
tidy up code
multiphaseCFD Sep 22, 2023
74d3667
make format
multiphaseCFD Sep 22, 2023
3efeb1f
fix for codecov
multiphaseCFD Sep 22, 2023
ec393f4
codecov fix
multiphaseCFD Sep 22, 2023
f3f1a85
quick fix
multiphaseCFD Sep 22, 2023
4ff0c61
quick fix
multiphaseCFD Sep 22, 2023
34a05d9
quick fix
multiphaseCFD Sep 22, 2023
60b2a3d
quick test
multiphaseCFD Sep 22, 2023
9bbd2d4
fix test
multiphaseCFD Sep 22, 2023
d96d793
fix tests
multiphaseCFD Sep 22, 2023
a290364
another quick fix
multiphaseCFD Sep 22, 2023
41d90e3
coverage fix
multiphaseCFD Sep 22, 2023
1410fee
update ci tests
multiphaseCFD Sep 22, 2023
08c8453
update ci for no binary
multiphaseCFD Sep 22, 2023
394ceab
codecov fix
multiphaseCFD Sep 22, 2023
79a6c34
update adj tests for no binary case
multiphaseCFD Sep 22, 2023
2d238eb
update python layer tests
multiphaseCFD Sep 22, 2023
98db424
fix codecov
multiphaseCFD Sep 22, 2023
11fa5c2
make format
multiphaseCFD Sep 22, 2023
9a4bb0b
Merge branch 'add_LGPU' into add_LGPUMPI
multiphaseCFD Sep 25, 2023
939f7ce
initial commit for MPI
multiphaseCFD Sep 26, 2023
219cfde
revert to cu11
multiphaseCFD Sep 26, 2023
2530925
enable more py tests
multiphaseCFD Sep 27, 2023
314c06d
update CI
multiphaseCFD Sep 27, 2023
9b9fbbe
upload codecov ci
multiphaseCFD Sep 27, 2023
d1b05f9
add more tests for statevectorcudamanaged
multiphaseCFD Sep 27, 2023
9e3e834
add more unit tests
multiphaseCFD Sep 27, 2023
4d1ea37
add more tests
multiphaseCFD Sep 27, 2023
b54759e
make format
multiphaseCFD Sep 27, 2023
a27d1a1
add more cpp tests
multiphaseCFD Sep 27, 2023
d353a6e
skip cpp tests pauli param gates
multiphaseCFD Sep 27, 2023
cfd7f3b
make format
multiphaseCFD Sep 27, 2023
1fbad9f
add more files to gitignore
multiphaseCFD Sep 27, 2023
43c7e52
Merge branch 'master' into add_LGPU
multiphaseCFD Sep 27, 2023
893c61b
Auto update version
github-actions[bot] Sep 27, 2023
8f56589
Merge branch 'add_LGPU' into add_LGPUMPI
multiphaseCFD Sep 27, 2023
f572875
init commit
multiphaseCFD Oct 2, 2023
722cc28
Trigger CI
multiphaseCFD Oct 2, 2023
6f49902
update gpu runner
multiphaseCFD Oct 10, 2023
36ea421
quick fix
multiphaseCFD Oct 10, 2023
643d9b0
update fix
multiphaseCFD Oct 10, 2023
1229ea6
add cpp layer for LGPU-MPI backend
multiphaseCFD Oct 11, 2023
77dacd5
add py layer
multiphaseCFD Oct 12, 2023
68a798c
quick fix
multiphaseCFD Oct 12, 2023
3a06309
make format
multiphaseCFD Oct 12, 2023
8044aad
fix for fp32 support in expval calculation
multiphaseCFD Oct 12, 2023
e099fc4
quick fix
multiphaseCFD Oct 12, 2023
38773b7
fix for cray_mpich_serialize_py
multiphaseCFD Oct 13, 2023
c8f9f1a
copy to move for hamiltonian operation
multiphaseCFD Oct 13, 2023
4edb007
add unit tests for adjoint method
multiphaseCFD Oct 13, 2023
3e80ce6
add more tests
multiphaseCFD Oct 13, 2023
114438a
resolve comments py layer
multiphaseCFD Oct 13, 2023
7e825ce
remove omp support in LGPU
multiphaseCFD Oct 13, 2023
6efb5dc
Merge branch 'master' into add_LGPU
multiphaseCFD Oct 13, 2023
19f85e1
update version
multiphaseCFD Oct 13, 2023
b7ef71f
Auto update version
github-actions[bot] Oct 13, 2023
ade064d
fix based on comments
multiphaseCFD Oct 13, 2023
500a0c4
Add L-GPU and L-Kokkos as package extras (#515)
mlxd Oct 13, 2023
52d7293
Auto update version
github-actions[bot] Oct 13, 2023
f09db5f
Merge branch 'master' into add_LGPU
multiphaseCFD Oct 13, 2023
8888060
make format
multiphaseCFD Oct 13, 2023
6b503b7
remove sparseH
multiphaseCFD Oct 15, 2023
997515f
remove applyHostMatrixGate
multiphaseCFD Oct 15, 2023
c263264
Add wheel_linux_x86_64_cu11.yml (#517)
vincentmr Oct 16, 2023
e6d802c
resolve more comments
multiphaseCFD Oct 16, 2023
6d9c443
add more tests to non_param gates
multiphaseCFD Oct 16, 2023
3f6268c
resolve cpp tests comments
multiphaseCFD Oct 16, 2023
db04384
remove unused methods in measurement class
multiphaseCFD Oct 16, 2023
cba4849
remove unused methods
multiphaseCFD Oct 16, 2023
34e00d2
resolve more comments
multiphaseCFD Oct 17, 2023
61ba81a
add changelog and matrixhasher
multiphaseCFD Oct 17, 2023
5be027b
quick update
multiphaseCFD Oct 17, 2023
1d1793c
Merge branch 'add_LGPU' into add_LGPUMPI
multiphaseCFD Oct 17, 2023
8b42b8c
add more tests and merge base branch
multiphaseCFD Oct 17, 2023
6633d2e
add mpi unit tests for algorithm base class
multiphaseCFD Oct 18, 2023
f89e4d0
add more unit tests for utils
multiphaseCFD Oct 18, 2023
9232e92
ctor test for MPIManager
multiphaseCFD Oct 18, 2023
9d172dc
Add mpi tests to LGPU (#519)
vincentmr Oct 18, 2023
7bc687e
add CI checks for cpp unit tests
multiphaseCFD Oct 18, 2023
9a7cc37
add cpp layer ci check for mpi backend
multiphaseCFD Oct 18, 2023
6520923
Merge branch 'master' into add_LGPUMPI
multiphaseCFD Oct 18, 2023
9310500
Auto update version
github-actions[bot] Oct 18, 2023
747f72d
remove redundant blank lines
multiphaseCFD Oct 18, 2023
bf776c5
tidy up code
multiphaseCFD Oct 18, 2023
8a69d05
Trigger CI
multiphaseCFD Oct 18, 2023
3a18ce0
remove single GPU backend tests in mpi ci
multiphaseCFD Oct 19, 2023
e7a0d44
upload codecov results
multiphaseCFD Oct 19, 2023
63f98ae
add more unit tests
multiphaseCFD Oct 19, 2023
bef8e97
add tests for pauli word based expval
multiphaseCFD Oct 19, 2023
3ba0c9a
add more docs
multiphaseCFD Oct 19, 2023
5532fc8
add more tests
multiphaseCFD Oct 19, 2023
79a3e46
skip lcov for native gates
multiphaseCFD Oct 19, 2023
48aed47
add mpi_helpers
multiphaseCFD Oct 19, 2023
63cef9a
add more docstrings
multiphaseCFD Oct 19, 2023
717f8d5
add change log
multiphaseCFD Oct 19, 2023
8973ee8
Merge branch 'master' into add_LGPUMPI
multiphaseCFD Oct 19, 2023
4d47ea0
Auto update version
github-actions[bot] Oct 19, 2023
5a75cfe
Merge branch 'add_LGPUMPI' into add_py_LGPUMPI
multiphaseCFD Oct 19, 2023
e17728d
Auto update version
github-actions[bot] Oct 19, 2023
69dc625
fix failures caused by merging
multiphaseCFD Oct 20, 2023
dc25439
add changelog
multiphaseCFD Oct 20, 2023
34c3b9a
Trigger multi-GPU runner
multiphaseCFD Oct 20, 2023
f9974b8
add more fp32 tests to the measurement class
multiphaseCFD Oct 20, 2023
84e2eb6
add number of devices and mpi procs check
multiphaseCFD Oct 23, 2023
6ad1c7c
Add coverage for py-mpitests. (#522)
vincentmr Oct 23, 2023
d3af819
Merge branch 'add_LGPUMPI' into add_py_LGPUMPI
vincentmr Oct 23, 2023
d0f6a89
add more tests in obs base class
multiphaseCFD Oct 23, 2023
2f82e1b
Merge branch 'fix_linting_lgpu' into add_LGPUMPI
multiphaseCFD Oct 23, 2023
1cca83d
Revert "Merge branch 'add_LGPUMPI' into add_py_LGPUMPI"
multiphaseCFD Oct 23, 2023
935a6c0
resolve comments on source codes and tidy up code
multiphaseCFD Oct 23, 2023
09538c8
Use CRTP to define initSV and remove initSV_MPI
multiphaseCFD Oct 23, 2023
1a33cdb
resolve more typos
multiphaseCFD Oct 23, 2023
c32b60d
resolve more typoes
multiphaseCFD Oct 23, 2023
740308f
resolve adjoint class
multiphaseCFD Oct 23, 2023
3bcad80
remove py&pybind layer
multiphaseCFD Oct 23, 2023
baaee12
resolve more comments
multiphaseCFD Oct 24, 2023
57fbf38
Remove redundant blank line
multiphaseCFD Oct 24, 2023
50c87e0
add num mpi & ngpudevice proc check
multiphaseCFD Oct 24, 2023
acec720
fix typo
multiphaseCFD Oct 24, 2023
faf39da
add more tests
multiphaseCFD Oct 24, 2023
9dc9181
make format
multiphaseCFD Oct 24, 2023
eabf80d
resolve more comments
multiphaseCFD Oct 24, 2023
1934338
check->require
multiphaseCFD Oct 24, 2023
839025c
make format
multiphaseCFD Oct 24, 2023
46df045
update docs
multiphaseCFD Oct 24, 2023
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

* Integrate the distributed C++ backend of Lightning-GPU into the Lightning monorepo.
[(#514)] (https://github.com/PennyLaneAI/pennylane-lightning/pull/514)

* Integrate Lightning-GPU into the Lightning monorepo. The new backend is named `lightning_gpu` and includes all single-GPU features.
[(#499)] (https://github.com/PennyLaneAI/pennylane-lightning/pull/499)

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests_gpu_cu11.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Testing::Linux::x86_64 (Lightning-GPU)
name: Testing::Linux::x86_64::LGPU
on:
pull_request:
push:
Expand Down Expand Up @@ -143,7 +143,7 @@ jobs:
if-no-files-found: error

pythontestswithLGPU:
needs: [builddeps]
needs: [builddeps, cpptestswithLGPU_cu11]
strategy:
matrix:
os: [ubuntu-22.04]
Expand Down
185 changes: 185 additions & 0 deletions .github/workflows/tests_linux_x86_mpi.yml
multiphaseCFD marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
name: Tests::Linux::x86_64::LGPU::MPI
on:
workflow_call:
inputs:
lightning-version:
type: string
required: true
description: The version of lightning to use. Valid values are either 'stable' (most recent git-tag) or 'latest' (most recent commit from master)
pennylane-version:
type: string
required: true
description: The version of PennyLane to use. Valid values are either 'stable' (most recent git-tag) or 'latest' (most recent commit from master)
release:
push:
branches:
- main
pull_request:

env:
COVERAGE_FLAGS: "--cov=pennylane_lightning --cov-report=term-missing --cov-report=xml:./coverage.xml --no-flaky-report -p no:warnings --tb=native"
GCC_VERSION: 11
OMP_NUM_THREADS: "2"
CI_CUDA_ARCH: 86

concurrency:
group: gpu-test-mpi-${{ github.ref }}-${{ inputs.lightning-version }}-${{ inputs.pennylane-version }}
cancel-in-progress: true

jobs:
cpp_tests:
if: contains(github.event.pull_request.labels.*.name, 'ci:use-multi-gpu-runner') || (inputs.lightning-version != '' && inputs.pennylane-version != '')
multiphaseCFD marked this conversation as resolved.
Show resolved Hide resolved
runs-on:
- self-hosted
- linux
- x64
- ubuntu-22.04
- multi-gpu
strategy:
max-parallel: 1
matrix:
mpilib: ["mpich", "openmpi"]
timeout-minutes: 30

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-tags: true

- name: Switch to stable build of Lightning-GPU
if: inputs.lightning-version == 'stable'
run: |
git fetch tags --force
git checkout $(git tag | sort -V | tail -1)
- uses: actions/setup-python@v4
id: setup_python
name: Install Python
with:
python-version: '3.9'

# Since the self-hosted runner can be re-used. It is best to set up all package
# installations in a virtual environment that gets cleaned at the end of each workflow run
- name: Setup Python virtual environment
id: setup_venv
env:
VENV_NAME: ${{ github.workspace }}/venv_${{ steps.setup_python.outputs.python-version }}_${{ github.sha }}
run: |
# Clear any pre-existing venvs
rm -rf venv_*

# Create new venv for this workflow_run
python --version
python -m venv ${{ env.VENV_NAME }}

# Add the venv to PATH for subsequent steps
echo ${{ env.VENV_NAME }}/bin >> $GITHUB_PATH

# Adding venv name as an output for subsequent steps to reference if needed
echo "venv_name=${{ env.VENV_NAME }}" >> $GITHUB_OUTPUT

- name: Display Python-Path
id: python_path
run: |
py_path=$(which python)
echo "Python Interpreter Path => $py_path"
echo "python=$py_path" >> $GITHUB_OUTPUT

pip_path=$(which python)
echo "PIP Path => $pip_path"
echo "pip=$pip_path" >> $GITHUB_OUTPUT

- name: Install required packages
run: |
python -m pip install ninja cmake custatevec-cu11

- name: Validate GPU version and installed compiler
run: |
source /etc/profile.d/modules.sh && module use /opt/modules && module load cuda/11.8
which -a nvcc
nvcc --version
- name: Validate Multi-GPU packages
run: |
source /etc/profile.d/modules.sh && module use /opt/modules/ && module load ${{ matrix.mpilib }}
echo 'Checking for ${{ matrix.mpilib }}'
which -a mpirun
mpirun --version
which -a mpicxx
mpicxx --version
module unload ${{ matrix.mpilib }}
- name: Install Latest PennyLane
if: inputs.pennylane-version == 'latest'
run: python -m pip install git+https://github.com/PennyLaneAI/pennylane.git@master

- name: Build and run unit tests
run: |
source /etc/profile.d/modules.sh && module use /opt/modules/ && module load ${{ matrix.mpilib }}
export CUQUANTUM_SDK=$(python -c "import site; print( f'{site.getsitepackages()[0]}/cuquantum/lib')")
cmake . -BBuild \
-DPL_BACKEND=lightning_gpu \
-DENABLE_MPI=ON \
-DCMAKE_BUILD_TYPE=Debug \
-DENABLE_COVERAGE=ON \
-DBUILD_TESTS=ON \
-DCMAKE_CXX_COMPILER=mpicxx \
-DCMAKE_CUDA_COMPILER="/usr/local/cuda/bin/nvcc" \
-DCMAKE_CUDA_ARCHITECTURES="86" \
-DPython_EXECUTABLE:FILE="${{ steps.python_path.outputs.python }}" \
-G Ninja
cmake --build ./Build
cd ./Build
mkdir -p ./tests/results
for file in *runner ; do ./$file --order lex --reporter junit --out ./tests/results/report_$file.xml; done;
for file in *runner_mpi ; do /opt/mpi/${{ matrix.mpilib }}/bin/mpirun -np 2 ./$file --order lex --reporter junit --out ./tests/results/report_$file.xml; done;
lcov --directory . -b ../pennylane_lightning/src --capture --output-file coverage.info
lcov --remove coverage.info '/usr/*' --output-file coverage.info
mv coverage.info coverage-${{ github.job }}-lightning_gpu_${{ matrix.mpilib }}.info

- name: Upload test results
uses: actions/upload-artifact@v3
if: always()
with:
if-no-files-found: error
name: ubuntu-tests-reports
path: ./Build/tests/results/

- name: Upload code coverage results
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: ubuntu-codecov-results-cpp
path: ./Build/coverage-${{ github.job }}-lightning_gpu_${{ matrix.mpilib }}.info

- name: Cleanup
if: always()
run: |
rm -rf ${{ steps.setup_venv.outputs.venv_name }}
rm -rf * .git .gitignore .github
pip cache purge

upload-to-codecov-linux-cpp:
needs: ["cpp_tests"]
name: Upload coverage data to codecov
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Download coverage reports
uses: actions/download-artifact@v3
with:
name: ubuntu-codecov-results-cpp

- name: Upload to Codecov
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Cleanup
if: always()
run: |
rm -rf ${{ steps.setup_venv.outputs.venv_name }}
rm -rf * .git .gitignore .github
pip cache purge
52 changes: 26 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,24 @@ TESTRUNNER := -m pytest tests --tb=short

PL_BACKEND?="$(if $(backend:-=),$(backend),lightning_qubit)"

ifdef verbose
VERBOSE := --verbose
else
VERBOSE :=
endif

ifdef check
CHECK := --check
else
CHECK :=
endif

ifdef build_options
OPTIONS := $(build_options)
else
OPTIONS :=
endif

ifdef verbose
VERBOSE := --verbose
else
VERBOSE :=
endif

.PHONY: help
help:
@echo "Please use \`make <target>' where <target> is one of"
Expand Down Expand Up @@ -56,16 +62,7 @@ clean:
rm -rf .coverage coverage_html_report/
rm -rf pennylane_lightning/*_ops*

.PHONY : test-builtin test-suite test-python coverage coverage-cpp test-cpp test-cpp-no-omp test-cpp-blas test-cpp-kokkos
test-builtin:
PL_DEVICE=$(if $(device:-=),$(device),lightning.qubit) $(PYTHON) -I $(TESTRUNNER)

test-suite:
pl-device-test --device $(if $(device:-=),$(device),lightning.qubit) --skip-ops --shots=20000
pl-device-test --device $(if $(device:-=),$(device),lightning.qubit) --shots=None --skip-ops

test-python: test-builtin test-suite

.PHONY : test-builtin test-suite test-python test-cpp coverage coverage-cpp
coverage:
@echo "Generating coverage report for $(if $(device:-=),$(device),lightning.qubit) device:"
$(PYTHON) $(TESTRUNNER) $(COVERAGE)
Expand All @@ -75,20 +72,29 @@ coverage:
coverage-cpp:
@echo "Generating cpp coverage report in BuildCov/out for $(PL_BACKEND) backend"
rm -rf ./BuildCov
cmake -BBuildCov -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DENABLE_COVERAGE=ON -DPL_BACKEND=$(PL_BACKEND)
cmake -BBuildCov -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DENABLE_COVERAGE=ON -DPL_BACKEND=$(PL_BACKEND) $(OPTIONS)
cmake --build ./BuildCov
cd ./BuildCov; for file in *runner ; do ./$file; done; \
lcov --directory . -b ../pennylane_lightning/core/src --capture --output-file coverage.info; \
genhtml coverage.info --output-directory out

build:
rm -rf ./Build
cmake -BBuild -G Ninja -DENABLE_BLAS=ON -DENABLE_WARNINGS=ON -DPL_BACKEND=$(PL_BACKEND)
cmake -BBuild -G Ninja -DENABLE_WARNINGS=ON -DPL_BACKEND=$(PL_BACKEND) $(OPTIONS)
cmake --build ./Build $(VERBOSE)

test-builtin:
PL_DEVICE=$(if $(device:-=),$(device),lightning.qubit) $(PYTHON) -I $(TESTRUNNER)

test-suite:
pl-device-test --device $(if $(device:-=),$(device),lightning.qubit) --skip-ops --shots=20000
pl-device-test --device $(if $(device:-=),$(device),lightning.qubit) --shots=None --skip-ops

test-python: test-builtin test-suite

test-cpp:
rm -rf ./BuildTests
cmake -BBuildTests -G Ninja -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DENABLE_OPENMP=ON -DENABLE_WARNINGS=ON -DPL_BACKEND=$(PL_BACKEND)
cmake -BBuildTests -G Ninja -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DENABLE_WARNINGS=ON -DPL_BACKEND=$(PL_BACKEND) $(OPTIONS)
ifdef target
cmake --build ./BuildTests $(VERBOSE) --target $(target)
OMP_PROC_BIND=false ./BuildTests/$(target)
Expand All @@ -97,12 +103,6 @@ else
OMP_PROC_BIND=false cmake --build ./BuildTests $(VERBOSE) --target test
endif

test-cpp-blas:
rm -rf ./BuildTests
cmake -BBuildTests -G Ninja -DBUILD_TESTS=ON -DENABLE_BLAS=ON -DENABLE_WARNINGS=ON -DPL_BACKEND=$(PL_BACKEND)
cmake --build ./BuildTests $(VERBOSE)
cmake --build ./BuildTests $(VERBOSE) --target test

.PHONY: format format-cpp
format: format-cpp format-python

Expand All @@ -115,7 +115,7 @@ format-python:
.PHONY: check-tidy
check-tidy:
rm -rf ./BuildTidy
cmake -BBuildTidy -DENABLE_CLANG_TIDY=ON -DBUILD_TESTS=ON -DENABLE_WARNINGS=ON -DPL_BACKEND=$(PL_BACKEND)
cmake -BBuildTidy -DENABLE_CLANG_TIDY=ON -DBUILD_TESTS=ON -DENABLE_WARNINGS=ON -DPL_BACKEND=$(PL_BACKEND) $(OPTIONS)
ifdef target
cmake --build ./BuildTidy $(VERBOSE) --target $(target)
else
Expand Down
3 changes: 0 additions & 3 deletions cmake/process_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ if(ENABLE_NATIVE)
target_compile_options(lightning_compile_options INTERFACE -march=native)
endif()

if(ENABLE_MPI)
set(ENABLE_OPENMP OFF)
endif()
multiphaseCFD marked this conversation as resolved.
Show resolved Hide resolved
multiphaseCFD marked this conversation as resolved.
Show resolved Hide resolved

if(PLLGPU_DISABLE_CUDA_SAFETY)
target_compile_options(lightning_compile_options INTERFACE $<$<COMPILE_LANGUAGE:CXX>:-DCUDA_UNSAFE>)
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.33.0-dev22"
__version__ = "0.33.0-dev23"
4 changes: 4 additions & 0 deletions pennylane_lightning/core/src/algorithms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ project(lightning_algorithms LANGUAGES CXX)

add_library(lightning_algorithms INTERFACE)

if(ENABLE_MPI)
target_compile_options(lightning_compile_options INTERFACE "-D_ENABLE_MPI=1")
endif()

target_include_directories(lightning_algorithms INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(lightning_algorithms INTERFACE lightning_compile_options
lightning_external_libs
Expand Down
26 changes: 26 additions & 0 deletions pennylane_lightning/core/src/algorithms/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,29 @@ target_link_libraries(algorithms_test_runner PRIVATE algorithms_tests)
catch_discover_tests(algorithms_test_runner)

install(TARGETS algorithms_test_runner DESTINATION bin)

if(ENABLE_MPI)
add_library(algorithms_tests_mpi INTERFACE)
target_link_libraries(algorithms_tests_mpi INTERFACE Catch2::Catch2)
foreach(BACKEND ${PL_BACKEND})
target_link_libraries(algorithms_tests_mpi INTERFACE ${BACKEND}
"${BACKEND}_gates"
"${BACKEND}_measurements"
"${BACKEND}_algorithms"
"${BACKEND}_observables"
)
endforeach()

ProcessTestOptions(algorithms_tests_mpi)

target_sources(algorithms_tests_mpi INTERFACE ./mpi/runner_algorithms_mpi.cpp)

################################################################################
# Define targets
################################################################################
set(TEST_SOURCES ./mpi/Test_AdjointJacobianMPI.cpp)

add_executable(algorithms_test_runner_mpi ${TEST_SOURCES})
target_link_libraries(algorithms_test_runner_mpi PRIVATE algorithms_tests_mpi)
catch_discover_tests(algorithms_test_runner_mpi)
endif()
Loading
Loading