diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index be57b94646..494f13638c 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -7,8 +7,14 @@ ### Breaking changes +* Migrate `lightning.gpu` to CUDA 12. + [(#606)](https://github.com/PennyLaneAI/pennylane-lightning/pull/606) + ### Improvements +* Lower the overheads of Windows CI tests. + [(#610)](https://github.com/PennyLaneAI/pennylane-lightning/pull/610) + * Decouple LightningQubit memory ownership from numpy and migrate it to Lightning-Qubit managed state-vector class. [(#601)](https://github.com/PennyLaneAI/pennylane-lightning/pull/601) diff --git a/.github/workflows/compat-check-latest-latest.yml b/.github/workflows/compat-check-latest-latest.yml index 16a11078b1..63533e089d 100644 --- a/.github/workflows/compat-check-latest-latest.yml +++ b/.github/workflows/compat-check-latest-latest.yml @@ -20,7 +20,7 @@ jobs: pennylane-version: latest tests_lgpu_gpu: name: Lightning Compatibility test (tests_lgpu_gpu) - latest/latest - uses: ./.github/workflows/tests_gpu_cu11.yml + uses: ./.github/workflows/tests_gpu_cuda.yml with: lightning-version: latest pennylane-version: latest diff --git a/.github/workflows/compat-check-latest-stable.yml b/.github/workflows/compat-check-latest-stable.yml index d370a1240e..3e589283eb 100644 --- a/.github/workflows/compat-check-latest-stable.yml +++ b/.github/workflows/compat-check-latest-stable.yml @@ -20,7 +20,7 @@ jobs: pennylane-version: stable tests_lgpu_gpu: name: Lightning Compatibility test (tests_lgpu_gpu) - latest/stable - uses: ./.github/workflows/tests_gpu_cu11.yml + uses: ./.github/workflows/tests_gpu_cuda.yml with: lightning-version: latest pennylane-version: stable diff --git a/.github/workflows/compat-check-release-release.yml b/.github/workflows/compat-check-release-release.yml index 9c179708e9..52c6bea41c 100644 --- a/.github/workflows/compat-check-release-release.yml +++ b/.github/workflows/compat-check-release-release.yml @@ -20,7 +20,7 @@ jobs: pennylane-version: release tests_lgpu_gpu: name: Lightning Compatibility test (tests_lgpu_gpu) - release/release - uses: ./.github/workflows/tests_gpu_cu11.yml + uses: ./.github/workflows/tests_gpu_cuda.yml with: lightning-version: release pennylane-version: release diff --git a/.github/workflows/compat-check-stable-latest.yml b/.github/workflows/compat-check-stable-latest.yml index 65eceb4aed..f7e125ca69 100644 --- a/.github/workflows/compat-check-stable-latest.yml +++ b/.github/workflows/compat-check-stable-latest.yml @@ -20,7 +20,7 @@ jobs: pennylane-version: latest tests_lgpu_gpu: name: Lightning Compatibility test (tests_lgpu_gpu) - stable/latest - uses: ./.github/workflows/tests_gpu_cu11.yml + uses: ./.github/workflows/tests_gpu_cuda.yml with: lightning-version: stable pennylane-version: latest diff --git a/.github/workflows/compat-check-stable-stable.yml b/.github/workflows/compat-check-stable-stable.yml index 4bcba8fcbb..8f33068c39 100644 --- a/.github/workflows/compat-check-stable-stable.yml +++ b/.github/workflows/compat-check-stable-stable.yml @@ -20,7 +20,7 @@ jobs: pennylane-version: stable tests_lgpu_gpu: name: Lightning Compatibility test (tests_lgpu_gpu) - stable/stable - uses: ./.github/workflows/tests_gpu_cu11.yml + uses: ./.github/workflows/tests_gpu_cuda.yml with: lightning-version: stable pennylane-version: stable diff --git a/.github/workflows/tests_gpu_cu11.yml b/.github/workflows/tests_gpu_cuda.yml similarity index 96% rename from .github/workflows/tests_gpu_cu11.yml rename to .github/workflows/tests_gpu_cuda.yml index 12d4c26786..06741a1152 100644 --- a/.github/workflows/tests_gpu_cu11.yml +++ b/.github/workflows/tests_gpu_cuda.yml @@ -39,25 +39,27 @@ jobs: 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/11.8 + module load cuda/${{ matrix.cuda_version }} echo "${PATH}" >> $GITHUB_PATH echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> $GITHUB_ENV nvcc --version nvidia-smi - cpptestswithLGPU_cu11: + 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: @@ -70,7 +72,7 @@ jobs: run: | source /etc/profile.d/modules.sh module use /opt/modules - module load cuda/11.8 + module load cuda/${{ matrix.cuda_version }} echo "${PATH}" >> $GITHUB_PATH echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> $GITHUB_ENV nvcc --version @@ -117,7 +119,7 @@ jobs: - name: Install required packages run: | - python -m pip install ninja cmake custatevec-cu11 + 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 @@ -161,6 +163,7 @@ jobs: os: [ubuntu-22.04] pl_backend: ["lightning_gpu"] default_backend: ["lightning_qubit"] + cuda_version: ["12"] name: Python tests with LGPU runs-on: @@ -173,7 +176,7 @@ jobs: run: | source /etc/profile.d/modules.sh module use /opt/modules - module load cuda/11.8 + module load cuda/${{ matrix.cuda_version }} echo "${PATH}" >> $GITHUB_PATH echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> $GITHUB_ENV nvcc --version @@ -238,7 +241,7 @@ jobs: run: | cd main python -m pip install -r requirements-dev.txt - python -m pip install cmake custatevec-cu11 openfermionpyscf + python -m pip install cmake custatevec-cu${{ matrix.cuda_version }} openfermionpyscf - name: Checkout PennyLane for release build if: inputs.pennylane-version == 'release' @@ -344,7 +347,7 @@ jobs: token: ${{ secrets.CODECOV_TOKEN }} upload-to-codecov-linux-cpp: - needs: [cpptestswithLGPU_cu11] + needs: [cpptestswithLGPU] name: Upload coverage data to codecov runs-on: ubuntu-latest steps: diff --git a/.github/workflows/tests_linux_x86_mpi_gpu.yml b/.github/workflows/tests_linux_x86_mpi_gpu.yml index 648e68bdb3..7af97b5046 100644 --- a/.github/workflows/tests_linux_x86_mpi_gpu.yml +++ b/.github/workflows/tests_linux_x86_mpi_gpu.yml @@ -39,6 +39,8 @@ jobs: max-parallel: 1 matrix: mpilib: ["mpich", "openmpi"] + cuda_version_maj: ["12"] + cuda_version_min: ["2"] timeout-minutes: 30 steps: @@ -92,28 +94,29 @@ jobs: - name: Install required packages run: | python -m pip install -r requirements-dev.txt - python -m pip install cmake custatevec-cu11 + python -m pip install cmake custatevec-cu12 sudo apt-get -y -q install liblapack-dev - - name: Validate GPU version and installed compiler + - name: Validate GPU version and installed compiler and modules run: | - source /etc/profile.d/modules.sh && module use /opt/modules && module load cuda/11.8 + 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 }} + 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 }} + 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 }} + 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 \ @@ -123,7 +126,7 @@ jobs: -DBUILD_TESTS=ON \ -DENABLE_LAPACK=ON \ -DCMAKE_CXX_COMPILER=mpicxx \ - -DCMAKE_CUDA_COMPILER="/usr/local/cuda/bin/nvcc" \ + -DCMAKE_CUDA_COMPILER=$(which nvcc) \ -DCMAKE_CUDA_ARCHITECTURES="86" \ -DPython_EXECUTABLE:FILE="${{ steps.python_path.outputs.python }}" \ -G Ninja @@ -131,7 +134,7 @@ jobs: 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 /opt/mpi/${{ matrix.mpilib }}/bin/mpirun -np 2 ./$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 @@ -171,6 +174,8 @@ jobs: max-parallel: 1 matrix: mpilib: ["mpich", "openmpi"] + cuda_version_maj: ["12"] + cuda_version_min: ["2"] timeout-minutes: 30 steps: @@ -232,9 +237,9 @@ jobs: - name: Install required packages run: | - source /etc/profile.d/modules.sh && module use /opt/modules/ && module load ${{ matrix.mpilib }} + source /etc/profile.d/modules.sh && module use /opt/modules/ && module load ${{ matrix.mpilib }}/cuda-${{ matrix.cuda_version_maj }}.${{ matrix.cuda_version_min }} python -m pip install -r requirements-dev.txt - python -m pip install custatevec-cu11 mpi4py openfermionpyscf + python -m pip install custatevec-cu${{ matrix.cuda_version_maj }} mpi4py openfermionpyscf SKIP_COMPILATION=True PL_BACKEND=lightning_qubit python -m pip install -e . -vv - name: Checkout PennyLane for release build @@ -256,25 +261,25 @@ jobs: env: CUQUANTUM_SDK: $(python -c "import site; print( f'{site.getsitepackages()[0]}/cuquantum/lib')") run: | - source /etc/profile.d/modules.sh && module use /opt/modules/ && module load ${{ matrix.mpilib }} - CMAKE_ARGS="-DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpicxx -DENABLE_MPI=ON -DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc -DCMAKE_CUDA_ARCHITECTURES=${{ env.CI_CUDA_ARCH }} -DPython_EXECUTABLE=${{ steps.python_path.outputs.python }}" \ + source /etc/profile.d/modules.sh && module use /opt/modules/ && module load ${{ matrix.mpilib }}/cuda-${{ matrix.cuda_version_maj }}.${{ matrix.cuda_version_min }} + CMAKE_ARGS="-DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpicxx -DENABLE_MPI=ON -DCMAKE_CUDA_COMPILER=$(which nvcc) -DCMAKE_CUDA_ARCHITECTURES=${{ env.CI_CUDA_ARCH }} -DPython_EXECUTABLE=${{ steps.python_path.outputs.python }}" \ PL_BACKEND=lightning_gpu python -m pip install -e . --verbose # There are issues running py-cov with MPI. A solution is to use coverage as reported # [here](https://github.com/pytest-dev/pytest-cov/issues/237#issuecomment-544824228) - name: Run unit tests for MPI-enabled lightning.gpu device run: | - source /etc/profile.d/modules.sh && module use /opt/modules/ && module load ${{ matrix.mpilib }} - PL_DEVICE=lightning.gpu /opt/mpi/${{ matrix.mpilib }}/bin/mpirun -np 2 \ + source /etc/profile.d/modules.sh && module use /opt/modules/ && module load ${{ matrix.mpilib }}/cuda-${{ matrix.cuda_version_maj }}.${{ matrix.cuda_version_min }} + PL_DEVICE=lightning.gpu mpirun -np 2 \ coverage run --rcfile=.coveragerc --source=pennylane_lightning -p -m mpi4py -m pytest ./mpitests --tb=native coverage combine - coverage xml -o coverage-${{ github.job }}-lightning_gpu_${{ matrix.mpilib }}-main.xml + coverage xml -o coverage-${{ github.job }}-lightning_gpu_${{ matrix.mpilib }}_cu${{ matrix.cuda_version_maj }}-main.xml - name: Upload code coverage results uses: actions/upload-artifact@v3 with: name: ubuntu-codecov-results-python - path: coverage-${{ github.job }}-lightning_gpu_${{ matrix.mpilib }}-*.xml + path: coverage-${{ github.job }}-lightning_gpu_${{ matrix.mpilib }}_cu${{ matrix.cuda_version_maj }}-*.xml if-no-files-found: error - name: Cleanup diff --git a/.github/workflows/tests_windows.yml b/.github/workflows/tests_windows.yml index 1d56af45b5..395d4a8bdd 100644 --- a/.github/workflows/tests_windows.yml +++ b/.github/workflows/tests_windows.yml @@ -20,76 +20,6 @@ concurrency: cancel-in-progress: true jobs: - cpptests: - if: ${{ !contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }} - timeout-minutes: 45 - name: C++ tests (Windows) - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [windows-latest] - pl_backend: ["lightning_qubit"] - steps: - - name: Checkout PennyLane-Lightning - uses: actions/checkout@v3 - - - name: Configure MSVC for amd64 # Use cl.exe as a default compiler - uses: ilammy/msvc-dev-cmd@v1 - with: - arch: amd64 - - - name: Install lapack with vcpkg - run: | - git clone --quiet --recursive https://github.com/microsoft/vcpkg.git - cd vcpkg - .\bootstrap-vcpkg.bat - vcpkg install lapack - - - name: Setup OpenCppCoverage and add to PATH - run: | - choco install OpenCppCoverage -y - echo "C:\Program Files\OpenCppCoverage" >> $env:GITHUB_PATH - - - name: Build and run unit tests for code coverage - run: | - cmake -BBuild ` - -DBUILD_TESTS=ON ` - -DENABLE_OPENMP=OFF ` - -DENABLE_PYTHON=OFF ` - -DENABLE_GATE_DISPATCHER=OFF ` - -DPL_BACKEND=${{ matrix.pl_backend }} ` - -DENABLE_LAPACK=ON ` - -DCMAKE_TOOLCHAIN_FILE=D:/a/pennylane-lightning/pennylane-lightning/vcpkg/scripts/buildsystems/vcpkg.cmake ` - -DENABLE_WARNINGS=OFF - cmake --build .\Build --config Debug - mkdir -p .\Build\tests\results - $test_bins = Get-ChildItem -Include *.exe -Recurse -Path ./Build/Debug - foreach ($file in $test_bins) - { - $filename = $file.ToString() -replace '.{4}$' - $filename = $filename.Substring($filename.LastIndexOf("\")+1) - $test_call = $file.ToString() + " --order lex --reporter junit --out .\Build\tests\results\report_" + $filename + ".xml" - Invoke-Expression $test_call - $cov_call = "OpenCppCoverage --sources pennylane_lightning\core\src --export_type cobertura:coverage.xml " + $file.ToString() - Invoke-Expression $cov_call - } - Move-Item -Path .\coverage.xml -Destination .\coverage-${{ github.job }}-${{ matrix.pl_backend }}.xml - - - name: Upload test results - uses: actions/upload-artifact@v3 - if: always() - with: - name: windows-test-report-${{ github.job }}-${{ matrix.pl_backend }} - path: .\Build\tests\results\ - if-no-files-found: error - - - name: Upload coverage results - uses: actions/upload-artifact@v3 - with: - name: windows-coverage-report - path: .\coverage-${{ github.job }}-${{ matrix.pl_backend }}.xml - if-no-files-found: error - win-set-matrix-x86: name: Set builder matrix runs-on: ubuntu-latest @@ -110,7 +40,7 @@ jobs: exec_model: ${{ steps.exec_model.outputs.exec_model }} kokkos_version: ${{ steps.kokkos_version.outputs.kokkos_version }} - build_dependencies: + build_dependencies_kokkos: needs: [win-set-matrix-x86] strategy: fail-fast: false @@ -125,7 +55,7 @@ jobs: steps: - name: Cache installation directories id: kokkos-cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: D:\a\install_dir\${{ matrix.exec_model }} key: ${{ matrix.os }}-kokkos${{ matrix.kokkos_version }}-${{ matrix.exec_model }}-Debug @@ -163,9 +93,111 @@ jobs: cmake --build ./Build --config Debug --verbose cmake --install ./Build --config Debug --verbose + build_dependencies_vcpkg: + strategy: + fail-fast: false + matrix: + os: [windows-latest] + timeout-minutes: 30 + name: vcpkg dependencies + runs-on: ${{ matrix.os }} + + steps: + - name: Cache installation directories + id: vcpkg-cache + uses: actions/cache@v4 + with: + path: D:\a\install_dir\vcpkg + key: ${{ matrix.os }}-vcpkg + + - name: Clone vcpkg + if: steps.vcpkg-cache.outputs.cache-hit != 'true' + run: | + mkdir -p D:\a\install_dir + cd D:\a\install_dir\ + git clone --quiet --recursive https://github.com/microsoft/vcpkg.git + + - name: Install dependencies + if: steps.vcpkg-cache.outputs.cache-hit != 'true' + run: | + python -m pip install cmake build ninja + + - name: Build Lapack library + if: steps.vcpkg-cache.outputs.cache-hit != 'true' + run: | + cd D:\a\install_dir\vcpkg + .\bootstrap-vcpkg.bat + vcpkg install lapack + + cpptests: + needs: [build_dependencies_vcpkg] + if: ${{ !contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }} + timeout-minutes: 30 + name: C++ tests (Windows) + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-latest] + pl_backend: ["lightning_qubit"] + steps: + - name: Checkout PennyLane-Lightning + uses: actions/checkout@v3 + + - name: Restoring cached vcpkg + id: vcpkg-cache + uses: actions/cache@v4 + with: + path: D:\a\install_dir\vcpkg + key: ${{ matrix.os }}-vcpkg + + - name: Setup OpenCppCoverage and add to PATH + run: | + choco install OpenCppCoverage -y + echo "C:\Program Files\OpenCppCoverage" >> $env:GITHUB_PATH + + - name: Build and run unit tests for code coverage + run: | + cmake -BBuild ` + -DBUILD_TESTS=ON ` + -DENABLE_OPENMP=OFF ` + -DENABLE_PYTHON=OFF ` + -DENABLE_GATE_DISPATCHER=OFF ` + -DPL_BACKEND=${{ matrix.pl_backend }} ` + -DENABLE_LAPACK=ON ` + -DCMAKE_TOOLCHAIN_FILE=D:\a\install_dir\vcpkg\scripts\buildsystems\vcpkg.cmake ` + -DENABLE_WARNINGS=OFF + cmake --build .\Build --config RelWithDebInfo + mkdir -p .\Build\tests\results + $test_bins = Get-ChildItem -Include *.exe -Recurse -Path ./Build/RelWithDebInfo + foreach ($file in $test_bins) + { + $filename = $file.ToString() -replace '.{4}$' + $filename = $filename.Substring($filename.LastIndexOf("\")+1) + $test_call = $file.ToString() + " --order lex --reporter junit --out .\Build\tests\results\report_" + $filename + ".xml" + Invoke-Expression $test_call + $cov_call = "OpenCppCoverage --sources pennylane_lightning\core\src --excluded_modules D:\a\install_dir\* --excluded_modules C:\Windows\System32\* --export_type cobertura:coverage.xml " + $file.ToString() + Invoke-Expression $cov_call + } + Move-Item -Path .\coverage.xml -Destination .\coverage-${{ github.job }}-${{ matrix.pl_backend }}.xml + + - name: Upload test results + uses: actions/upload-artifact@v3 + if: always() + with: + name: windows-test-report-${{ github.job }}-${{ matrix.pl_backend }} + path: .\Build\tests\results\ + if-no-files-found: error + + - name: Upload coverage results + uses: actions/upload-artifact@v3 + with: + name: windows-coverage-report + path: .\coverage-${{ github.job }}-${{ matrix.pl_backend }}.xml + if-no-files-found: error + cpptestswithkokkos: if: ${{ !contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }} - needs: [build_dependencies, win-set-matrix-x86] + needs: [build_dependencies_kokkos, build_dependencies_vcpkg, win-set-matrix-x86] strategy: matrix: os: [windows-latest] @@ -180,32 +212,27 @@ jobs: steps: - name: Restoring cached Kokkos id: kokkos-cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: D:\a\install_dir\${{ matrix.exec_model }} key: ${{ matrix.os }}-kokkos${{ matrix.kokkos_version }}-${{ matrix.exec_model }}-Debug + + - name: Restoring cached vcpkg + id: vcpkg-cache + uses: actions/cache@v4 + with: + path: D:\a\install_dir\vcpkg + key: ${{ matrix.os }}-vcpkg - name: Checkout PennyLane-Lightning uses: actions/checkout@v3 - - name: Copy cached libraries + - name: Copy cached Kokkos libraries if: steps.kokkos-cache.outputs.cache-hit == 'true' run: | Copy-Item -Path "D:\a\install_dir\${{ matrix.exec_model }}\" ` -Destination "D:\a\pennylane-lightning\pennylane-lightning\Kokkos" -Recurse -Force - - name: Configure MSVC for amd64 # Use cl.exe as a default compiler - uses: ilammy/msvc-dev-cmd@v1 - with: - arch: amd64 - - - name: Install lapack with vcpkg - run: | - git clone --quiet --recursive https://github.com/microsoft/vcpkg.git - cd vcpkg - .\bootstrap-vcpkg.bat - vcpkg install lapack - - name: Enable long paths run: | powershell.exe New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force @@ -224,7 +251,7 @@ jobs: -DENABLE_PYTHON=OFF ` -DENABLE_GATE_DISPATCHER=OFF ` -DCMAKE_PREFIX_PATH=D:\a\pennylane-lightning\pennylane-lightning\Kokkos ` - -DCMAKE_TOOLCHAIN_FILE=D:/a/pennylane-lightning/pennylane-lightning/vcpkg/scripts/buildsystems/vcpkg.cmake ` + -DCMAKE_TOOLCHAIN_FILE=D:\a\install_dir\vcpkg\scripts\buildsystems\vcpkg.cmake ` -DENABLE_OPENMP=OFF ` -DPL_BACKEND=${{ matrix.pl_backend }} ` -DENABLE_LAPACK=ON ` @@ -238,7 +265,7 @@ jobs: $filename = $filename.Substring($filename.LastIndexOf("\")+1) $test_call = $file.ToString() + " --order lex --reporter junit --out .\Build\tests\results\report_" + $filename + ".xml" Invoke-Expression $test_call - $cov_call = "OpenCppCoverage --sources pennylane_lightning\core\src --export_type cobertura:coverage.xml " + $file.ToString() + $cov_call = "OpenCppCoverage --sources pennylane_lightning\core\src --excluded_modules D:\a\install_dir\* --excluded_modules C:\Windows\System32\* --export_type cobertura:coverage.xml " + $file.ToString() Invoke-Expression $cov_call } Move-Item -Path .\coverage.xml -Destination .\coverage-${{ github.job }}-${{ matrix.pl_backend }}.xml diff --git a/.github/workflows/wheel_linux_x86_64_cu11.yml b/.github/workflows/wheel_linux_x86_64_cuda.yml similarity index 76% rename from .github/workflows/wheel_linux_x86_64_cu11.yml rename to .github/workflows/wheel_linux_x86_64_cuda.yml index 33a5d6f8b3..27a1841a4e 100644 --- a/.github/workflows/wheel_linux_x86_64_cu11.yml +++ b/.github/workflows/wheel_linux_x86_64_cuda.yml @@ -1,4 +1,4 @@ -name: Wheel::Linux::x86_64::CUDA-11 +name: Wheel::Linux::x86_64::CUDA # **What it does**: Builds python wheels for Linux (ubuntu-latest) architecture x86_64 and store it as artifacts. # Python versions: 3.9, 3.10, 3.11, 3.12. @@ -6,9 +6,7 @@ name: Wheel::Linux::x86_64::CUDA-11 # **Who does it impact**: Wheels to be uploaded to PyPI. env: - GCC_VERSION: 11 - CUDA_VERSION_MAJOR: 11 - CUDA_VERSION_MINOR: 5 + GCC_VERSION: "11" on: pull_request: @@ -19,7 +17,7 @@ on: types: [published] concurrency: - group: wheel_linux_x86_64_cu11-${{ github.ref }} + group: wheel_linux_x86_64_cu12-${{ github.ref }} cancel-in-progress: true jobs: @@ -37,15 +35,15 @@ jobs: os: [ubuntu-latest] arch: [x86_64] pl_backend: ["lightning_gpu"] + cuda_version: ["12"] cibw_build: ${{ fromJson(needs.set_wheel_build_matrix.outputs.python_version) }} container_img: ["quay.io/pypa/manylinux2014_x86_64"] timeout-minutes: 30 - name: ${{ matrix.os }}::${{ matrix.arch }} - ${{ matrix.pl_backend }} (Python ${{ fromJson('{ "cp39-*":"3.9","cp310-*":"3.10","cp311-*":"3.11","cp312-*":"3.12" }')[matrix.cibw_build] }}) + name: ${{ matrix.os }}::${{ matrix.arch }} - ${{ matrix.pl_backend }} CUDA ${{ matrix.cuda_version }} (Python ${{ fromJson('{ "cp39-*":"3.9","cp310-*":"3.10","cp311-*":"3.11","cp312-*":"3.12" }')[matrix.cibw_build] }}) runs-on: ${{ matrix.os }} container: ${{ matrix.container_img }} steps: - - name: Checkout PennyLane-Lightning uses: actions/checkout@v3 @@ -67,24 +65,25 @@ jobs: CIBW_SKIP: "*-musllinux*" - CIBW_CONFIG_SETTINGS: --global-option=build_ext --global-option=--define="CMAKE_CXX_COMPILER=$(which g++-11);CMAKE_C_COMPILER=$(which gcc-11);LIGHTNING_RELEASE_TAG=master" + CIBW_CONFIG_SETTINGS: --global-option=build_ext --global-option=--define="CMAKE_CXX_COMPILER=$(which g++);CMAKE_C_COMPILER=$(which gcc);LIGHTNING_RELEASE_TAG=master" # Python build settings CIBW_BEFORE_BUILD: | cat /etc/yum.conf | sed "s/\[main\]/\[main\]\ntimeout=5/g" > /etc/yum.conf - python -m pip install ninja cmake~=3.24.3 auditwheel custatevec-cu11 + python -m pip install ninja cmake~=3.24.3 auditwheel custatevec-cu${{ matrix.cuda_version }} yum clean all -y yum install centos-release-scl-rh -y yum install devtoolset-11-gcc-c++ -y source /opt/rh/devtoolset-11/enable -y yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-rhel7.repo -y - yum -y install cuda-11-5 git openssh wget + yum -y install cuda-${{ matrix.cuda_version }}-0 git openssh wget # ensure nvcc is available CIBW_ENVIRONMENT: | - PATH=$PATH:/usr/local/cuda/bin \ - LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64 \ - PL_BACKEND="${{ matrix.pl_backend }}" + PATH=/opt/rh/devtoolset-11/root/usr/bin:$PATH:/usr/local/cuda-${{ matrix.cuda_version }}/bin \ + LD_LIBRARY_PATH=/opt/rh/devtoolset-11/root/usr/lib64:/opt/rh/devtoolset-11/root/usr/lib:/opt/rh/devtoolset-11/root/usr/lib64/dyninst:/opt/rh/devtoolset-11/root/usr/lib/dyninst:$LD_LIBRARY_PATH:/usr/local/cuda-${{ matrix.cuda_version }}/lib64 \ + PL_BACKEND="${{ matrix.pl_backend }}" \ + PKG_CONFIG_PATH=/opt/rh/devtoolset-11/root/usr/lib64/pkgconfig:$PKG_CONFIG_PATH CIBW_REPAIR_WHEEL_COMMAND_LINUX: "./bin/auditwheel repair -w {dest_dir} {wheel}" @@ -108,7 +107,7 @@ jobs: - uses: actions/upload-artifact@v3 if: ${{ github.event_name == 'release' || github.ref == 'refs/heads/master' || steps.rc_build.outputs.match != ''}} with: - name: ${{ runner.os }}-wheels-${{ matrix.pl_backend }}-${{ matrix.arch }}.zip + name: ${{ runner.os }}-wheels-${{ matrix.pl_backend }}-${{ matrix.arch }}-cu${{ matrix.cuda_version }} path: ./wheelhouse/*.whl upload-pypi: @@ -122,7 +121,7 @@ jobs: steps: - uses: actions/download-artifact@v3 with: - name: Linux-wheels-${{ matrix.pl_backend }}-${{ matrix.arch }}.zip + name: ${{ runner.os }}-wheels-${{ matrix.pl_backend }}-${{ matrix.arch }}-cu${{ matrix.cuda_version }} path: dist - name: Upload wheels to PyPI diff --git a/README.rst b/README.rst index f82b4282a6..74090c8266 100644 --- a/README.rst +++ b/README.rst @@ -121,7 +121,7 @@ On MacOS, we recommend using the latest version of ``clang++`` and ``libomp``: $ brew install llvm libomp -The Lightning-GPU backend has several dependencies (e.g. ``CUDA``, ``custatevec-cu11``, etc.), and hence we recommend referring to Lightning-GPU installation section. +The Lightning-GPU backend has several dependencies (e.g. ``CUDA``, ``custatevec-cu12``, etc.), and hence we recommend referring to Lightning-GPU installation section. Similarly, for Lightning-Kokkos it is recommended to configure and install Kokkos independently as prescribed in the Lightning-Kokkos installation section. Development installation @@ -227,7 +227,7 @@ Lightning-GPU can be installed using ``pip``: pip install pennylane-lightning[gpu] -Lightning-GPU requires the `cuQuantum SDK `_ (only the `cuStateVec `_ library is required). +Lightning-GPU requires CUDA 12 and the `cuQuantum SDK `_ (only the `cuStateVec `_ library is required). The SDK may be installed within the Python environment ``site-packages`` directory using ``pip`` or ``conda`` or the SDK library path appended to the ``LD_LIBRARY_PATH`` environment variable. Please see the `cuQuantum SDK`_ install guide for more information. @@ -247,7 +247,7 @@ Then the `cuStateVec`_ library can be installed and set a ``CUQUANTUM_SDK`` envi .. code-block:: console - python -m pip install wheel custatevec-cu11 + python -m pip install wheel custatevec-cu12 export CUQUANTUM_SDK=$(python -c "import site; print( f'{site.getsitepackages()[0]}/cuquantum/lib')") The Lightning-GPU can then be installed with ``pip``: @@ -261,7 +261,7 @@ To simplify the build, we recommend using the containerized build process descri Install Lightning-GPU with MPI ============================== -Building Lightning-GPU with MPI also requires the ``NVIDIA cuQuantum SDK`` (currently supported version: `custatevec-cu11 `_), ``mpi4py`` and ``CUDA-aware MPI`` (Message Passing Interface). +Building Lightning-GPU with MPI also requires the ``NVIDIA cuQuantum SDK`` (currently supported version: `custatevec-cu12 `_), ``mpi4py`` and ``CUDA-aware MPI`` (Message Passing Interface). ``CUDA-aware MPI`` allows data exchange between GPU memory spaces of different nodes without the need for CPU-mediated transfers. Both the ``MPICH`` and ``OpenMPI`` libraries are supported, provided they are compiled with CUDA support. The path to ``libmpi.so`` should be found in ``LD_LIBRARY_PATH``. diff --git a/bin/auditwheel b/bin/auditwheel index e7142fa4ab..84de9fa7e1 100755 --- a/bin/auditwheel +++ b/bin/auditwheel @@ -5,21 +5,35 @@ import sys from auditwheel.main import main -from auditwheel.policy import _POLICIES as POLICIES +from auditwheel.policy import WheelPolicies as WP # Do not include licensed dynamic libraries libs = [ "libcudart.so.11.0", + "libcudart.so.12.0", "libcublasLt.so.11", + "libcublasLt.so.12", "libcublas.so.11", + "libcublas.so.12", "libcusparse.so.11", + "libcusparse.so.12", "libcustatevec.so.1", ] print(f"Excluding {libs}") -for p in POLICIES: - p["lib_whitelist"].extend(libs) +for arch in [ + "manylinux2014_x86_64", + "manylinux_2_28_x86_64", + "manylinux2014_aarch64", + "manylinux_2_28_aarch64", + "manylinux2014_ppc64le", + "manylinux_2_28_ppc64le", +]: + wheel_policy = WP() + arch_pol = wheel_policy.get_policy_by_name(arch) + if arch_pol: + arch_pol["lib_whitelist"].extend(libs) if __name__ == "__main__": sys.exit(main()) diff --git a/doc/requirements.txt b/doc/requirements.txt index ff26c3ded6..4887af0718 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -11,7 +11,7 @@ sphinxcontrib-qthelp==1.0.3 sphinxcontrib-htmlhelp==2.0.1 sphinxcontrib-serializinghtml==1.1.5 pennylane-sphinx-theme -custatevec-cu11 +custatevec-cu12 wheel sphinxext-opengraph matplotlib \ No newline at end of file diff --git a/pennylane_lightning/core/_version.py b/pennylane_lightning/core/_version.py index 2501bfbac7..87a919ae46 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.35.0-dev11" +__version__ = "0.35.0-dev12" diff --git a/pennylane_lightning/lightning_gpu/lightning_gpu.py b/pennylane_lightning/lightning_gpu/lightning_gpu.py index 349e821959..fba2612207 100644 --- a/pennylane_lightning/lightning_gpu/lightning_gpu.py +++ b/pennylane_lightning/lightning_gpu/lightning_gpu.py @@ -60,7 +60,7 @@ "cuquantum" ): # pragma: no cover raise ImportError( - 'custatevec libraries not found. Please pip install appropriate custatevec in a virtual environment and then add its path to the "LD_LIBRARY_PATH" environment variable.' + "custatevec libraries not found. Please pip install the appropriate custatevec library in a virtual environment." ) if not DevPool.getTotalDevices(): # pragma: no cover raise ValueError("No supported CUDA-capable device found") diff --git a/requirements-dev.txt b/requirements-dev.txt index 10e01a32cc..94456d4e0f 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -12,5 +12,5 @@ black==23.7.0 clang-tidy~=16.0 clang-format~=16.0 cmake -custatevec-cu11 +custatevec-cu12 pylint diff --git a/tests/test_adjoint_jacobian.py b/tests/test_adjoint_jacobian.py index 86c0a9e246..422ad06eef 100644 --- a/tests/test_adjoint_jacobian.py +++ b/tests/test_adjoint_jacobian.py @@ -727,6 +727,7 @@ def test_controlled_jacobian(self, par, n_qubits, control_value, operation, tol) np.random.seed(1337) init_state = np.random.rand(2**n_qubits) + 1.0j * np.random.rand(2**n_qubits) init_state /= np.sqrt(np.dot(np.conj(init_state), init_state)) + init_state = np.array(init_state, requires_grad=False) if operation.num_wires > n_qubits: return