Skip to content

Commit

Permalink
Merge lightning.gpu and lightning.tensor test CIs and add control by …
Browse files Browse the repository at this point in the history
…a label (#911)

**Context:** Merge lightning.gpu and lightning.tensor test CIs and add
control by a label

**Description of the Change:** Merge `lightning.gpu` and
`lightning.tensor` GPU tests in single Python and C++ CIs controlled by
the `ci:use-gpu-runner` label.

**Benefits:** Efficient CIs, faster queue, and code reduction.

**Possible Drawbacks:**

[sc-73818]

**Related GitHub Issues:**

---------

Co-authored-by: ringo-but-quantum <[email protected]>
  • Loading branch information
AmintorDusko and ringo-but-quantum authored Sep 19, 2024
1 parent eb709d5 commit 1acb133
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 515 deletions.
3 changes: 3 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@

### Improvements

* Merge `lightning.gpu` and `lightning.tensor` GPU tests in single Python and C++ CIs controlled by the `ci:use-gpu-runner` label.
[(#911)](https://github.com/PennyLaneAI/pennylane-lightning/pull/911)

* Update the test suite to remove deprecated code.
[(#912)](https://github.com/PennyLaneAI/pennylane-lightning/pull/912)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Testing::x86_64::LGPU::C++
name: Testing::x86_64::GPU::C++
on:
workflow_call:
inputs:
Expand All @@ -16,12 +16,6 @@ on:
- reopened
- synchronize
- ready_for_review
paths:
- .github/workflows/tests_lgpu_cpp.yml
- pennylane_lightning/core/src/**
- '!pennylane_lightning/core/src/simulators/lightning_kokkos/**'
- '!pennylane_lightning/core/src/simulators/lightning_qubit/**'
- '!pennylane_lightning/core/src/simulators/lightning_tensor/**'
push:
branches:
- master
Expand All @@ -30,16 +24,14 @@ 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
TF_VERSION: 2.10.0
TORCH_VERSION: 1.11.0+cpu

concurrency:
group: tests_lgpu_cpp-${{ github.ref }}-${{ github.event_name }}-${{ inputs.lightning-version }}-${{ inputs.pennylane-version }}
group: tests_gpu_cpp-${{ github.ref }}-${{ github.event_name }}-${{ inputs.lightning-version }}-${{ inputs.pennylane-version }}
cancel-in-progress: true

jobs:
builddeps:
if: github.event.pull_request.draft == false
if: ${{ github.event.pull_request.draft == false || contains(github.event.pull_request.labels.*.name, 'ci:use-gpu-runner') }}
runs-on:
- self-hosted
- ubuntu-22.04
Expand All @@ -61,16 +53,15 @@ jobs:
nvcc --version
nvidia-smi
cpptestswithLGPU:
cpptests:
if: ${{ !contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }}
needs: [builddeps]
strategy:
matrix:
pl_backend: ["lightning_gpu"]
enable_lapack: ["OFF"]
pl_backend: ["lightning_gpu", "lightning_tensor"]
cuda_version: ["12"]

name: C++ Tests (${{ matrix.pl_backend }}, cuda-${{ matrix.cuda_version }}, enable_lapack=${{ matrix.enable_lapack }})
name: C++ Tests (${{ matrix.pl_backend }}, cuda-${{ matrix.cuda_version }})
runs-on:
- ubuntu-22.04
- self-hosted
Expand All @@ -87,20 +78,20 @@ jobs:
nvcc --version
nvidia-smi
- name: Checkout PennyLane-Lightning-GPU
- name: Checkout PennyLane-Lightning
uses: actions/checkout@v4
with:
path: main

- uses: actions/setup-python@v5
name: Install Python
name: Setup Python
with:
python-version: '3.10'

- name: Setup Python virtual environment
id: setup_venv
env:
VENV_NAME: ${{ github.workspace }}/venv_${{ steps.setup_python.outputs.python-version }}_${{ github.sha }}
VENV_NAME: ${{ github.workspace }}/venv_${{ steps.setup_python.outputs.python-version }}_${{ github.sha }}_${{ matrix.pl_backend }}
run: |
# Clear any pre-existing venvs
rm -rf venv_*
Expand All @@ -117,7 +108,7 @@ jobs:
echo "Python_ROOT_DIR=${{ env.VENV_NAME }}" >> $GITHUB_ENV
echo "Python3_ROOT_DIR=${{ env.VENV_NAME }}" >> $GITHUB_ENV
# Adding venv site-packages to output for subsequent step to referecen if needed
# Adding venv site-packages to output for subsequent step to referece if needed
echo "site_packages_dir=$(${{ env.VENV_NAME }}/bin/python -c 'import sysconfig; print(sysconfig.get_path("platlib"))')" >> $GITHUB_OUTPUT
- name: Display Python-Path
Expand All @@ -131,10 +122,19 @@ jobs:
echo "PIP Path => $pip_path"
echo "pip=$pip_path" >> $GITHUB_OUTPUT
- name: Install required packages
- name: Install required basic packages
run: |
python -m pip install ninja cmake custatevec-cu${{ matrix.cuda_version }} scipy
sudo apt-get -y -q install liblapack-dev black
python -m pip install ninja cmake scipy
- name: Install required lightning_gpu only packages
if: matrix.pl_backend == 'lightning_gpu'
run: |
python -m pip install custatevec-cu${{ matrix.cuda_version }}
- name: Install required lightning_tensor only packages
if: matrix.pl_backend == 'lightning_tensor'
run: |
python -m pip install cutensornet-cu${{ matrix.cuda_version }}
- name: Build and run unit tests
run: |
Expand All @@ -143,40 +143,39 @@ jobs:
-DCUQUANTUM_SDK=$(python -c "import site; print( f'{site.getsitepackages()[0]}/cuquantum')")\
-DBUILD_TESTS=ON \
-DENABLE_PYTHON=OFF \
-DENABLE_LAPACK=${{ matrix.enable_lapack }} \
-DPL_BACKEND=${{ matrix.pl_backend }} \
-DCMAKE_CXX_COMPILER=$(which g++-$GCC_VERSION) \
-DENABLE_COVERAGE=ON \
-G Ninja
cmake --build ./Build
cd ./Build
mkdir -p ./tests/results_${{ github.job }}_${{ matrix.pl_backend }}-${{ matrix.enable_lapack }}
for file in *runner ; do ./$file --order lex --reporter junit --out ./tests/results_${{ github.job }}_${{ matrix.pl_backend }}-${{ matrix.enable_lapack }}/report_$file.xml; done;
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 }}-${{ matrix.enable_lapack }}.info
mv coverage.info coverage-${{ github.job }}-${{ matrix.pl_backend }}.info
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: ubuntu-tests-reports-${{ github.job }}_${{ matrix.pl_backend }}-${{ matrix.enable_lapack }}
path: ./main/Build/tests/results_${{ github.job }}_${{ matrix.pl_backend }}-${{ matrix.enable_lapack }}
name: ubuntu-tests-reports-${{ github.job }}_${{ matrix.pl_backend }}
path: ./main/Build/tests/results_${{ github.job }}_${{ matrix.pl_backend }}
retention-days: 1
if-no-files-found: error
include-hidden-files: true

- name: Upload code coverage results
uses: actions/upload-artifact@v4
with:
name: ubuntu-codecov-results-cpp-${{ matrix.pl_backend }}-${{ matrix.enable_lapack }}
path: ./main/Build/coverage-${{ github.job }}-${{ matrix.pl_backend }}-${{ matrix.enable_lapack }}.info
name: ubuntu-codecov-results-cpp-${{ matrix.pl_backend }}
path: ./main/Build/coverage-${{ github.job }}-${{ matrix.pl_backend }}.info
retention-days: 1
if-no-files-found: error
include-hidden-files: true

upload-to-codecov-linux-cpp:
needs: [cpptestswithLGPU]
needs: [cpptests]
name: Upload coverage data to codecov
runs-on: ubuntu-latest
steps:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Testing::x86_64::LGPU::Python
name: Testing::x86_64::GPU::Python
on:
workflow_call:
inputs:
Expand All @@ -16,16 +16,6 @@ on:
- reopened
- synchronize
- ready_for_review
paths-ignore:
- .github/**
- '!.github/workflows/tests_lgpu_python.yml'
- pennylane_lightning/core/_version.py
- pennylane_lightning/core/src/simulators/lightning_kokkos/**
- pennylane_lightning/core/src/simulators/lightning_qubit/**
- pennylane_lightning/core/src/simulators/lightning_tensor/**
- pennylane_lightning/lightning_kokkos/**
- pennylane_lightning/lightning_qubit/**
- pennylane_lightning/lightning_tensor/**
push:
branches:
- master
Expand All @@ -34,16 +24,14 @@ 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
TF_VERSION: 2.10.0
TORCH_VERSION: 1.11.0+cpu

concurrency:
group: tests_lgpu_python-${{ github.ref }}-${{ github.event_name }}-${{ inputs.lightning-version }}-${{ inputs.pennylane-version }}
group: tests_gpu_python-${{ github.ref }}-${{ github.event_name }}-${{ inputs.lightning-version }}-${{ inputs.pennylane-version }}
cancel-in-progress: true

jobs:
builddeps:
if: github.event.pull_request.draft == false
if: github.event.pull_request.draft == false || contains(github.event.pull_request.labels.*.name, 'ci:use-gpu-runner')
runs-on:
- self-hosted
- ubuntu-22.04
Expand All @@ -65,11 +53,11 @@ jobs:
nvcc --version
nvidia-smi
pythontestswithLGPU:
pythontestswithGPU:
needs: [builddeps]
strategy:
matrix:
pl_backend: ["lightning_gpu"]
pl_backend: ["lightning_gpu", "lightning_tensor"]
cuda_version: ["12"]

name: Python Tests (${{ matrix.pl_backend }}, cuda-${{ matrix.cuda_version }})
Expand All @@ -93,19 +81,16 @@ jobs:
uses: actions/checkout@v4
with:
fetch-tags: true
path: main

- name: Switch to release build of Lightning
if: inputs.lightning-version == 'release'
if: inputs.lightning-version == 'release' && matrix.pl_backend == 'lightning.qubit'
run: |
cd main
git fetch --all
git checkout $(git branch -a --list "origin/v0.*rc*" | sort | tail -1)
- name: Switch to stable build of Lightning
if: inputs.lightning-version == 'stable'
if: inputs.lightning-version == 'stable' && matrix.pl_backend == 'lightning.qubit'
run: |
cd main
git fetch --tags --force
git checkout latest_release
Expand All @@ -117,7 +102,7 @@ jobs:
- name: Setup Python virtual environment
id: setup_venv
env:
VENV_NAME: ${{ github.workspace }}/venv_${{ steps.setup_python.outputs.python-version }}_${{ github.sha }}
VENV_NAME: ${{ github.workspace }}/venv_${{ steps.setup_python.outputs.python-version }}_${{ github.sha }}_${{ matrix.pl_backend }}
run: |
# Clear any pre-existing venvs
rm -rf venv_*
Expand Down Expand Up @@ -152,9 +137,18 @@ jobs:
- name: Install required packages
run: |
cd main
python -m pip install -r requirements-dev.txt
python -m pip install cmake custatevec-cu${{ matrix.cuda_version }} openfermionpyscf
python -m pip install cmake openfermionpyscf
- name: Install required lightning_gpu only packages
if: matrix.pl_backend == 'lightning_gpu'
run: |
python -m pip install custatevec-cu${{ matrix.cuda_version }}
- name: Install required lightning_tensor only packages
if: matrix.pl_backend == 'lightning_tensor'
run: |
python -m pip install cutensornet-cu${{ matrix.cuda_version }}
- name: Checkout PennyLane for release build
if: inputs.pennylane-version == 'release'
Expand All @@ -174,76 +168,53 @@ jobs:
- name: Install Stable PennyLane
if: inputs.pennylane-version == 'stable'
run: |
cd main
python -m pip uninstall -y pennylane && python -m pip install -U pennylane
- name: Build and install package
env:
CUQUANTUM_SDK: $(python -c "import site; print( f'{site.getsitepackages()[0]}/cuquantum')")
run: |
cd main
rm -rf build
PL_BACKEND=lightning_qubit python scripts/configure_pyproject_toml.py || true
PL_BACKEND=lightning_qubit SKIP_COMPILATION=True python -m pip install . -vv
rm -rf build
PL_BACKEND=${{ matrix.pl_backend }} python scripts/configure_pyproject_toml.py || true
PL_BACKEND=${{ matrix.pl_backend }} CMAKE_ARGS="-DPython_EXECUTABLE=${{ steps.python_path.outputs.python }}" \
python -m pip install . -vv
PL_BACKEND=${{ matrix.pl_backend }} python -m pip install . -vv
- name: Run PennyLane-Lightning-GPU unit tests
if: ${{ matrix.pl_backend != 'all'}}
- name: Run PennyLane unit tests
env:
OMP_NUM_THREADS: 1
OMP_PROC_BIND: false
if: matrix.pl_backend == 'lightning_gpu'
run: |
cd main/
DEVICENAME=`echo ${{ matrix.pl_backend }} | sed "s/_/./g"`
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
PL_DEVICE=${DEVICENAME} python -m pytest tests/ $COVERAGE_FLAGS
mv coverage.xml coverage-${{ github.job }}-${{ matrix.pl_backend }}.xml
- name: Install all backend devices
if: ${{ matrix.pl_backend == 'all' }}
env:
CUQUANTUM_SDK: $(python -c "import site; print( f'{site.getsitepackages()[0]}/cuquantum')")
run: |
cd main
rm -rf build
PL_BACKEND=lightning_qubit python scripts/configure_pyproject_toml.py || true
PL_BACKEND=lightning_qubit python -m pip install . -vv
rm -rf build
PL_BACKEND=${{ matrix.pl_backend }} python scripts/configure_pyproject_toml.py || true
PL_BACKEND=${{ matrix.pl_backend }} python -m pip install . -vv
- name: Run PennyLane-Lightning unit tests for lightning.qubit with all devices installed
if: ${{ matrix.pl_backend == 'all' }}
- name: Run PennyLane Lightning unit tests
env:
OMP_NUM_THREADS: 1
OMP_PROC_BIND: false
run: |
cd main/
PL_DEVICE=lightning.qubit python -m pytest tests/ -k "not test_native_mcm" $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.gpu python -m pytest tests/ $COVERAGE_FLAGS
pl-device-test --device lightning.gpu --skip-ops --shots=20000 $COVERAGE_FLAGS --cov-append
pl-device-test --device lightning.gpu --shots=None --skip-ops $COVERAGE_FLAGS --cov-append
DEVICENAME=`echo ${{ matrix.pl_backend }} | sed "s/_/./g"`
PL_DEVICE=${DEVICENAME} python -m pytest tests/ $COVERAGE_FLAGS
- name: Move coverage file
run: |
mv coverage.xml coverage-${{ github.job }}-${{ matrix.pl_backend }}.xml
- name: Upload code coverage results
uses: actions/upload-artifact@v4
with:
name: ubuntu-codecov-results-python-${{ matrix.pl_backend }}
path: ./main/coverage-${{ github.job }}-${{ matrix.pl_backend }}.xml
path: coverage-${{ github.job }}-${{ matrix.pl_backend }}.xml
retention-days: 1
if-no-files-found: error
include-hidden-files: true

upload-to-codecov-linux-python:
needs: [pythontestswithLGPU]
needs: [pythontestswithGPU]
name: Upload coverage data to codecov
runs-on: ubuntu-latest
steps:
Expand Down
Loading

0 comments on commit 1acb133

Please sign in to comment.