Skip to content

Commit c979154

Browse files
Merge branch 'pytorch:main' into temp-ppc64le-wheel-branch-v8
2 parents bd9dc2f + ce52674 commit c979154

File tree

216 files changed

+3231
-4267
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

216 files changed

+3231
-4267
lines changed

.ci/docker/build.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ docker build \
515515
UBUNTU_VERSION=$(echo ${UBUNTU_VERSION} | sed 's/-rc$//')
516516

517517
function drun() {
518-
docker run --rm "$tmp_tag" $*
518+
docker run --rm "$tmp_tag" "$@"
519519
}
520520

521521
if [[ "$OS" == "ubuntu" ]]; then
@@ -563,3 +563,14 @@ if [ -n "$KATEX" ]; then
563563
exit 1
564564
fi
565565
fi
566+
567+
HAS_TRITON=$(drun python -c "import triton" > /dev/null 2>&1 && echo "yes" || echo "no")
568+
if [[ -n "$TRITON" || -n "$TRITON_CPU" ]]; then
569+
if [ "$HAS_TRITON" = "no" ]; then
570+
echo "expecting triton to be installed, but it is not"
571+
exit 1
572+
fi
573+
elif [ "$HAS_TRITON" = "yes" ]; then
574+
echo "expecting triton to not be installed, but it is"
575+
exit 1
576+
fi

.ci/docker/centos-rocm/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ COPY ./common/install_rocm.sh install_rocm.sh
6868
RUN bash ./install_rocm.sh
6969
RUN rm install_rocm.sh
7070
COPY ./common/install_rocm_magma.sh install_rocm_magma.sh
71-
RUN bash ./install_rocm_magma.sh
71+
RUN bash ./install_rocm_magma.sh ${ROCM_VERSION}
7272
RUN rm install_rocm_magma.sh
7373
COPY ./common/install_amdsmi.sh install_amdsmi.sh
7474
RUN bash ./install_amdsmi.sh
Lines changed: 23 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,28 @@
1-
#!/bin/bash
2-
# Script used in CI and CD pipeline
1+
#!/usr/bin/env bash
2+
# Script used only in CD pipeline
33

4-
set -ex
4+
set -eou pipefail
55

6-
# Magma build scripts need `python`
7-
ln -sf /usr/bin/python3 /usr/bin/python
6+
function do_install() {
7+
rocm_version=$1
8+
rocm_version_nodot=${1//./}
89

9-
ID=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"')
10-
case "$ID" in
11-
almalinux)
12-
yum install -y gcc-gfortran
13-
;;
14-
*)
15-
echo "No preinstalls to build magma..."
16-
;;
17-
esac
10+
# Version 2.7.2 + ROCm related updates
11+
MAGMA_VERSION=a1625ff4d9bc362906bd01f805dbbe12612953f6
12+
magma_archive="magma-rocm${rocm_version_nodot}-${MAGMA_VERSION}-1.tar.bz2"
1813

19-
MKLROOT=${MKLROOT:-/opt/conda/envs/py_$ANACONDA_PYTHON_VERSION}
14+
rocm_dir="/opt/rocm"
15+
(
16+
set -x
17+
tmp_dir=$(mktemp -d)
18+
pushd ${tmp_dir}
19+
curl -OLs https://ossci-linux.s3.us-east-1.amazonaws.com/${magma_archive}
20+
tar -xvf "${magma_archive}"
21+
mkdir -p "${rocm_dir}/magma"
22+
mv include "${rocm_dir}/magma/include"
23+
mv lib "${rocm_dir}/magma/lib"
24+
popd
25+
)
26+
}
2027

