Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set PL_BACKEND in L-GPU docker build and misc improvements #791

Merged
merged 4 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@

### Improvements

* Enable setting the PennyLane version when invoking, for example, `make docker-build version=master pl_version=master`.
[(#791)](https://github.com/PennyLaneAI/pennylane-lightning/pull/791)

* Add a Catalyst-specific wrapping class for Lightning Kokkos.
[(#770)](https://github.com/PennyLaneAI/pennylane-lightning/pull/770)

### Documentation

### Bug fixes

* Set `PL_BACKEND` for the entire `build-wheel-lightning-gpu` Docker-build stage to properly build the Lightning-GPU wheel.
[(#791)](https://github.com/PennyLaneAI/pennylane-lightning/pull/791)

* Fix conditions for skipping build & push steps in the Docker build workflows.
[(#790)](https://github.com/PennyLaneAI/pennylane-lightning/pull/790)

Expand Down
29 changes: 17 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -150,28 +150,33 @@ endif
ifdef version
VERSION := $(version)
else
VERSION := v0.36.0
VERSION := master
endif
ifdef pl_version
PL_VERSION := $(pl_version)
else
PL_VERSION := master
endif

docker-build:
docker build -f docker/Dockerfile \
--tag=pennylaneai/pennylane:$(VERSION)-$(TARGET) \
--target wheel-$(TARGET) \
--build-arg='LIGHTNING_VERSION=$(VERSION)' .
--build-arg='LIGHTNING_VERSION=$(VERSION)' --build-arg='PENNYLANE_VERSION=$(PL_VERSION)' .
docker-push:
docker push pennylaneai/pennylane:$(VERSION)-$(TARGET)
docker-build-all:
$(MAKE) docker-build target=lightning-qubit
$(MAKE) docker-build target=lightning-gpu
$(MAKE) docker-build target=lightning-kokkos-openmp
$(MAKE) docker-build target=lightning-kokkos-cuda
$(MAKE) docker-build target=lightning-kokkos-rocm
$(MAKE) docker-build target=lightning-qubit pl_version=$(PL_VERSION) version=$(VERSION)
$(MAKE) docker-build target=lightning-gpu pl_version=$(PL_VERSION) version=$(VERSION)
$(MAKE) docker-build target=lightning-kokkos-openmp pl_version=$(PL_VERSION) version=$(VERSION)
$(MAKE) docker-build target=lightning-kokkos-cuda pl_version=$(PL_VERSION) version=$(VERSION)
$(MAKE) docker-build target=lightning-kokkos-rocm pl_version=$(PL_VERSION) version=$(VERSION)
docker-push-all:
$(MAKE) docker-push target=lightning-qubit
$(MAKE) docker-push target=lightning-gpu
$(MAKE) docker-push target=lightning-kokkos-openmp
$(MAKE) docker-push target=lightning-kokkos-cuda
$(MAKE) docker-push target=lightning-kokkos-rocm
$(MAKE) docker-push target=lightning-qubit pl_version=$(PL_VERSION) version=$(VERSION)
$(MAKE) docker-push target=lightning-gpu pl_version=$(PL_VERSION) version=$(VERSION)
$(MAKE) docker-push target=lightning-kokkos-openmp pl_version=$(PL_VERSION) version=$(VERSION)
$(MAKE) docker-push target=lightning-kokkos-cuda pl_version=$(PL_VERSION) version=$(VERSION)
$(MAKE) docker-push target=lightning-kokkos-rocm pl_version=$(PL_VERSION) version=$(VERSION)
docker-all:
$(MAKE) docker-build-all
$(MAKE) docker-push-all
21 changes: 12 additions & 9 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Define global build defaults
ARG PENNYLANE_VERSION=master

# Create basic runtime environment base on Ubuntu 22.04 (jammy)
# Define build arguments
# Create and activate runtime virtual environment
FROM ubuntu:jammy AS base-runtime
ARG CUDA_ARCH=AMPERE80
ARG AMD_ARCH=AMD_GFX90A
ARG CUDA_ARCH=AMPERE80
ARG CUDA_INSTALLER=https://developer.download.nvidia.com/compute/cuda/12.2.2/local_installers/cuda_12.2.2_535.104.05_linux.run
ARG DEBIAN_FRONTEND=noninteractive
ARG GCC_VERSION=11
ARG LIGHTNING_VERSION=v0.36.0
ARG PENNYLANE_VERSION=v0.36.0
ARG LIGHTNING_VERSION=master
ARG PENNYLANE_VERSION
ARG ROCM_INSTALLER=https://repo.radeon.com/amdgpu-install/5.7/ubuntu/jammy/amdgpu-install_5.7.50700-1_all.deb
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
Expand Down Expand Up @@ -122,7 +124,7 @@ RUN python setup.py bdist_wheel
# Install python3 and setup runtime virtual env in CUDA-12-runtime image (includes CUDA runtime and math libraries)
# Install lightning-kokkos CUDA backend
FROM nvidia/cuda:12.2.0-base-ubuntu22.04 AS wheel-lightning-kokkos-cuda
ARG PENNYLANE_VERSION=v0.36.0
ARG PENNYLANE_VERSION
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
libgomp1 \
Expand All @@ -143,15 +145,16 @@ RUN pip install --no-cache-dir git+https://github.com/PennyLaneAI/pennylane.git@
# Download and build Lightning-GPU release
FROM base-build-cuda AS build-wheel-lightning-gpu
WORKDIR /opt/pennylane-lightning
ENV PL_BACKEND=lightning_gpu
RUN pip install --no-cache-dir wheel custatevec-cu12
RUN pip uninstall -y pennylane-lightning
RUN CUQUANTUM_SDK=$(python -c "import site; print( f'{site.getsitepackages()[0]}/cuquantum/lib')") PL_BACKEND=lightning_gpu python setup.py build_ext
RUN CUQUANTUM_SDK=$(python -c "import site; print( f'{site.getsitepackages()[0]}/cuquantum/lib')") python setup.py build_ext
vincentmr marked this conversation as resolved.
Show resolved Hide resolved
RUN python setup.py bdist_wheel

# Install python3 and setup runtime virtual env in CUDA-12-runtime image (includes CUDA runtime and math libraries)
# Install lightning-kokkos CUDA backend
FROM nvidia/cuda:12.2.0-runtime-ubuntu22.04 AS wheel-lightning-gpu
ARG PENNYLANE_VERSION=v0.36.0
ARG PENNYLANE_VERSION
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
git \
Expand Down Expand Up @@ -189,12 +192,12 @@ ENV CMAKE_PREFIX_PATH=/opt/rocm:$CMAKE_PREFIX_PATH
ENV CXX=hipcc
ENV PL_BACKEND=lightning_kokkos
RUN pip uninstall -y pennylane-lightning
RUN python setup.py build_ext -i --define="PL_BACKEND=lightning_kokkos;Kokkos_ENABLE_SERIAL:BOOL=ON;Kokkos_ENABLE_OPENMP:BOOL=ON;Kokkos_ENABLE_HIP:BOOL=ON;Kokkos_ARCH_${AMD_ARCH}=ON"
RUN python setup.py build_ext -i --define="Kokkos_ENABLE_SERIAL:BOOL=ON;Kokkos_ENABLE_OPENMP:BOOL=ON;Kokkos_ENABLE_HIP:BOOL=ON;Kokkos_ARCH_${AMD_ARCH}=ON"
RUN python setup.py bdist_wheel

# Install lightning-kokkos HIP backend
FROM rocm/dev-ubuntu-22.04:5.7 AS wheel-lightning-kokkos-rocm
ARG PENNYLANE_VERSION=v0.36.0
ARG PENNYLANE_VERSION
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
git \
Expand Down
2 changes: 1 addition & 1 deletion pennylane_lightning/core/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
Version number (major.minor.patch[-label])
"""

__version__ = "0.38.0-dev4"
__version__ = "0.38.0-dev5"
Loading