This repository has been archived by the owner on Oct 27, 2023. It is now read-only.
Test QuantumPhaseEstimation and associated decomp values #226
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests::Linux::x86_64::Nvidia_GPU | |
on: | |
release: | |
push: | |
branches: | |
- main | |
pull_request: | |
env: | |
COVERAGE_FLAGS: "--cov=pennylane_lightning_kokkos --cov-report=term-missing --cov-report=xml:./coverage.xml --no-flaky-report -p no:warnings --tb=native" | |
GCC_VERSION: 11 | |
CI_CUDA_ARCH: 86 | |
concurrency: | |
group: gpu-test-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
cpptests: | |
runs-on: | |
- self-hosted | |
- ubuntu-22.04 | |
- gpu | |
strategy: | |
max-parallel: 1 | |
steps: | |
- name: Checkout PennyLane-Lightning-Kokkos | |
uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
name: Install Python | |
with: | |
python-version: '3.8' | |
# 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 | |
- name: Validate GPU version and installed compiler | |
run: | | |
nvidia-smi | |
/usr/local/cuda/bin/nvcc --version | |
- name: Build and run unit tests | |
run: | | |
export PATH=/usr/local/cuda-11.8/bin:$PATH | |
export LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64:$LD_LIBRARY_PATH | |
cmake . -BBuild \ | |
-DKokkos_ENABLE_CUDA=ON \ | |
-DKokkos_ENABLE_SERIAL=ON \ | |
-DPLKOKKOS_BUILD_TESTS=ON \ | |
-DPython_EXECUTABLE:FILE="${{ steps.python_path.outputs.python }}" \ | |
-G Ninja | |
cmake --build ./Build | |
./Build/pennylane_lightning_kokkos/src/tests/runner_kokkos | |
- name: Upload test results | |
uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: ubuntu-tests-reports | |
path: ./Build/tests/results/report_${{ github.job }}.xml | |
- name: Cleanup | |
if: always() | |
run: | | |
rm -rf * | |
rm -rf .git | |
rm -rf .gitignore | |
rm -rf .github | |
pythontests: | |
runs-on: | |
- self-hosted | |
- ubuntu-22.04 | |
- gpu | |
strategy: | |
max-parallel: 1 | |
steps: | |
- name: Checkout pennyLane-lightning-gpu | |
uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
name: Install Python | |
with: | |
python-version: '3.8' | |
# 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 | |
source ${{ env.VENV_NAME }}/bin/activate | |
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 pip~=22.3 | |
python -m pip install ninja cmake pytest pytest-mock flaky pytest-cov wheel | |
# Sync with latest master branches | |
python -m pip install git+https://github.com/PennyLaneAI/pennylane.git@v0.30.0-rc0 | |
python -m pip install --index-url https://test.pypi.org/simple/ pennylane-lightning --pre --force-reinstall --no-deps | |
- name: Build and install package | |
run: | | |
export PATH=/usr/local/cuda-11.8/bin:$PATH | |
export LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64:$LD_LIBRARY_PATH | |
CC=$(which gcc-${{ env.GCC_VERSION }}) CXX=$(which g++-${{ env.GCC_VERSION }}) BACKEND="CUDA" python -m pip install -e . --verbose | |
- name: Run PennyLane-Lightning-Kokkos unit tests | |
run: | | |
python -m pytest ./tests/ ${{ env.COVERAGE_FLAGS }} | |
pl-device-test --device lightning.kokkos --skip-ops --shots=20000 ${{ env.COVERAGE_FLAGS }} --cov-append | |
pl-device-test --device lightning.kokkos --shots=None --skip-ops ${{ env.COVERAGE_FLAGS }} --cov-append | |
mv coverage.xml coverage-${{ github.job }}.xml | |
- name: Upload code coverage results | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ubuntu-codecov-results-python | |
path: ./coverage-${{ github.job }}.xml | |
- name: Cleanup | |
if: always() | |
run: | | |
rm -rf * | |
rm -rf .git | |
rm -rf .gitignore | |
rm -rf .github |