21-
# "install" hipMAGMA into /opt/rocm/magma by copying after build
22-
git clone https://bitbucket.org/icl/magma.git
23-
pushd magma
24-
25-
# Version 2.7.2 + ROCm related updates
26-
git checkout a1625ff4d9bc362906bd01f805dbbe12612953f6
27-
28-
cp make.inc-examples/make.inc.hip-gcc-mkl make.inc
29-
echo 'LIBDIR += -L$(MKLROOT)/lib' >> make.inc
30-
if [[ -f "${MKLROOT}/lib/libmkl_core.a" ]]; then
31-
echo 'LIB = -Wl,--start-group -lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -Wl,--end-group -lpthread -lstdc++ -lm -lgomp -lhipblas -lhipsparse' >> make.inc
32-
fi
33-
echo 'LIB += -Wl,--enable-new-dtags -Wl,--rpath,/opt/rocm/lib -Wl,--rpath,$(MKLROOT)/lib -Wl,--rpath,/opt/rocm/magma/lib -ldl' >> make.inc
34-
echo 'DEVCCFLAGS += --gpu-max-threads-per-block=256' >> make.inc
35-
export PATH="${PATH}:/opt/rocm/bin"
36-
if [[ -n "$PYTORCH_ROCM_ARCH" ]]; then
37-
amdgpu_targets=`echo $PYTORCH_ROCM_ARCH | sed 's/;/ /g'`
38-
else
39-
amdgpu_targets=`rocm_agent_enumerator | grep -v gfx000 | sort -u | xargs`
40-
fi
41-
for arch in $amdgpu_targets; do
42-
echo "DEVCCFLAGS += --offload-arch=$arch" >> make.inc
43-
done
44-
# hipcc with openmp flag may cause isnan() on __device__ not to be found; depending on context, compiler may attempt to match with host definition
45-
sed -i 's/^FOPENMP/#FOPENMP/g' make.inc
46-
make -f make.gen.hipMAGMA -j $(nproc)
47-
LANG=C.UTF-8 make lib/libmagma.so -j $(nproc) MKLROOT="${MKLROOT}"
48-
make testing/testing_dgemm -j $(nproc) MKLROOT="${MKLROOT}"
49-
popd
50-
mv magma /opt/rocm
28+
do_install $1

.ci/docker/common/install_triton.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
set -ex
44

5+
mkdir -p /opt/triton
6+
if [ -z "${TRITON}" ] && [ -z "${TRITON_CPU}" ]; then
7+
echo "TRITON and TRITON_CPU are not set. Exiting..."
8+
exit 0
9+
fi
10+
511
source "$(dirname "${BASH_SOURCE[0]}")/common_utils.sh"
612

