diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 2677a7edd8..965dfff2c2 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -41,6 +41,9 @@ ### Breaking changes +* Add `paths` directives to test workflows to avoid running tests that cannot be impacted by changes. + [(#695)](https://github.com/PennyLaneAI/pennylane-lightning/pull/695) + * Move common components of `/src/simulator/lightning_gpu/utils/` to `/src/utils/cuda_utils/`. [(#676)](https://github.com/PennyLaneAI/pennylane-lightning/pull/676) diff --git a/.github/workflows/compat-check-latest-latest.yml b/.github/workflows/compat-check-latest-latest.yml index fadf592dee..dbb9886766 100644 --- a/.github/workflows/compat-check-latest-latest.yml +++ b/.github/workflows/compat-check-latest-latest.yml @@ -6,38 +6,73 @@ on: workflow_dispatch: jobs: - tests_linux: - name: Lightning Compatibility test (tests_linux) - latest/latest - uses: ./.github/workflows/tests_linux.yml + tests_lgpu_cpp: + name: Lightning Compatibility test (tests_lgpu_cpp) - latest/latest + uses: ./.github/workflows/lgpu_cpp.yml with: lightning-version: latest pennylane-version: latest - secrets: inherit # pass all secrets - tests_lkokkos_gpu: - name: Lightning Compatibility test (tests_lkokkos_gpu) - latest/latest - uses: ./.github/workflows/tests_gpu_kokkos.yml + secrets: inherit + tests_lgpumpi_cpp: + name: Lightning Compatibility test (tests_lgpumpi_cpp) - latest/latest + uses: ./.github/workflows/lgpumpi_cpp.yml with: lightning-version: latest pennylane-version: latest - secrets: inherit # pass all secrets - tests_lgpu_gpu: - name: Lightning Compatibility test (tests_lgpu_gpu) - latest/latest - uses: ./.github/workflows/tests_gpu_cuda.yml + secrets: inherit + tests_linux_cpp: + name: Lightning Compatibility test (tests_linux_cpp) - latest/latest + uses: ./.github/workflows/linux_cpp.yml with: lightning-version: latest pennylane-version: latest - secrets: inherit # pass all secrets - tests_lgpu_gpu_mpi: - name: Lightning Compatibility test (tests_lgpu_gpu_mpi) - latest/latest - uses: ./.github/workflows/tests_linux_x86_mpi_gpu.yml + secrets: inherit + tests_lkcuda_cpp: + name: Lightning Compatibility test (tests_lkcuda_cpp) - latest/latest + uses: ./.github/workflows/lkcuda_cpp.yml with: lightning-version: latest pennylane-version: latest - secrets: inherit # pass all secrets + secrets: inherit + tests_windows_cpp: + name: Lightning Compatibility test (tests_windows_cpp) - latest/latest + uses: ./.github/workflows/windows_cpp.yml + with: + lightning-version: latest + pennylane-version: latest + secrets: inherit + tests_lgpu_python: + name: Lightning Compatibility test (tests_lgpu_python) - latest/latest + uses: ./.github/workflows/lgpu_python.yml + with: + lightning-version: latest + pennylane-version: latest + secrets: inherit + tests_lgpumpi_python: + name: Lightning Compatibility test (tests_lgpumpi_python) - latest/latest + uses: ./.github/workflows/lgpumpi_python.yml + with: + lightning-version: latest + pennylane-version: latest + secrets: inherit + tests_linux_python: + name: Lightning Compatibility test (tests_linux_python) - latest/latest + uses: ./.github/workflows/linux_python.yml + with: + lightning-version: latest + pennylane-version: latest + secrets: inherit + tests_lkcuda_python: + name: Lightning Compatibility test (tests_lkcuda_python) - latest/latest + uses: ./.github/workflows/lkcuda_python.yml + with: + lightning-version: latest + pennylane-version: latest + secrets: inherit tests_without_binary: name: Lightning Compatibility test (tests_without_binary) - latest/latest - uses: ./.github/workflows/tests_without_binary.yml + uses: ./.github/workflows/without_binary.yml with: lightning-version: latest pennylane-version: latest - secrets: inherit # pass all secrets + secrets: inherit diff --git a/.github/workflows/compat-check-latest-stable.yml b/.github/workflows/compat-check-latest-stable.yml index d395d09530..bc64172ede 100644 --- a/.github/workflows/compat-check-latest-stable.yml +++ b/.github/workflows/compat-check-latest-stable.yml @@ -6,38 +6,74 @@ on: workflow_dispatch: jobs: - tests_linux: - name: Lightning Compatibility test (tests_linux) - latest/stable - uses: ./.github/workflows/tests_linux.yml + tests_lgpu_cpp: + name: Lightning Compatibility test (tests_lgpu_cpp) - latest/stable + uses: ./.github/workflows/lgpu_cpp.yml with: lightning-version: latest pennylane-version: stable - secrets: inherit # pass all secrets - tests_lkokkos_gpu: - name: Lightning Compatibility test (tests_lkokkos_gpu) - latest/stable - uses: ./.github/workflows/tests_gpu_kokkos.yml + secrets: inherit + tests_lgpumpi_cpp: + name: Lightning Compatibility test (tests_lgpumpi_cpp) - latest/stable + uses: ./.github/workflows/lgpumpi_cpp.yml with: lightning-version: latest pennylane-version: stable - secrets: inherit # pass all secrets - tests_lgpu_gpu: - name: Lightning Compatibility test (tests_lgpu_gpu) - latest/stable - uses: ./.github/workflows/tests_gpu_cuda.yml + secrets: inherit + tests_linux_cpp: + name: Lightning Compatibility test (tests_linux_cpp) - latest/stable + uses: ./.github/workflows/linux_cpp.yml with: lightning-version: latest pennylane-version: stable - secrets: inherit # pass all secrets - tests_lgpu_gpu_mpi: - name: Lightning Compatibility test (tests_lgpu_gpu_mpi) - latest/stable - uses: ./.github/workflows/tests_linux_x86_mpi_gpu.yml + secrets: inherit + tests_lkcuda_cpp: + name: Lightning Compatibility test (tests_lkcuda_cpp) - latest/stable + uses: ./.github/workflows/lkcuda_cpp.yml with: lightning-version: latest pennylane-version: stable - secrets: inherit # pass all secrets + secrets: inherit + tests_windows_cpp: + name: Lightning Compatibility test (tests_windows_cpp) - latest/stable + uses: ./.github/workflows/windows_cpp.yml + with: + lightning-version: latest + pennylane-version: stable + secrets: inherit + tests_lgpu_python: + name: Lightning Compatibility test (tests_lgpu_python) - latest/stable + uses: ./.github/workflows/lgpu_python.yml + with: + lightning-version: latest + pennylane-version: stable + secrets: inherit + tests_lgpumpi_python: + name: Lightning Compatibility test (tests_lgpumpi_python) - latest/stable + uses: ./.github/workflows/lgpumpi_python.yml + with: + lightning-version: latest + pennylane-version: stable + secrets: inherit + tests_linux_python: + name: Lightning Compatibility test (tests_linux_python) - latest/stable + uses: ./.github/workflows/linux_python.yml + with: + lightning-version: latest + pennylane-version: stable + secrets: inherit + tests_lkcuda_python: + name: Lightning Compatibility test (tests_lkcuda_python) - latest/stable + uses: ./.github/workflows/lkcuda_python.yml + with: + lightning-version: latest + pennylane-version: stable + secrets: inherit tests_without_binary: name: Lightning Compatibility test (tests_without_binary) - latest/stable - uses: ./.github/workflows/tests_without_binary.yml + uses: ./.github/workflows/without_binary.yml with: lightning-version: latest pennylane-version: stable - secrets: inherit # pass all secrets + secrets: inherit + \ No newline at end of file diff --git a/.github/workflows/compat-check-release-release.yml b/.github/workflows/compat-check-release-release.yml index 2c3f9becfb..7d3f569ea3 100644 --- a/.github/workflows/compat-check-release-release.yml +++ b/.github/workflows/compat-check-release-release.yml @@ -6,38 +6,74 @@ on: workflow_dispatch: jobs: - tests_linux: - name: Lightning Compatibility test (tests_linux) - release/release - uses: ./.github/workflows/tests_linux.yml + tests_lgpu_cpp: + name: Lightning Compatibility test (tests_lgpu_cpp) - release/release + uses: ./.github/workflows/lgpu_cpp.yml with: lightning-version: release pennylane-version: release - secrets: inherit # pass all secrets - tests_lkokkos_gpu: - name: Lightning Compatibility test (tests_lkokkos_gpu) - release/release - uses: ./.github/workflows/tests_gpu_kokkos.yml + secrets: inherit + tests_lgpumpi_cpp: + name: Lightning Compatibility test (tests_lgpumpi_cpp) - release/release + uses: ./.github/workflows/lgpumpi_cpp.yml with: lightning-version: release pennylane-version: release - secrets: inherit # pass all secrets - tests_lgpu_gpu: - name: Lightning Compatibility test (tests_lgpu_gpu) - release/release - uses: ./.github/workflows/tests_gpu_cuda.yml + secrets: inherit + tests_linux_cpp: + name: Lightning Compatibility test (tests_linux_cpp) - release/release + uses: ./.github/workflows/linux_cpp.yml with: lightning-version: release pennylane-version: release - secrets: inherit # pass all secrets - tests_lgpu_gpu_mpi: - name: Lightning Compatibility test (tests_lgpu_gpu_mpi) - release/release - uses: ./.github/workflows/tests_linux_x86_mpi_gpu.yml + secrets: inherit + tests_lkcuda_cpp: + name: Lightning Compatibility test (tests_lkcuda_cpp) - release/release + uses: ./.github/workflows/lkcuda_cpp.yml with: lightning-version: release pennylane-version: release - secrets: inherit # pass all secrets + secrets: inherit + tests_windows_cpp: + name: Lightning Compatibility test (tests_windows_cpp) - release/release + uses: ./.github/workflows/windows_cpp.yml + with: + lightning-version: release + pennylane-version: release + secrets: inherit + tests_lgpu_python: + name: Lightning Compatibility test (tests_lgpu_python) - release/release + uses: ./.github/workflows/lgpu_python.yml + with: + lightning-version: release + pennylane-version: release + secrets: inherit + tests_lgpumpi_python: + name: Lightning Compatibility test (tests_lgpumpi_python) - release/release + uses: ./.github/workflows/lgpumpi_python.yml + with: + lightning-version: release + pennylane-version: release + secrets: inherit + tests_linux_python: + name: Lightning Compatibility test (tests_linux_python) - release/release + uses: ./.github/workflows/linux_python.yml + with: + lightning-version: release + pennylane-version: release + secrets: inherit + tests_lkcuda_python: + name: Lightning Compatibility test (tests_lkcuda_python) - release/release + uses: ./.github/workflows/lkcuda_python.yml + with: + lightning-version: release + pennylane-version: release + secrets: inherit tests_without_binary: name: Lightning Compatibility test (tests_without_binary) - release/release - uses: ./.github/workflows/tests_without_binary.yml + uses: ./.github/workflows/without_binary.yml with: lightning-version: release pennylane-version: release - secrets: inherit # pass all secrets + secrets: inherit + \ No newline at end of file diff --git a/.github/workflows/compat-check-stable-latest.yml b/.github/workflows/compat-check-stable-latest.yml index a06e4b9a99..a537355957 100644 --- a/.github/workflows/compat-check-stable-latest.yml +++ b/.github/workflows/compat-check-stable-latest.yml @@ -6,38 +6,74 @@ on: workflow_dispatch: jobs: - tests_linux: - name: Lightning Compatibility test (tests_linux) - stable/latest - uses: ./.github/workflows/tests_linux.yml + tests_lgpu_cpp: + name: Lightning Compatibility test (tests_lgpu_cpp) - stable/latest + uses: ./.github/workflows/lgpu_cpp.yml with: lightning-version: stable pennylane-version: latest - secrets: inherit # pass all secrets - tests_lkokkos_gpu: - name: Lightning Compatibility test (tests_lkokkos_gpu) - stable/latest - uses: ./.github/workflows/tests_gpu_kokkos.yml + secrets: inherit + tests_lgpumpi_cpp: + name: Lightning Compatibility test (tests_lgpumpi_cpp) - stable/latest + uses: ./.github/workflows/lgpumpi_cpp.yml with: lightning-version: stable pennylane-version: latest - secrets: inherit # pass all secrets - tests_lgpu_gpu: - name: Lightning Compatibility test (tests_lgpu_gpu) - stable/latest - uses: ./.github/workflows/tests_gpu_cuda.yml + secrets: inherit + tests_linux_cpp: + name: Lightning Compatibility test (tests_linux_cpp) - stable/latest + uses: ./.github/workflows/linux_cpp.yml with: lightning-version: stable pennylane-version: latest - secrets: inherit # pass all secrets - tests_lgpu_gpu_mpi: - name: Lightning Compatibility test (tests_lgpu_gpu_mpi) - stable/latest - uses: ./.github/workflows/tests_linux_x86_mpi_gpu.yml + secrets: inherit + tests_lkcuda_cpp: + name: Lightning Compatibility test (tests_lkcuda_cpp) - stable/latest + uses: ./.github/workflows/lkcuda_cpp.yml with: lightning-version: stable pennylane-version: latest - secrets: inherit # pass all secrets + secrets: inherit + tests_windows_cpp: + name: Lightning Compatibility test (tests_windows_cpp) - stable/latest + uses: ./.github/workflows/windows_cpp.yml + with: + lightning-version: stable + pennylane-version: latest + secrets: inherit + tests_lgpu_python: + name: Lightning Compatibility test (tests_lgpu_python) - stable/latest + uses: ./.github/workflows/lgpu_python.yml + with: + lightning-version: stable + pennylane-version: latest + secrets: inherit + tests_lgpumpi_python: + name: Lightning Compatibility test (tests_lgpumpi_python) - stable/latest + uses: ./.github/workflows/lgpumpi_python.yml + with: + lightning-version: stable + pennylane-version: latest + secrets: inherit + tests_linux_python: + name: Lightning Compatibility test (tests_linux_python) - stable/latest + uses: ./.github/workflows/linux_python.yml + with: + lightning-version: stable + pennylane-version: latest + secrets: inherit + tests_lkcuda_python: + name: Lightning Compatibility test (tests_lkcuda_python) - stable/latest + uses: ./.github/workflows/lkcuda_python.yml + with: + lightning-version: stable + pennylane-version: latest + secrets: inherit tests_without_binary: name: Lightning Compatibility test (tests_without_binary) - stable/latest - uses: ./.github/workflows/tests_without_binary.yml + uses: ./.github/workflows/without_binary.yml with: lightning-version: stable pennylane-version: latest - secrets: inherit # pass all secrets + secrets: inherit + \ No newline at end of file diff --git a/.github/workflows/compat-check-stable-stable.yml b/.github/workflows/compat-check-stable-stable.yml index ddf6e07b19..8fb4261054 100644 --- a/.github/workflows/compat-check-stable-stable.yml +++ b/.github/workflows/compat-check-stable-stable.yml @@ -6,38 +6,74 @@ on: workflow_dispatch: jobs: - tests_linux: - name: Lightning Compatibility test (tests_linux) - stable/stable - uses: ./.github/workflows/tests_linux.yml + tests_lgpu_cpp: + name: Lightning Compatibility test (tests_lgpu_cpp) - stable/stable + uses: ./.github/workflows/lgpu_cpp.yml with: lightning-version: stable pennylane-version: stable - secrets: inherit # pass all secrets - tests_lkokkos_gpu: - name: Lightning Compatibility test (tests_lkokkos_gpu) - stable/stable - uses: ./.github/workflows/tests_gpu_kokkos.yml + secrets: inherit + tests_lgpumpi_cpp: + name: Lightning Compatibility test (tests_lgpumpi_cpp) - stable/stable + uses: ./.github/workflows/lgpumpi_cpp.yml with: lightning-version: stable pennylane-version: stable - secrets: inherit # pass all secrets - tests_lgpu_gpu: - name: Lightning Compatibility test (tests_lgpu_gpu) - stable/stable - uses: ./.github/workflows/tests_gpu_cuda.yml + secrets: inherit + tests_linux_cpp: + name: Lightning Compatibility test (tests_linux_cpp) - stable/stable + uses: ./.github/workflows/linux_cpp.yml with: lightning-version: stable pennylane-version: stable - secrets: inherit # pass all secrets - tests_lgpu_gpu_mpi: - name: Lightning Compatibility test (tests_lgpu_gpu_mpi) - stable/stable - uses: ./.github/workflows/tests_linux_x86_mpi_gpu.yml + secrets: inherit + tests_lkcuda_cpp: + name: Lightning Compatibility test (tests_lkcuda_cpp) - stable/stable + uses: ./.github/workflows/lkcuda_cpp.yml with: lightning-version: stable pennylane-version: stable - secrets: inherit # pass all secrets + secrets: inherit + tests_windows_cpp: + name: Lightning Compatibility test (tests_windows_cpp) - stable/stable + uses: ./.github/workflows/windows_cpp.yml + with: + lightning-version: stable + pennylane-version: stable + secrets: inherit + tests_lgpu_python: + name: Lightning Compatibility test (tests_lgpu_python) - stable/stable + uses: ./.github/workflows/lgpu_python.yml + with: + lightning-version: stable + pennylane-version: stable + secrets: inherit + tests_lgpumpi_python: + name: Lightning Compatibility test (tests_lgpumpi_python) - stable/stable + uses: ./.github/workflows/lgpumpi_python.yml + with: + lightning-version: stable + pennylane-version: stable + secrets: inherit + tests_linux_python: + name: Lightning Compatibility test (tests_linux_python) - stable/stable + uses: ./.github/workflows/linux_python.yml + with: + lightning-version: stable + pennylane-version: stable + secrets: inherit + tests_lkcuda_python: + name: Lightning Compatibility test (tests_lkcuda_python) - stable/stable + uses: ./.github/workflows/lkcuda_python.yml + with: + lightning-version: stable + pennylane-version: stable + secrets: inherit tests_without_binary: name: Lightning Compatibility test (tests_without_binary) - stable/stable - uses: ./.github/workflows/tests_without_binary.yml + uses: ./.github/workflows/without_binary.yml with: lightning-version: stable pennylane-version: stable - secrets: inherit # pass all secrets + secrets: inherit + \ No newline at end of file diff --git a/.github/workflows/tests_lgpu_cpp.yml b/.github/workflows/tests_lgpu_cpp.yml new file mode 100644 index 0000000000..cc5754bcf3 --- /dev/null +++ b/.github/workflows/tests_lgpu_cpp.yml @@ -0,0 +1,191 @@ +name: Testing::x86_64::LGPU::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) + release: + pull_request: + 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/**' + 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 + TF_VERSION: 2.10.0 + TORCH_VERSION: 1.11.0+cpu + +concurrency: + group: tests_lgpu_cpp-${{ 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] + pl_backend: ["lightning_gpu"] + cuda_version: ["12"] + + steps: + - name: Validate GPU version and installed compiler + run: | + source /etc/profile.d/modules.sh + module use /opt/modules + module load cuda/${{ matrix.cuda_version }} + echo "${PATH}" >> $GITHUB_PATH + echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> $GITHUB_ENV + nvcc --version + nvidia-smi + + cpptestswithLGPU: + if: ${{ !contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }} + needs: [builddeps] + strategy: + matrix: + os: [ubuntu-22.04] + pl_backend: ["lightning_gpu"] + cuda_version: ["12"] + + name: C++ tests (Lightning-GPU) + 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/${{ matrix.cuda_version }} + echo "${PATH}" >> $GITHUB_PATH + echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> $GITHUB_ENV + nvcc --version + nvidia-smi + + - name: Checkout PennyLane-Lightning-GPU + uses: actions/checkout@v4 + with: + path: main + + - uses: actions/setup-python@v5 + name: Install Python + with: + python-version: '3.9' + + - 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-cu${{ matrix.cuda_version }} + sudo apt-get -y -q install liblapack-dev + + - name: Build and run unit tests + run: | + cd main + cmake . -BBuild \ + -DCUQUANTUM_SDK=$(python -c "import site; print( f'{site.getsitepackages()[0]}/cuquantum')")\ + -DBUILD_TESTS=ON \ + -DENABLE_PYTHON=OFF \ + -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 }} + 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 + + upload-to-codecov-linux-cpp: + needs: [cpptestswithLGPU] + name: Upload coverage data to codecov + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Download coverage reports + uses: actions/download-artifact@v3 + with: + name: ubuntu-codecov-results-cpp + + - name: Upload to Codecov + uses: codecov/codecov-action@v4 + 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 * + rm -rf .git + rm -rf .gitignore + rm -rf .github + pip cache purge diff --git a/.github/workflows/tests_gpu_cuda.yml b/.github/workflows/tests_lgpu_python.yml similarity index 65% rename from .github/workflows/tests_gpu_cuda.yml rename to .github/workflows/tests_lgpu_python.yml index c15f4fa1ba..8716241b4c 100644 --- a/.github/workflows/tests_gpu_cuda.yml +++ b/.github/workflows/tests_lgpu_python.yml @@ -1,4 +1,4 @@ -name: Testing::Linux::x86_64::LGPU +name: Testing::x86_64::LGPU::Python on: workflow_call: inputs: @@ -12,6 +12,11 @@ on: 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) release: pull_request: + paths-ignore: + - pennylane_lightning/core/src/simulators/lightning_kokkos/** + - pennylane_lightning/core/src/simulators/lightning_qubit/** + - pennylane_lightning/lightning_kokkos/** + - pennylane_lightning/lightning_qubit/** push: branches: - master @@ -24,7 +29,7 @@ env: TORCH_VERSION: 1.11.0+cpu concurrency: - group: tests_gpu-${{ github.ref }} + group: tests_lgpu_python-${{ github.ref }} cancel-in-progress: true jobs: @@ -52,109 +57,6 @@ jobs: nvcc --version nvidia-smi - cpptestswithLGPU: - if: ${{ !contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }} - needs: [builddeps] - strategy: - matrix: - os: [ubuntu-22.04] - pl_backend: ["lightning_gpu"] - cuda_version: ["12"] - - name: C++ tests (Lightning-GPU) - 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/${{ matrix.cuda_version }} - echo "${PATH}" >> $GITHUB_PATH - echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> $GITHUB_ENV - nvcc --version - nvidia-smi - - - name: Checkout PennyLane-Lightning-GPU - uses: actions/checkout@v4 - with: - path: main - - - uses: actions/setup-python@v5 - name: Install Python - with: - python-version: '3.9' - - - 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-cu${{ matrix.cuda_version }} - sudo apt-get -y -q install liblapack-dev - - - name: Build and run unit tests - run: | - cd main - cmake . -BBuild \ - -DCUQUANTUM_SDK=$(python -c "import site; print( f'{site.getsitepackages()[0]}/cuquantum')")\ - -DBUILD_TESTS=ON \ - -DENABLE_PYTHON=OFF \ - -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 }} - 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 - pythontestswithLGPU: needs: [builddeps] strategy: @@ -345,33 +247,3 @@ jobs: fail_ci_if_error: true verbose: true token: ${{ secrets.CODECOV_TOKEN }} - - upload-to-codecov-linux-cpp: - needs: [cpptestswithLGPU] - name: Upload coverage data to codecov - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Download coverage reports - uses: actions/download-artifact@v3 - with: - name: ubuntu-codecov-results-cpp - - - name: Upload to Codecov - uses: codecov/codecov-action@v4 - 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 * - rm -rf .git - rm -rf .gitignore - rm -rf .github - pip cache purge diff --git a/.github/workflows/tests_lgpumpi_cpp.yml b/.github/workflows/tests_lgpumpi_cpp.yml new file mode 100644 index 0000000000..43fe1c8fc6 --- /dev/null +++ b/.github/workflows/tests_lgpumpi_cpp.yml @@ -0,0 +1,194 @@ +name: Testing::x86_64::LGPU-MPI::C++ +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: + paths: + - .github/workflows/tests_lgpumpi_cpp.yml + - pennylane_lightning/core/src/** + - '!pennylane_lightning/core/src/simulators/lightning_kokkos/**' + - '!pennylane_lightning/core/src/simulators/lightning_qubit/**' + +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: tests_lgpumpi_cpp-${{ 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') && !contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }} + runs-on: + - self-hosted + - linux + - x64 + - ubuntu-22.04 + - multi-gpu + strategy: + max-parallel: 1 + matrix: + mpilib: ["mpich", "openmpi"] + cuda_version_maj: ["12"] + cuda_version_min: ["2"] + timeout-minutes: 30 + + steps: + - name: Checkout + uses: actions/checkout@v4 + 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@v5 + 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 -r requirements-dev.txt + python -m pip install cmake custatevec-cu12 scipy + + - name: Validate GPU version and installed compiler and modules + run: | + source /etc/profile.d/modules.sh && module use /opt/modules && module load cuda/${{ matrix.cuda_version_maj }} + which -a nvcc + nvcc --version + ls -R /opt/modules + + - name: Validate Multi-GPU packages + run: | + source /etc/profile.d/modules.sh && module use /opt/modules/ && module load ${{ matrix.mpilib }}/cuda-${{ matrix.cuda_version_maj }}.${{ matrix.cuda_version_min }} + echo 'Checking for ${{ matrix.mpilib }}' + which -a mpirun + mpirun --version + which -a mpicxx + mpicxx --version + module unload ${{ matrix.mpilib }}/cuda-${{ matrix.cuda_version_maj }}.${{ matrix.cuda_version_min }} + + - name: Build and run unit tests + run: | + source /etc/profile.d/modules.sh && module use /opt/modules/ && module load ${{ matrix.mpilib }}/cuda-${{ matrix.cuda_version_maj }}.${{ matrix.cuda_version_min }} + export CUQUANTUM_SDK=$(python -c "import site; print( f'{site.getsitepackages()[0]}/cuquantum/lib')") + cmake . -BBuild \ + -DPL_BACKEND=lightning_gpu \ + -DENABLE_PYTHON=OFF \ + -DENABLE_MPI=ON \ + -DCMAKE_BUILD_TYPE=Debug \ + -DENABLE_COVERAGE=ON \ + -DBUILD_TESTS=ON \ + -DCMAKE_CXX_COMPILER=mpicxx \ + -DCMAKE_CUDA_COMPILER=$(which 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 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: + name: ubuntu-tests-reports + path: ./Build/tests/results/ + if-no-files-found: error + + - name: Upload code coverage results + uses: actions/upload-artifact@v3 + with: + name: ubuntu-codecov-results-cpp + path: ./Build/coverage-${{ github.job }}-lightning_gpu_${{ matrix.mpilib }}.info + if-no-files-found: error + + - 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@v4 + + - name: Download coverage reports + uses: actions/download-artifact@v3 + with: + name: ubuntu-codecov-results-cpp + + - name: Upload to Codecov + uses: codecov/codecov-action@v4 + 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 + diff --git a/.github/workflows/tests_linux_x86_mpi_gpu.yml b/.github/workflows/tests_lgpumpi_python.yml similarity index 52% rename from .github/workflows/tests_linux_x86_mpi_gpu.yml rename to .github/workflows/tests_lgpumpi_python.yml index 4d78d4cfff..4811bb3eda 100644 --- a/.github/workflows/tests_linux_x86_mpi_gpu.yml +++ b/.github/workflows/tests_lgpumpi_python.yml @@ -1,4 +1,4 @@ -name: Tests::Linux::x86_64::LGPU::MPI +name: Testing::x86_64::LGPU-MPI::Python on: workflow_call: inputs: @@ -15,7 +15,11 @@ on: branches: - main pull_request: - + paths-ignore: + - pennylane_lightning/core/src/simulators/lightning_kokkos/** + - pennylane_lightning/core/src/simulators/lightning_qubit/** + - pennylane_lightning/lightning_kokkos/** + - pennylane_lightning/lightning_qubit/** 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 @@ -23,143 +27,10 @@ env: CI_CUDA_ARCH: 86 concurrency: - group: gpu-test-mpi-${{ github.ref }}-${{ inputs.lightning-version }}-${{ inputs.pennylane-version }} + group: tests_lgpumpi_python-${{ 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') && !contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }} - runs-on: - - self-hosted - - linux - - x64 - - ubuntu-22.04 - - multi-gpu - strategy: - max-parallel: 1 - matrix: - mpilib: ["mpich", "openmpi"] - cuda_version_maj: ["12"] - cuda_version_min: ["2"] - timeout-minutes: 30 - - steps: - - name: Checkout - uses: actions/checkout@v4 - 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@v5 - 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 -r requirements-dev.txt - python -m pip install cmake custatevec-cu12 scipy - - - name: Validate GPU version and installed compiler and modules - run: | - source /etc/profile.d/modules.sh && module use /opt/modules && module load cuda/${{ matrix.cuda_version_maj }} - which -a nvcc - nvcc --version - ls -R /opt/modules - - - name: Validate Multi-GPU packages - run: | - source /etc/profile.d/modules.sh && module use /opt/modules/ && module load ${{ matrix.mpilib }}/cuda-${{ matrix.cuda_version_maj }}.${{ matrix.cuda_version_min }} - echo 'Checking for ${{ matrix.mpilib }}' - which -a mpirun - mpirun --version - which -a mpicxx - mpicxx --version - module unload ${{ matrix.mpilib }}/cuda-${{ matrix.cuda_version_maj }}.${{ matrix.cuda_version_min }} - - - name: Build and run unit tests - run: | - source /etc/profile.d/modules.sh && module use /opt/modules/ && module load ${{ matrix.mpilib }}/cuda-${{ matrix.cuda_version_maj }}.${{ matrix.cuda_version_min }} - export CUQUANTUM_SDK=$(python -c "import site; print( f'{site.getsitepackages()[0]}/cuquantum/lib')") - cmake . -BBuild \ - -DPL_BACKEND=lightning_gpu \ - -DENABLE_PYTHON=OFF \ - -DENABLE_MPI=ON \ - -DCMAKE_BUILD_TYPE=Debug \ - -DENABLE_COVERAGE=ON \ - -DBUILD_TESTS=ON \ - -DCMAKE_CXX_COMPILER=mpicxx \ - -DCMAKE_CUDA_COMPILER=$(which 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 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: - name: ubuntu-tests-reports - path: ./Build/tests/results/ - if-no-files-found: error - - - name: Upload code coverage results - uses: actions/upload-artifact@v3 - with: - name: ubuntu-codecov-results-cpp - path: ./Build/coverage-${{ github.job }}-lightning_gpu_${{ matrix.mpilib }}.info - if-no-files-found: error - - - name: Cleanup - if: always() - run: | - rm -rf ${{ steps.setup_venv.outputs.venv_name }} - rm -rf * .git .gitignore .github - pip cache purge - python_tests: if: ${{ contains(github.event.pull_request.labels.*.name, 'ci:use-multi-gpu-runner') || contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }} @@ -283,33 +154,6 @@ jobs: 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@v4 - - - name: Download coverage reports - uses: actions/download-artifact@v3 - with: - name: ubuntu-codecov-results-cpp - - - name: Upload to Codecov - uses: codecov/codecov-action@v4 - 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 - upload-to-codecov-linux-python: needs: ["python_tests"] name: Upload coverage data to codecov diff --git a/.github/workflows/tests_linux_cpp.yml b/.github/workflows/tests_linux_cpp.yml new file mode 100644 index 0000000000..b0ba398a28 --- /dev/null +++ b/.github/workflows/tests_linux_cpp.yml @@ -0,0 +1,344 @@ +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: + paths: + - .github/workflows/tests_linux_cpp.yml + - pennylane_lightning/core/src/** + - '!pennylane_lightning/core/src/simulators/lightning_gpu/**' + + 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 }}-${{ inputs.lightning-version }}-${{ inputs.pennylane-version }} + cancel-in-progress: true + +jobs: + cpptests: + if: ${{ !contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }} + strategy: + matrix: + os: [ubuntu-22.04] + pl_backend: ["lightning_qubit"] + timeout-minutes: 60 + name: C++ tests + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/setup-python@v5 + name: Install Python + with: + python-version: '3.9' + + - 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 \ + -DPL_BACKEND=${{ matrix.pl_backend }} \ + -DCMAKE_CXX_COMPILER=$(which g++-$GCC_VERSION) \ + -DENABLE_COVERAGE=ON + + cmake . -BBuildKernelOMP -G Ninja \ + -DCMAKE_BUILD_TYPE=Debug \ + -DBUILD_TESTS=ON \ + -DENABLE_PYTHON=OFF \ + -DPL_BACKEND=${{ matrix.pl_backend }} \ + -DCMAKE_CXX_COMPILER=$(which g++-$GCC_VERSION) \ + -DENABLE_COVERAGE=ON \ + -DLQ_ENABLE_KERNEL_OMP=ON + + cmake . -BBuildKernelAVXStream -G Ninja \ + -DCMAKE_BUILD_TYPE=Debug \ + -DBUILD_TESTS=ON \ + -DENABLE_PYTHON=OFF \ + -DPL_BACKEND=${{ matrix.pl_backend }} \ + -DCMAKE_CXX_COMPILER=$(which g++-$GCC_VERSION) \ + -DENABLE_COVERAGE=ON \ + -DLQ_ENABLE_KERNEL_AVX_STREAM=ON \ + -DLQ_ENABLE_KERNEL_OMP=ON + + cmake --build ./Build + cmake --build ./BuildKernelOMP + cmake --build ./BuildKernelAVXStream + + for d in Build BuildKernelOMP BuildKernelAVXStream; do + cd ./$d + 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 + cd .. + done + lcov --add-tracefile ./Build/coverage.info -a ./BuildKernelOMP/coverage.info \ + --add-tracefile ./BuildKernelAVXStream/coverage.info -o 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: | + ./Build/tests/results/ + ./BuildKernelOMP/tests/results/ + ./BuildKernelAVXStream/tests/results/ + + if-no-files-found: error + + - name: Upload code coverage results + uses: actions/upload-artifact@v3 + with: + name: ubuntu-codecov-results-cpp + path: ./coverage-${{ github.job }}-${{ matrix.pl_backend }}.info + if-no-files-found: error + + cpptestswithOpenBLAS: + if: ${{ !contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }} + strategy: + matrix: + os: [ubuntu-22.04] + pl_backend: ["lightning_qubit"] + timeout-minutes: 60 + name: C++ tests (OpenBLAS) + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/setup-python@v5 + name: Install Python + with: + python-version: '3.9' + + - 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-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@v3 + if: always() + with: + name: ubuntu-tests-reports-${{ github.job }}-${{ matrix.pl_backend }} + path: ./Build/tests/results/ + if-no-files-found: error + + - name: Upload code coverage results + uses: actions/upload-artifact@v3 + with: + name: ubuntu-codecov-results-cpp + path: ./Build/coverage-${{ github.job }}-${{ matrix.pl_backend }}.info + if-no-files-found: error + + build_and_cache_Kokkos: + name: "Build and cache Kokkos" + uses: ./.github/workflows/build_and_cache_Kokkos_linux.yml + with: + os: ubuntu-22.04 + + cpptestswithKokkos: + if: ${{ !contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }} + needs: [build_and_cache_Kokkos] + 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 (Kokkos) + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/setup-python@v5 + name: Install Python + with: + python-version: '3.9' + + - 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@v3 + if: always() + with: + name: ubuntu-tests-reports-${{ github.job }}_${{ matrix.pl_backend }} + path: ./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: ./Build/coverage-${{ github.job }}-${{ matrix.pl_backend }}.info + if-no-files-found: error + + 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@v3 + with: + name: ubuntu-codecov-results-cpp + + - 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] + 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) + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/setup-python@v5 + name: Install Python + with: + python-version: '3.9' + + - 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: | + set -x + 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; + set +x + + - name: Upload test results + uses: actions/upload-artifact@v3 + if: always() + with: + name: ubuntu-tests-reports-${{ github.job }}-multiple-backends + path: ./Build/tests/results_multiple_backends/ + if-no-files-found: error diff --git a/.github/workflows/tests_linux.yml b/.github/workflows/tests_linux_python.yml similarity index 58% rename from .github/workflows/tests_linux.yml rename to .github/workflows/tests_linux_python.yml index df9ef214a8..47af4fc938 100644 --- a/.github/workflows/tests_linux.yml +++ b/.github/workflows/tests_linux_python.yml @@ -1,4 +1,4 @@ -name: Testing (Linux) +name: Testing::x86_64::Python on: workflow_call: inputs: @@ -11,6 +11,9 @@ on: 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: + paths-ignore: + - pennylane_lightning/core/src/simulators/lightning_gpu/** + - pennylane_lightning/lightning_gpu/** push: branches: - master @@ -24,98 +27,10 @@ env: OMP_PROC_BIND: "false" concurrency: - group: tests_linux-${{ github.ref }}-${{ inputs.lightning-version }}-${{ inputs.pennylane-version }} + group: tests_linux_python-${{ github.ref }}-${{ inputs.lightning-version }}-${{ inputs.pennylane-version }} cancel-in-progress: true jobs: - cpptests: - if: ${{ !contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }} - strategy: - matrix: - os: [ubuntu-22.04] - pl_backend: ["lightning_qubit"] - timeout-minutes: 60 - name: C++ tests - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/setup-python@v5 - name: Install Python - with: - python-version: '3.9' - - - 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 \ - -DPL_BACKEND=${{ matrix.pl_backend }} \ - -DCMAKE_CXX_COMPILER=$(which g++-$GCC_VERSION) \ - -DENABLE_COVERAGE=ON - - cmake . -BBuildKernelOMP -G Ninja \ - -DCMAKE_BUILD_TYPE=Debug \ - -DBUILD_TESTS=ON \ - -DENABLE_PYTHON=OFF \ - -DPL_BACKEND=${{ matrix.pl_backend }} \ - -DCMAKE_CXX_COMPILER=$(which g++-$GCC_VERSION) \ - -DENABLE_COVERAGE=ON \ - -DLQ_ENABLE_KERNEL_OMP=ON - - cmake . -BBuildKernelAVXStream -G Ninja \ - -DCMAKE_BUILD_TYPE=Debug \ - -DBUILD_TESTS=ON \ - -DENABLE_PYTHON=OFF \ - -DPL_BACKEND=${{ matrix.pl_backend }} \ - -DCMAKE_CXX_COMPILER=$(which g++-$GCC_VERSION) \ - -DENABLE_COVERAGE=ON \ - -DLQ_ENABLE_KERNEL_AVX_STREAM=ON \ - -DLQ_ENABLE_KERNEL_OMP=ON - - - cmake --build ./Build - cmake --build ./BuildKernelOMP - cmake --build ./BuildKernelAVXStream - - for d in Build BuildKernelOMP BuildKernelAVXStream; do - cd ./$d - 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 - cd .. - done - lcov --add-tracefile ./Build/coverage.info -a ./BuildKernelOMP/coverage.info \ - --add-tracefile ./BuildKernelAVXStream/coverage.info -o 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: | - ./Build/tests/results/ - ./BuildKernelOMP/tests/results/ - ./BuildKernelAVXStream/tests/results/ - - if-no-files-found: error - - - name: Upload code coverage results - uses: actions/upload-artifact@v3 - with: - name: ubuntu-codecov-results-cpp - path: ./coverage-${{ github.job }}-${{ matrix.pl_backend }}.info - if-no-files-found: error pythontests: strategy: @@ -223,62 +138,6 @@ jobs: ./main/.coverage-${{ github.job }}-${{ matrix.pl_backend }} if-no-files-found: error - cpptestswithOpenBLAS: - if: ${{ !contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }} - strategy: - matrix: - os: [ubuntu-22.04] - pl_backend: ["lightning_qubit"] - timeout-minutes: 60 - name: C++ tests (OpenBLAS) - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/setup-python@v5 - name: Install Python - with: - python-version: '3.9' - - - 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-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@v3 - if: always() - with: - name: ubuntu-tests-reports-${{ github.job }}-${{ matrix.pl_backend }} - path: ./Build/tests/results/ - if-no-files-found: error - - - name: Upload code coverage results - uses: actions/upload-artifact@v3 - with: - name: ubuntu-codecov-results-cpp - path: ./Build/coverage-${{ github.job }}-${{ matrix.pl_backend }}.info - if-no-files-found: error pythontestswithOpenBLAS: strategy: @@ -387,80 +246,6 @@ jobs: with: os: ubuntu-22.04 - cpptestswithKokkos: - if: ${{ !contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }} - needs: [build_and_cache_Kokkos] - 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 (Kokkos) - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/setup-python@v5 - name: Install Python - with: - python-version: '3.9' - - - 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@v3 - if: always() - with: - name: ubuntu-tests-reports-${{ github.job }}_${{ matrix.pl_backend }} - path: ./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: ./Build/coverage-${{ github.job }}-${{ matrix.pl_backend }}.info - if-no-files-found: error - pythontestswithKokkos: needs: [build_and_cache_Kokkos] strategy: @@ -645,87 +430,3 @@ jobs: verbose: true token: ${{ secrets.CODECOV_TOKEN }} - 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@v3 - with: - name: ubuntu-codecov-results-cpp - - - 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] - 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) - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/setup-python@v5 - name: Install Python - with: - python-version: '3.9' - - - 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: | - set -x - 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; - set +x - - - name: Upload test results - uses: actions/upload-artifact@v3 - if: always() - with: - name: ubuntu-tests-reports-${{ github.job }}-multiple-backends - path: ./Build/tests/results_multiple_backends/ - if-no-files-found: error diff --git a/.github/workflows/tests_lkcuda_cpp.yml b/.github/workflows/tests_lkcuda_cpp.yml new file mode 100644 index 0000000000..2f39943b94 --- /dev/null +++ b/.github/workflows/tests_lkcuda_cpp.yml @@ -0,0 +1,190 @@ +name: Testing::x86_64::LKokkos::CUDA::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: + paths: + - pennylane_lightning/core/src/** + - '!pennylane_lightning/core/src/simulators/lightning_gpu/**' + - '!pennylane_lightning/core/src/simulators/lightning_qubit/**' + + 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 + TF_VERSION: 2.10.0 + TORCH_VERSION: 1.11.0+cpu + +concurrency: + group: tests_lkcuda_cpp-${{ github.ref }}-${{ inputs.lightning-version }}-${{ inputs.pennylane-version }} + 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.2.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 ${{ matrix.kokkos_version }} https://github.com/kokkos/kokkos.git kokkos_${{ matrix.exec_model }} + 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: + # TODO: The issue related to Kokkos with CUDA-12 running out of memory needs to be fixed. + if: ${{ github.sha == 'xxxxxxxx' }} + needs: [builddeps] + strategy: + matrix: + os: [ubuntu-22.04] + pl_backend: ["lightning_kokkos"] + exec_model: ["CUDA"] + kokkos_version: ["4.2.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@v4 + with: + path: main + + - uses: actions/setup-python@v5 + 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 diff --git a/.github/workflows/tests_gpu_kokkos.yml b/.github/workflows/tests_lkcuda_python.yml similarity index 74% rename from .github/workflows/tests_gpu_kokkos.yml rename to .github/workflows/tests_lkcuda_python.yml index 663f020e9e..f4e77417e2 100644 --- a/.github/workflows/tests_gpu_kokkos.yml +++ b/.github/workflows/tests_lkcuda_python.yml @@ -1,4 +1,4 @@ -name: Testing::LKokkos::GPU +name: Testing::x86_64::LKokkos::CUDA::Python on: workflow_call: inputs: @@ -11,6 +11,11 @@ on: 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: + paths-ignore: + - pennylane_lightning/core/src/simulators/lightning_gpu/** + - pennylane_lightning/core/src/simulators/lightning_qubit/** + - pennylane_lightning/lightning_gpu/** + - pennylane_lightning/lightning_qubit/** push: branches: - master @@ -23,7 +28,7 @@ env: TORCH_VERSION: 1.11.0+cpu concurrency: - group: tests_gpu-${{ github.ref }}-${{ inputs.lightning-version }}-${{ inputs.pennylane-version }} + group: tests_lkcuda_python-${{ github.ref }}-${{ inputs.lightning-version }}-${{ inputs.pennylane-version }} cancel-in-progress: true jobs: @@ -95,94 +100,6 @@ jobs: 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' }} - needs: [builddeps] - strategy: - matrix: - os: [ubuntu-22.04] - pl_backend: ["lightning_kokkos"] - exec_model: ["CUDA"] - kokkos_version: ["4.2.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@v4 - with: - path: main - - - uses: actions/setup-python@v5 - 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: diff --git a/.github/workflows/tests_windows.yml b/.github/workflows/tests_windows_cpp.yml similarity index 97% rename from .github/workflows/tests_windows.yml rename to .github/workflows/tests_windows_cpp.yml index 10d25bd8f1..2ee1d9b313 100644 --- a/.github/workflows/tests_windows.yml +++ b/.github/workflows/tests_windows_cpp.yml @@ -1,4 +1,4 @@ -name: Testing (Windows) +name: Testing::x86_64::Windows:C++ on: workflow_call: inputs: @@ -14,9 +14,13 @@ on: branches: - master pull_request: + paths: + - .github/workflows/tests_windows_cpp.yml + - pennylane_lightning/core/src/** + - '!pennylane_lightning/core/src/simulators/lightning_gpu/**' concurrency: - group: tests_windows-${{ github.ref }} + group: tests_windows_cpp-${{ github.ref }} cancel-in-progress: true jobs: diff --git a/.github/workflows/tests_without_binary.yml b/.github/workflows/tests_without_binary.yml index c061e64d7d..9854d39526 100644 --- a/.github/workflows/tests_without_binary.yml +++ b/.github/workflows/tests_without_binary.yml @@ -11,11 +11,12 @@ on: 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: + paths-ignore: + - pennylane_lightning/core/src/** push: branches: - master - env: COVERAGE_FLAGS: "--cov=pennylane_lightning --cov-report=term-missing --cov-report=xml:./coverage.xml --no-flaky-report -p no:warnings --tb=native" diff --git a/pennylane_lightning/core/_version.py b/pennylane_lightning/core/_version.py index fd9437debb..1b3bcb62fc 100644 --- a/pennylane_lightning/core/_version.py +++ b/pennylane_lightning/core/_version.py @@ -16,4 +16,4 @@ Version number (major.minor.patch[-label]) """ -__version__ = "0.36.0-dev41" +__version__ = "0.36.0-dev42"