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

Testing/gpu #494

Merged
merged 120 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
052c106
Adding test workflow to trigger self-hosted runner build
rashidnhm Sep 6, 2023
f13670c
Add Kokkos CUDA build.
vincentmr Sep 6, 2023
8e6aa46
Turn off format.yml
vincentmr Sep 6, 2023
bce8c49
Force 1cache-hit
vincentmr Sep 6, 2023
69b1e3b
Fix repo path.
vincentmr Sep 6, 2023
e52ac1b
Add nvcc to path.
vincentmr Sep 6, 2023
3a40df3
CUDA 12.0
vincentmr Sep 6, 2023
55b45c6
Auto update version
github-actions[bot] Sep 11, 2023
c162960
Load module.
vincentmr Sep 11, 2023
341ad20
Move cuda module up.
vincentmr Sep 11, 2023
12d7cd4
Mod spider cuda.
vincentmr Sep 11, 2023
47c4af1
Remove apt-get statements.
vincentmr Sep 11, 2023
0446c54
Remove mod spider.
vincentmr Sep 11, 2023
6a7bcd6
ls module/cuda
vincentmr Sep 11, 2023
ae70b6b
ls modules
vincentmr Sep 11, 2023
ec99762
ls -l /opt/modules/cuda
vincentmr Sep 11, 2023
ee074b2
Try see nvcc
rashidnhm Sep 13, 2023
9e622cc
Auto update version
github-actions[bot] Sep 13, 2023
aeb7fe0
Debug
rashidnhm Sep 13, 2023
0ce84a0
Merge branch 'testing/gpu' of github.com:PennyLaneAI/pennylane-lightn…
rashidnhm Sep 13, 2023
9482879
Merge branch 'master' of github.com:PennyLaneAI/pennylane-lightning i…
rashidnhm Sep 13, 2023
547ce79
Debug
rashidnhm Sep 13, 2023
fe34f72
Debug
rashidnhm Sep 13, 2023
acfdb9b
Debug
rashidnhm Sep 13, 2023
63bd74f
Debug
rashidnhm Sep 13, 2023
82120ae
Trigger CI
rashidnhm Sep 13, 2023
a4c006c
Try export path.
vincentmr Sep 13, 2023
e8d635a
Add gpu cpp tests.
vincentmr Sep 13, 2023
c05735b
Fix exec_model.
vincentmr Sep 13, 2023
ce24117
dont hit cache
vincentmr Sep 13, 2023
23e197f
key inputs.os
vincentmr Sep 13, 2023
3cf7004
Fix kokkos install?
vincentmr Sep 14, 2023
96e095a
Remove cleanup setp.
vincentmr Sep 14, 2023
4bab1c4
Always source cuda-12 mod.
vincentmr Sep 14, 2023
c45643a
Try that
vincentmr Sep 14, 2023
d4abc37
Fix key
vincentmr Sep 14, 2023
9112dee
Clear before cloning kokkos.
vincentmr Sep 14, 2023
f76a96b
No need to checkout kokkos ver.
vincentmr Sep 14, 2023
b514740
git clone --branch
vincentmr Sep 14, 2023
701fa3d
Merge coverage with tests. Move cache up in pythontests.
vincentmr Sep 14, 2023
ad78afd
trigger CI
vincentmr Sep 14, 2023
097c08f
Comment cache-hit.
vincentmr Sep 14, 2023
8fe637e
Clean Kokkos before copying.
vincentmr Sep 14, 2023
15b4a83
Fix cmake -B step in cpp tests.
vincentmr Sep 14, 2023
a07dd43
trigger CI
vincentmr Sep 14, 2023
63cb42f
fail-on-cache-miss
vincentmr Sep 14, 2023
4378148
Fix buildcov path
vincentmr Sep 14, 2023
c6258ef
sleep
vincentmr Sep 14, 2023
c56a858
if-no-files-found: error
vincentmr Sep 14, 2023
4a66592
fail-on-cache-miss everywhere.
vincentmr Sep 14, 2023
a822e42
Reenable pull_request trigger.
vincentmr Sep 14, 2023
7d19a03
Replace cache path.
vincentmr Sep 14, 2023
d89002f
Fix cache path.
vincentmr Sep 14, 2023
7426383
Restore ${{ github.workspace }} paths except test-gpu
vincentmr Sep 14, 2023
61ca984
cache is lru.
vincentmr Sep 14, 2023
d99c828
Copy cached if cache-hit.
vincentmr Sep 14, 2023
5f08021
Restore triggers.
vincentmr Sep 14, 2023
47c71f2
Update changelog.
vincentmr Sep 15, 2023
882ece0
Combine tests with codecov.
vincentmr Sep 15, 2023
cf59425
No cp -rf. Use debug builds.
vincentmr Sep 15, 2023
a71a0e2
Fix Kokkos/ tmp path.
vincentmr Sep 15, 2023
ac1bdae
ls Kokkos
vincentmr Sep 15, 2023
93b9445
Force build kokkos.
vincentmr Sep 15, 2023
87e7864
Restore ${{ github.workspace }}/ path
vincentmr Sep 15, 2023
4d37540
Use rel dirs.
vincentmr Sep 15, 2023
1e718ee
ls -ltrh
vincentmr Sep 15, 2023
481e0ea
Pust back {{ github.workspace }}/ prefix path.
vincentmr Sep 15, 2023
25139b6
Comment pull_request:
vincentmr Sep 15, 2023
5b80798
Change cache key.
vincentmr Sep 15, 2023
ba55e28
Switch back to relative paths.
vincentmr Sep 15, 2023
f1d29e0
Try github.workspace paths and ls
vincentmr Sep 15, 2023
74d6304
Merge branch 'master' into testing/gpu
vincentmr Sep 15, 2023
ef93fdc
save/restore
vincentmr Sep 15, 2023
8c8089e
Fix syntax error.
vincentmr Sep 15, 2023
55435a5
Move save cache down.
vincentmr Sep 15, 2023
f030271
Add CUDA-12 to env.
vincentmr Sep 15, 2023
ada5a30
cd main
vincentmr Sep 15, 2023
e47acb4
Skip c++ tests.
vincentmr Sep 15, 2023
3a32caf
Comment pl-device-test.
vincentmr Sep 15, 2023
fead291
Mod OMP_ params.
vincentmr Sep 18, 2023
7fe7d60
Try || true
vincentmr Sep 18, 2023
84cac81
trigger CI
vincentmr Sep 18, 2023
b582371
Sleep tests.
vincentmr Sep 18, 2023
1d76edd
Add kokkos test.
vincentmr Sep 21, 2023
20dea67
Merge branch 'master' into testing/gpu
vincentmr Sep 21, 2023
b498805
Install gfortran
vincentmr Sep 21, 2023
b5148ce
Which gfortran.
vincentmr Sep 21, 2023
9e3e4f7
set -x
vincentmr Sep 21, 2023
2345742
or
vincentmr Sep 21, 2023
797fbeb
Build on kokkos@dev
vincentmr Sep 21, 2023
117ed04
Install lightning_qubit prior
vincentmr Sep 21, 2023
81c3090
Fix kokkos commit.
vincentmr Sep 22, 2023
8182a3a
git checkout kokkos
vincentmr Sep 22, 2023
3fede7d
Update kokkos commit.
vincentmr Sep 22, 2023
e97b3bf
Restore all
vincentmr Sep 22, 2023
fbc05fe
Add kokkos init/finalize bindings.
vincentmr Sep 22, 2023
f981892
Restore pull_req triggers.
vincentmr Sep 22, 2023
3c265f8
Auto update version
github-actions[bot] Sep 22, 2023
420098b
Remove set-x
vincentmr Sep 22, 2023
4f19bcb
Remove commented ifs.
vincentmr Sep 22, 2023
60371aa
Switch all order.
vincentmr Sep 22, 2023
32e0c15
trigger CI
vincentmr Sep 22, 2023
905a200
trigger CI
vincentmr Sep 22, 2023
ad0a453
Revert to e97b3bf
vincentmr Sep 22, 2023
183a42d
Comment pull_requests.
vincentmr Sep 22, 2023
8964ec8
Restore triggers.
vincentmr Sep 22, 2023
00aa854
runs-on gpu
vincentmr Sep 22, 2023
90b7bba
Merge branch 'master' into testing/gpu
vincentmr Sep 22, 2023
e8dcdb3
Auto update version
github-actions[bot] Sep 22, 2023
39a6b01
trigger CI
vincentmr Sep 22, 2023
2aab322
Set KOKKOS_VERSION in env.
vincentmr Oct 2, 2023
3e2a849
Merge branch 'master' into testing/gpu
vincentmr Oct 2, 2023
d70f920
Auto update version
github-actions[bot] Oct 2, 2023
062393d
trigger CI
vincentmr Oct 2, 2023
0d013b1
Remove unnecessary fetch-depth.
vincentmr Oct 5, 2023
be0fa5c
Remove unwanted ISWAP changes.
vincentmr Oct 10, 2023
1567101
Merge branch 'master' into testing/gpu
vincentmr Oct 11, 2023
76c0676
Auto update version
github-actions[bot] Oct 11, 2023
baba8e7
trigger CI
vincentmr Oct 11, 2023
105a6e0
Remove remnants of ENABLE_KOKKOS.
vincentmr Oct 11, 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 @@ -10,6 +10,9 @@

