From d8461f3883047e1777f307ba42c4ba3e47d81b89 Mon Sep 17 00:00:00 2001 From: Joseph Lee <40768758+josephleekl@users.noreply.github.com> Date: Thu, 2 Jan 2025 20:52:53 -0500 Subject: [PATCH] Add Python CUDA dependencies as Lightning-GPU and Lightning-Tensor wheel dependencies (#1025) ### Before submitting Please complete the following checklist when submitting a PR: - [ ] All new features must include a unit test. If you've fixed a bug or added code that should be tested, add a test to the [`tests`](../tests) directory! - [ ] All new functions and code must be clearly commented and documented. If you do make documentation changes, make sure that the docs build and render correctly by running `make docs`. - [ ] Ensure that the test suite passes, by running `make test`. - [X] Add a new entry to the `.github/CHANGELOG.md` file, summarizing the change, and including a link back to the PR. - [ ] Ensure that code is properly formatted by running `make format`. When all the above are checked, delete everything above the dashed line and fill in the pull request template. ------------------------------------------------------------------------------------------------------------ **Context:** **Description of the Change:** Added all [Python CUDA dependencies](https://github.com/PennyLaneAI/pennylane-lightning/blob/954a6e7d12befc043597769c6357a1003e8d588b/bin/auditwheel) to `pyproject.toml` for LGPU and LT. `INSTALL_RPATH` updated in CMake files. **Benefits:** **Possible Drawbacks:** **Related GitHub Issues:** [sc-79647] --------- Co-authored-by: ringo-but-quantum Co-authored-by: Shuli Shu <08cnbj@gmail.com> --- .github/CHANGELOG.md | 7 +++++-- .github/workflows/tests_lgpumpi_cpp.yml | 2 +- pennylane_lightning/core/_version.py | 2 +- .../src/simulators/lightning_gpu/CMakeLists.txt | 4 ++-- .../lightning_tensor/tncuda/CMakeLists.txt | 2 +- requirements-dev.txt | 4 ++-- scripts/configure_pyproject_toml.py | 14 ++++++++++++++ 7 files changed, 26 insertions(+), 9 deletions(-) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index fb008b06a2..8d01e6b682 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -29,8 +29,8 @@ ### Improvements -* Optimize lightning.tensor by adding direct MPS sites data set with `qml.MPSPrep`. - [(#983)](https://github.com/PennyLaneAI/pennylane-lightning/pull/983) +* Add CUDA dependencies to Lightning GPU and Lightning Tensor Python wheels. + [(#1025)](https://github.com/PennyLaneAI/pennylane-lightning/pull/1025/) * Replace the `dummy_tensor_update` method with the `cutensornetStateCaptureMPS`API to ensure that further gates apply is allowed after the `cutensornetStateCompute` call. [(#1028)](https://github.com/PennyLaneAI/pennylane-lightning/pull/1028/) @@ -85,6 +85,9 @@ * The TOML files for the devices are updated to use the new schema for declaring device capabilities. [(#988)](https://github.com/PennyLaneAI/pennylane-lightning/pull/988) +* Optimize lightning.tensor by adding direct MPS sites data set with `qml.MPSPrep`. + [(#983)](https://github.com/PennyLaneAI/pennylane-lightning/pull/983) + * Unify excitation gates memory layout to row-major for both LGPU and LT. [(#959)](https://github.com/PennyLaneAI/pennylane-lightning/pull/959) diff --git a/.github/workflows/tests_lgpumpi_cpp.yml b/.github/workflows/tests_lgpumpi_cpp.yml index fdd17b0fbe..1dfcd85b9e 100644 --- a/.github/workflows/tests_lgpumpi_cpp.yml +++ b/.github/workflows/tests_lgpumpi_cpp.yml @@ -51,7 +51,7 @@ jobs: mpilib: ["mpich", "openmpi"] cuda_version_maj: ["12"] cuda_version_min: ["2"] - timeout-minutes: 30 + timeout-minutes: 35 steps: - name: Checkout diff --git a/pennylane_lightning/core/_version.py b/pennylane_lightning/core/_version.py index 30f24595a9..df42670b02 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.40.0-dev42" +__version__ = "0.40.0-dev43" diff --git a/pennylane_lightning/core/src/simulators/lightning_gpu/CMakeLists.txt b/pennylane_lightning/core/src/simulators/lightning_gpu/CMakeLists.txt index f2fa032454..47446032db 100644 --- a/pennylane_lightning/core/src/simulators/lightning_gpu/CMakeLists.txt +++ b/pennylane_lightning/core/src/simulators/lightning_gpu/CMakeLists.txt @@ -63,7 +63,7 @@ set_property(TARGET ${PL_BACKEND} PROPERTY POSITION_INDEPENDENT_CODE ON) # To avoid DSO errors on platforms preferring static linkage, uncomment the following line: # string(REPLACE "libcudart_static.a" "libcudart.so" CUDA_SHARED_RT "${CUDA_LIBRARIES}") -set_target_properties(${PL_BACKEND} PROPERTIES INSTALL_RPATH "$ORIGIN/../cuquantum/lib:$ORIGIN/../cuquantum/lib64:$ORIGIN/") +set_target_properties(${PL_BACKEND} PROPERTIES INSTALL_RPATH "$ORIGIN/../cuquantum/lib:$ORIGIN/../cuquantum/lib64:$ORIGIN/../nvidia/cublas/lib:$ORIGIN/../nvidia/cusparse/lib:$ORIGIN/../nvidia/nvjitlink/lib:$ORIGIN/../nvidia/cuda_runtime/lib:$ORIGIN/") if(PL_DISABLE_CUDA_SAFETY) target_compile_options(${PL_BACKEND} INTERFACE $<$:-DCUDA_UNSAFE>) @@ -87,4 +87,4 @@ endforeach() if (BUILD_TESTS) enable_testing() add_subdirectory("tests") -endif() \ No newline at end of file +endif() diff --git a/pennylane_lightning/core/src/simulators/lightning_tensor/tncuda/CMakeLists.txt b/pennylane_lightning/core/src/simulators/lightning_tensor/tncuda/CMakeLists.txt index 72d396319f..48f53da4b6 100644 --- a/pennylane_lightning/core/src/simulators/lightning_tensor/tncuda/CMakeLists.txt +++ b/pennylane_lightning/core/src/simulators/lightning_tensor/tncuda/CMakeLists.txt @@ -51,7 +51,7 @@ set_property(TARGET ${PL_BACKEND} PROPERTY POSITION_INDEPENDENT_CODE ON) # To avoid DSO errors on platforms preferring static linkage, uncomment the following line: # string(REPLACE "libcudart_static.a" "libcudart.so" CUDA_SHARED_RT "${CUDA_LIBRARIES}") -set_target_properties(${PL_BACKEND} PROPERTIES INSTALL_RPATH "$ORIGIN/../cuquantum/lib:$ORIGIN/../cuquantum/lib64:$ORIGIN/") +set_target_properties(${PL_BACKEND} PROPERTIES INSTALL_RPATH "$ORIGIN/../cuquantum/lib:$ORIGIN/../cuquantum/lib64:$ORIGIN/../nvidia/cublas/lib:$ORIGIN/../nvidia/cusparse/lib:$ORIGIN/../cutensor/lib:$ORIGIN/../nvidia/nvjitlink/lib:$ORIGIN/../nvidia/cusolver/lib:$ORIGIN/../nvidia/cuda_runtime/lib:$ORIGIN/") if(PL_DISABLE_CUDA_SAFETY) target_compile_options(${PL_BACKEND} INTERFACE $<$:-DCUDA_UNSAFE>) diff --git a/requirements-dev.txt b/requirements-dev.txt index 138510b32c..536b6f96be 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -16,8 +16,8 @@ isort==5.13.2 click==8.0.4 cmake jax[cpu]==0.4.28 -custatevec-cu12 -cutensornet-cu12 +custatevec-cu12; sys_platform == "linux" +cutensornet-cu12; sys_platform == "linux" pylint==2.7.4 scipy-openblas32>=0.3.26 git+https://github.com/PennyLaneAI/pennylane.git@master diff --git a/scripts/configure_pyproject_toml.py b/scripts/configure_pyproject_toml.py index 2a009863b3..bad11976d1 100755 --- a/scripts/configure_pyproject_toml.py +++ b/scripts/configure_pyproject_toml.py @@ -122,6 +122,20 @@ def parse_args(): "scipy-openblas32>=0.3.26", ] + if backend == "lightning_gpu": + dependencies += ["custatevec-cu12"] + + if backend == "lightning_tensor": + dependencies += ["cutensornet-cu12", "nvidia-cusolver-cu12"] + + if backend in ("lightning_gpu", "lightning_tensor"): + dependencies += [ + "nvidia-nvjitlink-cu12", + "nvidia-cusparse-cu12", + "nvidia-cublas-cu12", + "nvidia-cuda-runtime-cu12", + ] + if backend != "lightning_qubit": dependencies += ["pennylane_lightning==" + version]