Skip to content

Create v0.39.0 RC branch. #1864

Create v0.39.0 RC branch.

Create v0.39.0 RC branch. #1864

name: Testing::x86_64::C++
on:
workflow_call:
inputs:
lightning-version:
type: string
required: true
description: The version of Lightning to use. Valid values are either 'release' (most recent release candidate), '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 'release' (most recent release candidate), 'stable' (most recent git-tag) or 'latest' (most recent commit from master)
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
paths:
- .github/workflows/tests_linux_cpp.yml
- pennylane_lightning/core/src/**
- '!pennylane_lightning/core/src/simulators/lightning_gpu/**'
- '!pennylane_lightning/core/src/simulators/lightning_tensor/**'
push:
branches:
- master
env:
TF_VERSION: 2.10.0
TORCH_VERSION: 1.11.0+cpu
COVERAGE_FLAGS: "--cov=pennylane_lightning --cov-report=term-missing --no-flaky-report -p no:warnings --tb=native"
GCC_VERSION: 11
OMP_NUM_THREADS: "2"
OMP_PROC_BIND: "false"
concurrency:
group: tests_linux_cpp-${{ github.ref }}-${{ github.event_name }}-${{ inputs.lightning-version }}-${{ inputs.pennylane-version }}
cancel-in-progress: true
jobs:
determine_runner:
if: github.event.pull_request.draft == false
name: Determine runner type to use
uses: ./.github/workflows/determine-workflow-runner.yml
with:
default_runner: ubuntu-22.04
cpptests:
if: ${{ !contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }}
needs: [determine_runner]
strategy:
matrix:
pl_backend: ["lightning_qubit"]
enable_kernel_omp: ["OFF", "ON"]
enable_kernel_avx_streaming: ["OFF", "ON"]
enable_lapack: ["OFF", "ON"]
exclude:
- enable_kernel_omp: OFF
enable_kernel_avx_streaming: ON
timeout-minutes: 60
name: C++ Tests (${{ matrix.pl_backend }}, ENABLE_KERNEL_OMP=${{ matrix.enable_kernel_omp }}, ENABLE_KERNEL_AVX_STREAMING=${{ matrix.enable_kernel_avx_streaming }}), ENABLE_LAPACK=${{ matrix.enable_lapack }})
runs-on: ${{ needs.determine_runner.outputs.runner_group }}
steps:
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.10'
- name: Checkout PennyLane-Lightning
uses: actions/checkout@v4
- name: Install dependencies
run: |
echo ${{ github.event_name }} && sudo apt-get update && sudo apt-get -y -q install cmake gcc-$GCC_VERSION g++-$GCC_VERSION ninja-build gcovr lcov
python -m pip install scipy
- name: Build and run unit tests
run: |
cmake . -BBuild -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-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 \
-DLQ_ENABLE_KERNEL_AVX_STREAMING=${{ matrix.enable_kernel_avx_streaming }} \
-DLQ_ENABLE_KERNEL_OMP=${{ matrix.enable_kernel_omp }}
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;
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_kernel_avx_streaming }}-${{ matrix.enable_kernel_omp }}-${{ matrix.enable_lapack }}.info
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: ubuntu-tests-reports-${{ github.job }}-${{ matrix.pl_backend }}-${{ matrix.enable_kernel_avx_streaming }}-${{ matrix.enable_kernel_omp }}-${{ matrix.enable_lapack }}
retention-days: 1
include-hidden-files: true
path: |
./Build/tests/results/
if-no-files-found: error
- name: Upload code coverage results
uses: actions/upload-artifact@v4
with:
name: ubuntu-codecov-results-${{ matrix.pl_backend }}-${{ matrix.enable_kernel_avx_streaming }}-${{ matrix.enable_kernel_omp }}-${{ matrix.enable_lapack }}
path: ./Build/coverage-${{ github.job }}-${{ matrix.pl_backend }}-${{ matrix.enable_kernel_avx_streaming }}-${{ matrix.enable_kernel_omp }}-${{ matrix.enable_lapack }}.info
if-no-files-found: error
cpptestswithOpenBLAS:
if: ${{ !contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }}
needs: [determine_runner]
strategy:
matrix:
pl_backend: ["lightning_qubit"]
timeout-minutes: 60
name: C++ Tests (${{ matrix.pl_backend }}, blas-ON)
runs-on: ${{ needs.determine_runner.outputs.runner_group }}
steps:
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.10'
- name: Checkout PennyLane-Lightning
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get -y -q install cmake gcc-$GCC_VERSION g++-$GCC_VERSION libopenblas-base libopenblas-dev ninja-build gcovr lcov
python -m pip install scipy
- name: Build and run unit tests
run: |
cmake . -BBuild -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DENABLE_PYTHON=OFF \
-DENABLE_BLAS=ON \
-DPL_BACKEND=${{ matrix.pl_backend }} \
-DBUILD_TESTS=ON \
-DCMAKE_CXX_COMPILER=$(which g++-$GCC_VERSION) \
-DENABLE_COVERAGE=ON
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;
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@v4
if: always()
with:
name: ubuntu-tests-reports-blas-${{ github.job }}-${{ matrix.pl_backend }}
path: ./Build/tests/results/
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-blas-${{ matrix.pl_backend }}
path: ./Build/coverage-${{ github.job }}-${{ matrix.pl_backend }}.info
retention-days: 1
if-no-files-found: error
include-hidden-files: true
build_and_cache_Kokkos:
name: "Build and cache Kokkos"
needs: [determine_runner]
uses: ./.github/workflows/build_and_cache_Kokkos_linux.yml
with:
runs_on: ${{ needs.determine_runner.outputs.runner_group }}
os: ubuntu-22.04
cpptestswithKokkos:
if: ${{ !contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }}
needs: [build_and_cache_Kokkos, determine_runner]
strategy:
matrix:
os: [ubuntu-22.04]
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: 60
name: C++ Tests (${{ matrix.pl_backend }}, kokkos-${{ matrix.kokkos_version }}, model-${{ matrix.exec_model }})
runs-on: ${{ needs.determine_runner.outputs.runner_group }}
steps:
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.10'
- name: Checkout PennyLane-Lightning
uses: actions/checkout@v4
- name: Restoring cached dependencies
id: kokkos-cache
uses: actions/cache@v4
with:
path: ${{ github.workspace}}/Kokkos_install/${{ matrix.exec_model }}
key: ${{ matrix.os }}-kokkos${{ matrix.kokkos_version }}-${{ matrix.exec_model }}
- name: Copy cached libraries
if: steps.kokkos-cache.outputs.cache-hit == 'true'
run: |
rm -rf Kokkos
mkdir Kokkos/
cp -rf ${{ github.workspace}}/Kokkos_install/${{ matrix.exec_model }}/* Kokkos/
- 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
python -m pip install scipy
- name: Build and run unit tests
run: |
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@v4
if: always()
with:
name: ubuntu-tests-reports-${{ github.job }}-${{ matrix.pl_backend }}
path: ./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-${{ github.job }}-${{ matrix.pl_backend }}
path: ./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: [cpptests, cpptestswithOpenBLAS, cpptestswithKokkos]
name: Upload cpp coverage data to codecov
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download coverage reports
uses: actions/download-artifact@v4
with:
pattern: ubuntu-codecov-*
merge-multiple: true
- name: Upload to Codecov
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
cpptestsWithMultipleBackends:
# Device-specific tests are performed for both. Device-agnostic tests default to LightningQubit.
if: ${{ !contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }}
needs: [build_and_cache_Kokkos, determine_runner]
strategy:
matrix:
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: 60
name: C++ Tests (multiple-backends, kokkos-${{ matrix.kokkos_version }}, model-${{ matrix.exec_model }})
runs-on: ${{ needs.determine_runner.outputs.runner_group }}
steps:
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.10'
- name: Checkout PennyLane-Lightning
uses: actions/checkout@v4
- name: Restoring cached dependencies
id: kokkos-cache
uses: actions/cache@v4
with:
path: ${{ github.workspace}}/Kokkos_install/${{ matrix.exec_model }}
key: ${{ matrix.os }}-kokkos${{ matrix.kokkos_version }}-${{ matrix.exec_model }}
- name: Copy cached libraries
if: steps.kokkos-cache.outputs.cache-hit == 'true'
run: |
rm -rf Kokkos
mkdir Kokkos/
cp -rf ${{ github.workspace}}/Kokkos_install/${{ matrix.exec_model }}/* Kokkos/
- 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
python -m pip install scipy
- name: Build and run unit tests
run: |
cmake . -BBuild -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DBUILD_TESTS=ON \
-DENABLE_PYTHON=OFF \
-DCMAKE_PREFIX_PATH=${{ github.workspace }}/Kokkos \
-DPL_BACKEND="lightning_qubit;lightning_kokkos" \
-DCMAKE_CXX_COMPILER=$(which g++-$GCC_VERSION)
cmake --build ./Build
cd ./Build
mkdir -p ./tests/results_multiple_backends
for file in *runner ; do ./$file --order lex --reporter junit --out ./tests/results_multiple_backends/report_$file.xml; done;
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: ubuntu-tests-reports-${{ github.job }}-multiple-backends-kokkos${{ matrix.kokkos_version }}-${{ matrix.exec_model }}
path: ./Build/tests/results_multiple_backends/
retention-days: 1
if-no-files-found: error
include-hidden-files: true