### Breaking changes

* Add `tests_gpu.yml` workflow to test the Lightning-Kokkos backend with CUDA-12.
[(#494)](https://github.com/PennyLaneAI/pennylane-lightning/pull/494)

* Implement `LM::GeneratorDoubleExcitation`, `LM::GeneratorDoubleExcitationMinus`, `LM::GeneratorDoubleExcitationPlus` kernels. L-Qubit default kernels are now strictly from the `LM` implementation, which requires less memory and is faster for large state vectors.
[(#512)](https://github.com/PennyLaneAI/pennylane-lightning/pull/512)

Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/build_and_cache_Kokkos_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ jobs:
- name: Clone Kokkos repository
if: steps.kokkos-cache.outputs.cache-hit != 'true'
run: |
git clone https://github.com/kokkos/kokkos.git
cd kokkos
git checkout ${{ matrix.kokkos_version }}
cd -
git clone --branch ${{ matrix.kokkos_version }} https://github.com/kokkos/kokkos.git
pushd . &> /dev/null

- name: Install dependencies (Ubuntu)
Expand Down
298 changes: 298 additions & 0 deletions .github/workflows/tests_gpu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,298 @@
name: Testing (GPU)
on:
pull_request:
push:
branches:
- master

env:
CI_CUDA_ARCH: 86
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
KOKKOS_VERSION: e542e989af99cb87881ee2a0d06916541ee76006
TF_VERSION: 2.10.0
TORCH_VERSION: 1.11.0+cpu

concurrency:
group: tests_gpu-${{ github.ref }}
cancel-in-progress: true

jobs:
builddeps:
runs-on:
- self-hosted
- ubuntu-22.04
- gpu

strategy:
max-parallel: 1
matrix:
os: [ubuntu-22.04]
exec_model: ["CUDA"]
kokkos_version: ["4.1.00"]

steps:
- name: Validate GPU version and installed compiler
run: |
source /etc/profile.d/modules.sh
module use /opt/modules
module load cuda/12.2
echo "${PATH}" >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> $GITHUB_ENV
nvcc --version
nvidia-smi

- name: Clone Kokkos repository
run: |
rm -rf kokkos_${{ matrix.exec_model }}
# git clone --branch fix-rtld-deepbind https://github.com/cz4rs/kokkos.git kokkos_${{ matrix.exec_model }}
# git clone --branch ${{ matrix.kokkos_version }} https://github.com/kokkos/kokkos.git kokkos_${{ matrix.exec_model }}
git clone --branch develop https://github.com/kokkos/kokkos.git kokkos_${{ matrix.exec_model }}
cd kokkos_${{ matrix.exec_model }}
git checkout $KOKKOS_VERSION
git log | head
cd -
pushd . &> /dev/null

- name: Build Kokkos core library (Ubuntu)
run: |
rm -rf ${{ github.workspace }}/Kokkos_install/${{ matrix.exec_model }}
mkdir -p ${{ github.workspace }}/Kokkos_install/${{ matrix.exec_model }}
cd kokkos_${{ matrix.exec_model }}
cmake -BBuild . -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/Kokkos_install/${{ matrix.exec_model }} \
-DKokkos_ENABLE_COMPLEX_ALIGN=OFF \
-DKokkos_ENABLE_SERIAL=ON \
-DKokkos_ENABLE_${{ matrix.exec_model }}=ON \
-DKokkos_ENABLE_DEPRECATION_WARNINGS=OFF \
-DCMAKE_CXX_COMPILER="$(which g++-$GCC_VERSION)" \
-DCMAKE_CXX_STANDARD=20 \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-G Ninja
cmake --build ./Build --verbose
cmake --install ./Build
cd -

- name: Test Kokkos core library (Ubuntu)
env:
CMAKE_PREFIX_PATH: ${{ github.workspace }}/Kokkos_install/${{ matrix.exec_model }}
run: |
set -x
sudo apt-get update && sudo apt-get -y -q install gfortran-$GCC_VERSION
cd kokkos_${{ matrix.exec_model }}/example/build_cmake_installed
which -a gfortran || which -a gfortran-$GCC_VERSION
cmake -B build -DCMAKE_Fortran_COMPILER=gfortran-$GCC_VERSION
cmake --build build
cmake --build build --target test
set +x

- name: Cache installation directories
id: kokkos-cache
uses: actions/cache/save@v3
with:
key: ${{ matrix.os }}-kokkos${{ matrix.kokkos_version }}-${{ matrix.exec_model }}-${{ github.ref }}-${{ github.sha }}
path: ${{ github.workspace }}/Kokkos_install/${{ matrix.exec_model }}

cpptestswithKokkos:
if: ${{ github.sha == 'xxxxxxxx' }}
vincentmr marked this conversation as resolved.
Show resolved Hide resolved
needs: [builddeps]
strategy:
matrix:
os: [ubuntu-22.04]
pl_backend: ["lightning_kokkos"]
exec_model: ["CUDA"]
kokkos_version: ["4.1.00"]

name: C++ tests (Kokkos)
runs-on:
- ${{ matrix.os }}
- self-hosted
- gpu

steps:
- name: Validate GPU version and installed compiler
run: |
source /etc/profile.d/modules.sh
module use /opt/modules
module load cuda/12.2
echo "${PATH}" >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> $GITHUB_ENV
nvcc --version
nvidia-smi

- name: Restoring cached dependencies
id: kokkos-cache
uses: actions/cache/restore@v3
with:
path: ${{ github.workspace }}/Kokkos_install/${{ matrix.exec_model }}
key: ${{ matrix.os }}-kokkos${{ matrix.kokkos_version }}-${{ matrix.exec_model }}-${{ github.ref }}-${{ github.sha }}
restore-keys: ${{ matrix.os }}-kokkos${{ matrix.kokkos_version }}-${{ matrix.exec_model }}-${{ github.ref }}-

- name: Copy cached libraries
run: |
mkdir -p ${{ github.workspace }}/Kokkos
ls -ltrh
cp -r ${{ github.workspace }}/Kokkos_install/${{ matrix.exec_model }}/* ${{ github.workspace }}/Kokkos

- name: Checkout PennyLane-Lightning
uses: actions/checkout@v3
with:
path: main

- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.9'

- name: Install dependencies
run: sudo apt-get update && sudo apt-get -y -q install cmake gcc-$GCC_VERSION g++-$GCC_VERSION ninja-build gcovr lcov

- name: Build and run unit tests
run: |
cd main
cmake . -BBuild -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DBUILD_TESTS=ON \
-DENABLE_PYTHON=OFF \
-DCMAKE_PREFIX_PATH=${{ github.workspace }}/Kokkos \
-DPL_BACKEND=${{ matrix.pl_backend }} \
-DCMAKE_CXX_COMPILER=$(which g++-$GCC_VERSION) \
-DENABLE_COVERAGE=ON
cmake --build ./Build
cd ./Build
mkdir -p ./tests/results_${{ github.job }}_${{ matrix.pl_backend }}
for file in *runner ; do ./$file --order lex --reporter junit --out ./tests/results_${{ github.job }}_${{ matrix.pl_backend }}/report_$file.xml; done;
lcov --directory . -b ../pennylane_lightning/core/src --capture --output-file coverage.info
lcov --remove coverage.info '/usr/*' --output-file coverage.info
mv coverage.info coverage-${{ github.job }}-${{ matrix.pl_backend }}.info

- name: Upload test results
uses: actions/upload-artifact@v3
if: always()
with:
name: ubuntu-tests-reports-${{ github.job }}_${{ matrix.pl_backend }}
path: ./main/Build/tests/results_${{ github.job }}_${{ matrix.pl_backend }}
if-no-files-found: error

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

pythontestswithKokkos:
needs: [builddeps]
strategy:
matrix:
os: [ubuntu-22.04]
pl_backend: ["lightning_kokkos", "all"]
exec_model: ["CUDA"]
kokkos_version: ["4.1.00"]

name: Python tests with Kokkos
runs-on:
- ${{ matrix.os }}
- self-hosted
- gpu

steps:
- name: Validate GPU version and installed compiler
run: |
source /etc/profile.d/modules.sh
module use /opt/modules
module load cuda/12.2
echo "${PATH}" >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> $GITHUB_ENV
nvcc --version
nvidia-smi

- name: Restoring cached dependencies
id: kokkos-cache
uses: actions/cache/restore@v3
with:
path: ${{ github.workspace }}/Kokkos_install/${{ matrix.exec_model }}
key: ${{ matrix.os }}-kokkos${{ matrix.kokkos_version }}-${{ matrix.exec_model }}-${{ github.ref }}-${{ github.sha }}
restore-keys: ${{ matrix.os }}-kokkos${{ matrix.kokkos_version }}-${{ matrix.exec_model }}-${{ github.ref }}-

- name: Copy cached libraries
run: |
mkdir -p ${{ github.workspace }}/Kokkos
ls -ltrh
cp -r ${{ github.workspace }}/Kokkos_install/${{ matrix.exec_model }}/* ${{ github.workspace }}/Kokkos

- name: Checkout PennyLane-Lightning
uses: actions/checkout@v3
with:
path: main

- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.9'

- name: Install dependencies
run: sudo apt-get update && sudo apt-get -y -q install cmake gcc-$GCC_VERSION g++-$GCC_VERSION

- name: Get required Python packages
run: |
cd main
python -m pip install -r requirements-dev.txt

- name: Install ML libraries for interfaces
run: |
python -m pip install --upgrade torch==$TORCH_VERSION -f https://download.pytorch.org/whl/cpu/torch_stable.html
python -m pip install --upgrade "jax[cpu]" # This also installs jaxlib
python -m pip install --upgrade tensorflow~=$TF_VERSION keras~=$TF_VERSION

- name: Install backend device
if: ${{ matrix.pl_backend != 'all'}}
run: |
ls -l ${{ github.workspace }}/Kokkos
cd main
SKIP_COMPILATION=True PL_BACKEND="lightning_qubit" pip install -e . -vv
CMAKE_ARGS="-DPL_BACKEND=${{ matrix.pl_backend }} -DCMAKE_PREFIX_PATH=${{ github.workspace }}/Kokkos -DENABLE_PYTHON=ON -DCMAKE_CXX_COMPILER=$(which g++-$GCC_VERSION)" \
python -m pip install -e . -vv

- name: Run PennyLane-Lightning unit tests
if: ${{ matrix.pl_backend != 'all'}}
env:
OMP_NUM_THREADS: 1
OMP_PROC_BIND: false
run: |
cd main/
DEVICENAME=`echo ${{ matrix.pl_backend }} | sed "s/_/./g"`
pl-device-test --device ${DEVICENAME} --skip-ops --shots=20000 $COVERAGE_FLAGS --cov-append 2> /dev/null || echo Something went wrong with pl-device-test shot=20000
pl-device-test --device ${DEVICENAME} --shots=None --skip-ops $COVERAGE_FLAGS --cov-append 2> /dev/null || echo Something went wrong with pl-device-test shot=None
PL_DEVICE=${DEVICENAME} python -m pytest tests/ $COVERAGE_FLAGS 2> /dev/null || echo Something went wrong with Pytest
mv coverage.xml coverage-${{ github.job }}.xml

- name: Install all backend devices
if: ${{ matrix.pl_backend == 'all' }}
run: |
cd main
CMAKE_ARGS="-DPL_BACKEND="lightning_qubit" -DCMAKE_PREFIX_PATH=${{ github.workspace }}/Kokkos -DENABLE_PYTHON=ON -DCMAKE_CXX_COMPILER=$(which g++-$GCC_VERSION)" \
python -m pip install -e . -vv
rm -rf build
CMAKE_ARGS="-DPL_BACKEND="lightning_kokkos" -DCMAKE_PREFIX_PATH=${{ github.workspace }}/Kokkos -DENABLE_PYTHON=ON -DCMAKE_CXX_COMPILER=$(which g++-$GCC_VERSION)" \
python -m pip install -e . -vv

- name: Run PennyLane-Lightning unit tests for lightning.qubit with all devices installed
if: ${{ matrix.pl_backend == 'all' }}
env:
OMP_NUM_THREADS: 1
OMP_PROC_BIND: false
run: |
cd main/
PL_DEVICE=lightning.qubit python -m pytest tests/ $COVERAGE_FLAGS
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-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.xml coverage-${{ github.job }}-${{ matrix.pl_backend }}.xml

- name: Upload code coverage results
uses: actions/upload-artifact@v3
with:
name: ubuntu-codecov-results-python
path: ./main/coverage-${{ github.job }}-${{ matrix.pl_backend }}.xml
Loading
Loading