713
get_conda_version() {
@@ -52,6 +58,7 @@ cd triton
5258
as_jenkins git checkout ${TRITON_PINNED_COMMIT}
5359
as_jenkins git submodule update --init --recursive
5460
cd python
61+
pip_install pybind11==2.13.6
5562

5663
# TODO: remove patch setup.py once we have a proper fix for https://github.com/triton-lang/triton/issues/4527
5764
as_jenkins sed -i -e 's/https:\/\/tritonlang.blob.core.windows.net\/llvm-builds/https:\/\/oaitriton.blob.core.windows.net\/public\/llvm-builds/g' setup.py
@@ -60,17 +67,22 @@ if [ -n "${UBUNTU_VERSION}" ] && [ -n "${GCC_VERSION}" ] && [[ "${GCC_VERSION}"
6067
# Triton needs at least gcc-9 to build
6168
apt-get install -y g++-9
6269

63-
CXX=g++-9 pip_install .
70+
CXX=g++-9 conda_run python setup.py bdist_wheel
6471
elif [ -n "${UBUNTU_VERSION}" ] && [ -n "${CLANG_VERSION}" ]; then
6572
# Triton needs <filesystem> which surprisingly is not available with clang-9 toolchain
6673
add-apt-repository -y ppa:ubuntu-toolchain-r/test
6774
apt-get install -y g++-9
6875

69-
CXX=g++-9 pip_install .
76+
CXX=g++-9 conda_run python setup.py bdist_wheel
7077
else
71-
pip_install .
78+
conda_run python setup.py bdist_wheel
7279
fi
7380

81+
# Copy the wheel to /opt for multi stage docker builds
82+
cp dist/*.whl /opt/triton
83+
# Install the wheel for docker builds that don't use multi stage
84+
pip_install dist/*.whl
85+
7486
if [ -n "${CONDA_CMAKE}" ]; then
7587
# TODO: This is to make sure that the same cmake and numpy version from install conda
7688
# script is used. Without this step, the newer cmake version (3.25.2) downloaded by

.ci/docker/libtorch/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ RUN bash ./install_magma.sh 12.8
7272
RUN ln -sf /usr/local/cuda-12.8 /usr/local/cuda
7373

7474
FROM cpu as rocm
75+
ARG ROCM_VERSION
7576
ARG PYTORCH_ROCM_ARCH
7677
ENV PYTORCH_ROCM_ARCH ${PYTORCH_ROCM_ARCH}
7778
ENV MKLROOT /opt/intel
@@ -90,7 +91,7 @@ RUN apt-get update -y && \
9091
apt-get clean
9192

9293
RUN bash ./install_rocm_drm.sh && rm install_rocm_drm.sh
93-
RUN bash ./install_rocm_magma.sh && rm install_rocm_magma.sh
94+
RUN bash ./install_rocm_magma.sh ${ROCM_VERSION} && rm install_rocm_magma.sh
9495

9596
FROM ${BASE_TARGET} as final
9697
COPY --from=openssl /opt/openssl /opt/openssl

.ci/docker/libtorch/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ case ${GPU_ARCH_TYPE} in
4040
DOCKER_TAG=rocm${GPU_ARCH_VERSION}
4141
GPU_IMAGE=rocm/dev-ubuntu-20.04:${GPU_ARCH_VERSION}-complete
4242
PYTORCH_ROCM_ARCH="gfx900;gfx906;gfx908;gfx90a;gfx942;gfx1030;gfx1100;gfx1101;gfx1102;gfx1200;gfx1201"
43-
DOCKER_GPU_BUILD_ARG="--build-arg PYTORCH_ROCM_ARCH=${PYTORCH_ROCM_ARCH}"
43+
DOCKER_GPU_BUILD_ARG="--build-arg PYTORCH_ROCM_ARCH=${PYTORCH_ROCM_ARCH} --build-arg ROCM_VERSION=${GPU_ARCH_VERSION}"
4444
;;
4545
*)
4646
echo "ERROR: Unrecognized GPU_ARCH_TYPE: ${GPU_ARCH_TYPE}"

.ci/docker/manywheel/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,6 @@ RUN bash ./install_rocm_drm.sh && rm install_rocm_drm.sh
195195
# cmake3 is needed for the MIOpen build
196196
RUN ln -sf /usr/local/bin/cmake /usr/bin/cmake3
197197
ADD ./common/install_rocm_magma.sh install_rocm_magma.sh
198-
RUN bash ./install_rocm_magma.sh && rm install_rocm_magma.sh
198+
RUN bash ./install_rocm_magma.sh ${ROCM_VERSION} && rm install_rocm_magma.sh
199199
ADD ./common/install_miopen.sh install_miopen.sh
200200
RUN bash ./install_miopen.sh ${ROCM_VERSION} && rm install_miopen.sh

.ci/docker/manywheel/Dockerfile_2_28

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ ADD ./common/install_rocm_drm.sh install_rocm_drm.sh
158158
RUN bash ./install_rocm_drm.sh && rm install_rocm_drm.sh
159159
ENV MKLROOT /opt/intel
160160
ADD ./common/install_rocm_magma.sh install_rocm_magma.sh
161-
RUN bash ./install_rocm_magma.sh && rm install_rocm_magma.sh
161+
RUN bash ./install_rocm_magma.sh ${ROCM_VERSION} && rm install_rocm_magma.sh
162162
ADD ./common/install_miopen.sh install_miopen.sh
163163
RUN bash ./install_miopen.sh ${ROCM_VERSION} && rm install_miopen.sh
164164

.ci/docker/ubuntu-cuda/Dockerfile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ ARG UBUNTU_VERSION
22
ARG CUDA_VERSION
33
ARG IMAGE_NAME
44

5-
FROM ${IMAGE_NAME}
5+
FROM ${IMAGE_NAME} as base
66

77
ARG UBUNTU_VERSION
88
ARG CUDA_VERSION
@@ -90,14 +90,20 @@ RUN if [ -n "${CMAKE_VERSION}" ]; then bash ./install_cmake.sh; fi
9090
RUN rm install_cmake.sh
9191

9292
ARG TRITON
93+
94+
FROM base as triton-builder
9395
# Install triton, this needs to be done before sccache because the latter will
9496
# try to reach out to S3, which docker build runners don't have access
9597
COPY ./common/install_triton.sh install_triton.sh
9698
COPY ./common/common_utils.sh common_utils.sh
9799
COPY ci_commit_pins/triton.txt triton.txt
98100
COPY triton_version.txt triton_version.txt
99-
RUN if [ -n "${TRITON}" ]; then bash ./install_triton.sh; fi
100-
RUN rm install_triton.sh common_utils.sh triton.txt triton_version.txt
101+
RUN bash ./install_triton.sh
102+
103+
FROM base as final
104+
COPY --from=triton-builder /opt/triton /opt/triton
105+
RUN if [ -n "${TRITON}" ]; then pip install /opt/triton/*.whl; chown -R jenkins:jenkins /opt/conda; fi
106+
RUN rm -rf /opt/triton
101107

102108
ARG HALIDE
103109
# Build and install halide

.ci/docker/ubuntu-rocm/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ COPY ./common/install_rocm.sh install_rocm.sh
6363
RUN bash ./install_rocm.sh
6464
RUN rm install_rocm.sh
6565
COPY ./common/install_rocm_magma.sh install_rocm_magma.sh
66-
RUN bash ./install_rocm_magma.sh
66+
RUN bash ./install_rocm_magma.sh ${ROCM_VERSION}
6767
RUN rm install_rocm_magma.sh
6868
ADD ./common/install_miopen.sh install_miopen.sh
6969
RUN bash ./install_miopen.sh ${ROCM_VERSION} && rm install_miopen.sh

0 commit comments

Comments
 (0)