From f26b90c3ede84a860485a02f484df4bb16518caf Mon Sep 17 00:00:00 2001 From: "Nguyen Vuong (from Dev Box)" Date: Wed, 23 Sep 2026 16:48:28 -0700 Subject: [PATCH 1/7] Dockerfile - Add ROCm7.2 dockerfile Refresh #814 on top of main, reusing the fixes absorbed in the ROCm 6.4 image (#837): AMDGPU_TARGETS routing (default gfx942 gfx950), DOCA-OFED user-space, client-only Docker 29.6.2, flex, CMake version check, OpenMPI clone cleanup and .git removal. hipblaslt-bench is built for the requested targets via a standalone CMake script against the system hipBLASLt, TransformerEngine is pinned to v2.10_rocm, and hipBusBandwidth gets a include for the ROCm 7 clang. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/build-image.yml | 6 + .../etc/hipblaslt-bench-standalone.cmake | 130 +++++++++ dockerfile/rocm7.2.x.dockerfile | 276 ++++++++++++++++++ tests/test_rocm72_dockerfile.py | 106 +++++++ third_party/Makefile | 4 +- 5 files changed, 521 insertions(+), 1 deletion(-) create mode 100644 dockerfile/etc/hipblaslt-bench-standalone.cmake create mode 100644 dockerfile/rocm7.2.x.dockerfile create mode 100644 tests/test_rocm72_dockerfile.py diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index b52e04a4f..40cbb2e7e 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -70,6 +70,12 @@ jobs: platforms: linux/amd64 runner: [self-hosted, linux/amd64, rocm] build_args: "NUM_MAKE_JOBS=2" + - name: rocm7.2 + dockerfile: rocm7.2.x + tags: superbench/main:rocm7.2 + platforms: linux/amd64 + runner: [self-hosted, linux/amd64, rocm] + build_args: "NUM_MAKE_JOBS=8" steps: - name: Checkout uses: actions/checkout@v2 diff --git a/dockerfile/etc/hipblaslt-bench-standalone.cmake b/dockerfile/etc/hipblaslt-bench-standalone.cmake new file mode 100644 index 000000000..67f3ad986 --- /dev/null +++ b/dockerfile/etc/hipblaslt-bench-standalone.cmake @@ -0,0 +1,130 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +# Standalone CMake for building hipblaslt-bench against system-installed +# hipBLASLt, bypassing the upstream build system. +# +# Used by dockerfile/rocm7.2.x.dockerfile because the upstream 7.2 source +# tree pulls in AMD-internal "origami" headers and a new tensilelite-host +# C++ library that conflict with the goal of building only the bench tool. +# +# Place this file at the root of an upstream hipBLASLt source tree as the +# top-level CMakeLists.txt and configure it as a normal CMake project, e.g.: +# +# cp /path/to/this/file /path/to/hipBLASLt/CMakeLists.txt +# cmake -S /path/to/hipBLASLt -B /path/to/hipBLASLt/build -DCMAKE_HIP_ARCHITECTURES="gfx942;gfx950" +# cmake --build /path/to/hipBLASLt/build --target hipblaslt-bench + +cmake_minimum_required(VERSION 3.21) +project(hipblaslt-bench-standalone LANGUAGES CXX HIP) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_HIP_STANDARD 17) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +if(NOT DEFINED ROCM_PATH) + if(DEFINED ENV{ROCM_PATH}) + set(ROCM_PATH "$ENV{ROCM_PATH}") + else() + set(ROCM_PATH "/opt/rocm") + endif() +endif() + +# The directory containing this build script is the hipBLASLt source root. +set(HIPBLASLT_SRC "${CMAKE_CURRENT_SOURCE_DIR}") + +# --- Dependencies (all from system / preinstalled) --- +find_package(hip REQUIRED) +find_package(hipblaslt CONFIG REQUIRED) +find_package(LAPACK REQUIRED) # also brings BLAS via implicit find_package(BLAS) +find_package(OpenMP REQUIRED) +find_package(rocm_smi) # optional + +# Locate cblas explicitly (not part of LAPACK's standard targets). +# cblas_interface.cpp uses cblas_sgemm/dgemm so we need the C BLAS library. +find_library(CBLAS_LIBRARY NAMES cblas PATHS /usr/local/lib /usr/lib REQUIRED) +message(STATUS "Found CBLAS: ${CBLAS_LIBRARY}") + +# --- The bench static helper library --- +# Mirrors the source list of upstream clients/common/src/CMakeLists.txt with +# rocRoller (mxDataGen.cpp) and BLIS (blis_interface.cpp) disabled. +set(HIPBLASLT_CLIENTS_COMMON_SOURCES + "${HIPBLASLT_SRC}/clients/common/src/singletons.cpp" + "${HIPBLASLT_SRC}/clients/common/src/utility.cpp" + "${HIPBLASLT_SRC}/clients/common/src/efficiency_monitor.cpp" + "${HIPBLASLT_SRC}/clients/common/src/cblas_interface.cpp" + "${HIPBLASLT_SRC}/clients/common/src/argument_model.cpp" + "${HIPBLASLT_SRC}/clients/common/src/hipblaslt_parse_data.cpp" + "${HIPBLASLT_SRC}/clients/common/src/hipblaslt_arguments.cpp" + "${HIPBLASLT_SRC}/clients/common/src/hipblaslt_random.cpp" + "${HIPBLASLT_SRC}/clients/common/src/hipblaslt_init_device.cpp" +) +add_library(hipblaslt-clients-common STATIC ${HIPBLASLT_CLIENTS_COMMON_SOURCES}) + +# These .cpp files are HIP code (use __device__/__host__, hip_runtime APIs, +# half/bfloat16 types). Compiling them as plain CXX with gcc fails. Force HIP. +set_source_files_properties(${HIPBLASLT_CLIENTS_COMMON_SOURCES} PROPERTIES LANGUAGE HIP) + +target_include_directories(hipblaslt-clients-common + PUBLIC + "${HIPBLASLT_SRC}/clients/common/include" + "${HIPBLASLT_SRC}/clients/bench/include" + # Source's library/include comes BEFORE system include so we get + # hipblaslt_xfloat32.h (not shipped in the system install). + "${HIPBLASLT_SRC}/library/include" + # Internal headers used by clients (rocblaslt/rocblaslt-types.h etc.) + "${HIPBLASLT_SRC}/library/src/amd_detail/include" + "${HIPBLASLT_SRC}/library/src/amd_detail/rocblaslt/include" + "${HIPBLASLT_SRC}/library/src/amd_detail/rocblaslt/src/include" + # tensilelite headers used by clients (e.g. client/include/Utility.hpp). + "${HIPBLASLT_SRC}/tensilelite/include" + "${HIPBLASLT_SRC}/tensilelite" +) + +target_compile_definitions(hipblaslt-clients-common + PUBLIC + # Critical: in 7.2 the upstream build sets ROCM_USE_FLOAT16 only + # via the in-tree hipblaslt target's INTERFACE_COMPILE_DEFINITIONS. + # The system find_package(hipblaslt) does not propagate it. Without + # this, hipblasLtHalf is the struct version with no operator float, + # which breaks hipblaslt_ostream.hpp. + ROCM_USE_FLOAT16 + __HIP_PLATFORM_AMD__ + HIPBLASLT_BENCH + HIPBLASLT_INTERNAL_API +) + +target_link_libraries(hipblaslt-clients-common + PUBLIC + hip::host + hip::device + # Order matters: cblas -> lapack -> blas -> gfortran (lapack needs blas + # which needs Fortran runtime). + ${CBLAS_LIBRARY} + ${LAPACK_LIBRARIES} + ${BLAS_LIBRARIES} + gfortran + OpenMP::OpenMP_CXX +) + +if(rocm_smi_FOUND) + target_link_libraries(hipblaslt-clients-common PRIVATE rocm_smi64) +endif() + +# Link against the system hipblaslt .so directly via library name to avoid +# inheriting INTERFACE_COMPILE_DEFINITIONS (HIPBLASLT_USE_ROCROLLER) from +# the imported roc::hipblaslt target. We only need linkage, not propagated +# defines. +target_link_directories(hipblaslt-clients-common PUBLIC "${ROCM_PATH}/lib") +target_link_libraries(hipblaslt-clients-common PUBLIC hipblaslt) + +# --- The bench executable --- +add_executable(hipblaslt-bench + "${HIPBLASLT_SRC}/clients/bench/src/client.cpp" +) +set_source_files_properties( + "${HIPBLASLT_SRC}/clients/bench/src/client.cpp" + PROPERTIES LANGUAGE HIP +) +target_link_libraries(hipblaslt-bench PRIVATE hipblaslt-clients-common) diff --git a/dockerfile/rocm7.2.x.dockerfile b/dockerfile/rocm7.2.x.dockerfile new file mode 100644 index 000000000..664ef403f --- /dev/null +++ b/dockerfile/rocm7.2.x.dockerfile @@ -0,0 +1,276 @@ +ARG BASE_IMAGE=rocm/pytorch:rocm7.2.4_ubuntu24.04_py3.12_pytorch_release_2.9.1 + +FROM ${BASE_IMAGE} + +# OS: +# - Ubuntu: 24.04 +# - Docker Client: 29.6.2 (client only) +# ROCm: +# - ROCm: 7.2 +# Lib: +# - torch: 2.9.1 +# - rccl: release/rocm-rel-7.2 +# - hipblaslt: release/rocm-rel-7.2 (hipblaslt-bench only, against system hipBLASLt) +# - rocblas: release/rocm-rel-7.2 +# - transformer_engine: v2.10_rocm +# - openmpi: 4.1.x +# Intel: +# - mlc: v3.12 +# Network: +# - OFED: 25.10-3.1.8 user-space (via NVIDIA DOCA-Host 3.2.3, matches host) + +LABEL maintainer="SuperBench" + +# Target GPU architectures for ROCm builds (space-separated). Without an explicit +# target, hipcc defaults to gfx906 when no GPU is present at build time, producing +# kernels that run incorrectly on MI300X/MI355X. The default targets MI300X (gfx942) +# and MI355X (gfx950); other architectures can be selected with, e.g., +# --build-arg AMDGPU_TARGETS="gfx90a gfx942". +ARG AMDGPU_TARGETS="gfx942 gfx950" +ENV AMDGPU_TARGETS="${AMDGPU_TARGETS}" + +ENV DEBIAN_FRONTEND=noninteractive +RUN apt-get update && \ + apt-get -q install -y --no-install-recommends \ + autoconf \ + automake \ + bc \ + build-essential \ + curl \ + dmidecode \ + flex \ + git \ + hipify-clang \ + iproute2 \ + jq \ + libaio-dev \ + libboost-program-options-dev \ + libcap2 \ + libcurl4-openssl-dev \ + libnuma-dev \ + libpci-dev \ + libssl-dev \ + libtinfo6 \ + libtool \ + lshw \ + net-tools \ + numactl \ + openssh-client \ + openssh-server \ + pciutils \ + python3-mpi4py \ + rsync \ + sudo \ + util-linux \ + vim \ + wget \ + && \ + apt-get clean && \ + rm -rf /tmp/* + +ARG NUM_MAKE_JOBS=64 + +# Check if CMake is installed and its version +RUN cmake_version=$(cmake --version 2>/dev/null | awk 'NR == 1 { print $3 }') && \ + cmake_version=${cmake_version:-0.0.0} && \ + required_version="3.24.1" && \ + if [ "$(printf "%s\n" "$required_version" "$cmake_version" | sort -V | head -n 1)" != "$required_version" ]; then \ + echo "existing cmake version is ${cmake_version}" && \ + cd /tmp && \ + wget -q https://github.com/Kitware/CMake/releases/download/v${required_version}/cmake-${required_version}.tar.gz && \ + tar xzf cmake-${required_version}.tar.gz && \ + cd cmake-${required_version} && \ + ./bootstrap --prefix=/usr --no-system-curl --parallel=16 && \ + make -j ${NUM_MAKE_JOBS} && \ + make install && \ + rm -rf /tmp/cmake-${required_version}* ; \ + else \ + echo "CMake version ${cmake_version} is greater than or equal to ${required_version}"; \ + fi + +# Install the Docker CLI client only. SuperBench uses only the `docker` client (docker pull/run/rmi) +# against an external/host daemon; the bundled dockerd/containerd/runc/shims are never used in-container, +# so we extract just docker/docker to shrink the image and cut the CVE surface. Pinned to the latest static release. +ENV DOCKER_VERSION=29.6.2 +RUN cd /tmp && \ + wget -q https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_VERSION}.tgz -O docker.tgz && \ + tar --extract --file docker.tgz --strip-components 1 --directory /usr/local/bin/ docker/docker && \ + rm docker.tgz + +# Update system config +RUN mkdir -p /root/.ssh && \ + touch /root/.ssh/authorized_keys && \ + mkdir -p /var/run/sshd && \ + sed -i "s/[# ]*PermitRootLogin prohibit-password/PermitRootLogin yes/" /etc/ssh/sshd_config && \ + sed -i "s/[# ]*PermitUserEnvironment no/PermitUserEnvironment yes/" /etc/ssh/sshd_config && \ + sed -i "s/[# ]*Port.*/Port 22/" /etc/ssh/sshd_config && \ + echo "* soft nofile 1048576\n* hard nofile 1048576" >> /etc/security/limits.conf && \ + echo "root soft nofile 1048576\nroot hard nofile 1048576" >> /etc/security/limits.conf + + +# Set Ubuntu version +ENV UBUNTU_VERSION=24.04 + +# Install OFED (user-space only) from the NVIDIA DOCA-Host repo to match the host stack. +ENV DOCA_VERSION=3.2.3 +# Check if ofed_info is present and has a version +RUN if ! command -v ofed_info >/dev/null 2>&1; then \ + echo "OFED not found. Installing DOCA-OFED user-space ${DOCA_VERSION}..."; \ + DOCA_REPO="https://linux.mellanox.com/public/repo/doca/${DOCA_VERSION}/ubuntu${UBUNTU_VERSION}/x86_64" && \ + curl -fsSL "${DOCA_REPO}/doca_keyring.gpg" -o /usr/share/keyrings/doca_keyring.gpg && \ + echo "deb [signed-by=/usr/share/keyrings/doca_keyring.gpg] ${DOCA_REPO}/ ./" > /etc/apt/sources.list.d/doca.list && \ + apt-get update && \ + apt-get install -y --no-install-recommends doca-ofed-userspace=${DOCA_VERSION}-019000 && \ + apt-get clean ; \ + fi + +ENV ROCM_PATH=/opt/rocm + +# Install OpenMPI +ENV OPENMPI_VERSION=4.1.x +ENV MPI_HOME=/usr/local/mpi +RUN cd /tmp && \ + git clone --recursive https://github.com/open-mpi/ompi.git -b v${OPENMPI_VERSION} && \ + cd ompi && \ + ./autogen.pl && \ + mkdir build && \ + cd build && \ + ../configure --prefix=/usr/local/mpi --enable-orterun-prefix-by-default --enable-mpirun-prefix-by-default --enable-prte-prefix-by-default --with-rocm=/opt/rocm && \ + make -j $(nproc) && \ + make -j $(nproc) install && \ + ldconfig && \ + cd / && \ + rm -rf /tmp/ompi + +# Install Intel MLC +RUN cd /tmp && \ + wget -q https://downloadmirror.intel.com/866182/mlc_v3.12.tgz -O mlc.tgz && \ + tar xzf mlc.tgz Linux/mlc && \ + cp ./Linux/mlc /usr/local/bin/ && \ + rm -rf ./Linux mlc.tgz + +# Set CMAKE_POLICY_VERSION_MINIMUM globally so subprojects (RCCL's mscclpp, etc.) still configure +# with CMake 4.0+, which dropped compatibility for cmake_minimum_required < 3.5. +ENV CMAKE_POLICY_VERSION_MINIMUM=3.5 + +# Install RCCL +RUN cd /opt/ && \ + git clone -b release/rocm-rel-7.2 https://github.com/ROCmSoftwarePlatform/rccl.git && \ + cd rccl && \ + mkdir build && \ + cd build && \ + CXX=/opt/rocm/bin/hipcc cmake -DHIP_COMPILER=clang -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=1 \ + -DCMAKE_PREFIX_PATH="${ROCM_PATH}/hsa;${ROCM_PATH}/hip;${ROCM_PATH}/share/rocm/cmake/;${ROCM_PATH}" \ + .. && \ + make -j${NUM_MAKE_JOBS} + +# Install AMD SMI Python Library +RUN apt install amd-smi-lib -y && \ + cd /opt/rocm/share/amd_smi && \ + python3 -m pip install . + +# Do NOT LD_PRELOAD librccl.so - it causes segfaults on process exit due to HIP static +# object teardown order. The source-built RCCL is picked up through LD_LIBRARY_PATH instead. +# Do NOT put /usr/lib/x86_64-linux-gnu/ before /opt/rocm/lib - the OFED user-space stack can +# ship an older libhsa-runtime64.so there that conflicts with ROCm's version. +ENV PATH="/usr/local/mpi/bin:/opt/superbench/bin:/usr/local/bin/:/opt/rocm/hip/bin/:/opt/rocm/bin/:${PATH}" \ + LD_LIBRARY_PATH="/opt/rccl/build:/usr/local/mpi/lib:/opt/rocm/lib:/usr/local/lib/:${LD_LIBRARY_PATH}" \ + SB_HOME=/opt/superbench \ + SB_MICRO_PATH=/opt/superbench \ + ANSIBLE_DEPRECATION_WARNINGS=FALSE \ + ANSIBLE_COLLECTIONS_PATH=/usr/share/ansible/collections + +RUN echo PATH="$PATH" > /etc/environment && \ + echo LD_LIBRARY_PATH="$LD_LIBRARY_PATH" >> /etc/environment && \ + echo SB_MICRO_PATH="$SB_MICRO_PATH" >> /etc/environment + +RUN apt install rocm-cmake -y && \ + python3 -m pip install --upgrade pip wheel "setuptools>=69.0" + +WORKDIR ${SB_HOME} + +ADD third_party third_party +# RCCL is built from source above and referenced via RCCL_HOME. +# perftest_rocm6.patch changes are already upstream in the submodule version. +# rocm_hipblaslt: skipped - hipblaslt-bench is built separately below. +# rocm_megatron_lm: skipped (broken upstream - pretrain_deepseek.py missing in rocm_dev branch). +# apex_rocm: skipped - all apex imports in Megatron-DeepSpeed are guarded with try/except, +# superbench has zero direct apex usage, and PyTorch 2.9 has native fused optimizers/AMP. +RUN make RCCL_HOME=/opt/rccl/build/ ROCBLAS_BRANCH=release/rocm-rel-7.2 HIPBLASLT_BRANCH=release/rocm-rel-7.2 ROCM_VER=rocm-5.5.0 -C third_party rocm -o cpu_hpl -o cpu_stream -o megatron_lm -o rocm_hipblaslt -o rocm_megatron_lm -o apex_rocm + +# Build hipblaslt-bench only (not the hipBLASLt library/Tensile kernels) and run it against the +# hipBLASLt shipped in the base image. This avoids the multi-hour, memory-hungry Tensile library +# generation that the ROCm 6.4 image needs. The upstream 7.2 build system pulls in AMD-internal +# "origami" headers and a new tensilelite-host C++ library even for client-only builds, so a +# minimal top-level CMakeLists.txt (dockerfile/etc/hipblaslt-bench-standalone.cmake) replaces it +# and compiles only the bench sources against the system hipBLASLt + LAPACK. +# The deps superbuild builds but does not install LAPACK; install it explicitly so the standalone +# build can find /usr/local/lib/{liblapack.a,libcblas.a,libblas.a}. The deps project's reserved +# "install" target is renamed so it also configures on CMake versions without CMP0037 OLD. +COPY dockerfile/etc/hipblaslt-bench-standalone.cmake /tmp/hipblaslt-bench-standalone.cmake +RUN cd third_party && \ + git clone --depth 1 -b release/rocm-rel-7.2 https://github.com/ROCmSoftwarePlatform/hipBLASLt.git && \ + cp /tmp/hipblaslt-bench-standalone.cmake hipBLASLt/CMakeLists.txt && \ + cd hipBLASLt && \ + sed -i '/cmake_policy( SET CMP0037 OLD )/d; s/add_custom_target( install/add_custom_target( hipblaslt_deps_install/' deps/CMakeLists.txt && \ + mkdir -p deps/build && cd deps/build && \ + cmake .. && \ + cmake --build . -j${NUM_MAKE_JOBS} --target lapack && \ + cmake --build lapack/src/lapack-build -j${NUM_MAKE_JOBS} --target install && \ + cd ../.. && \ + hipblaslt_architectures=$(printf '%s' "${AMDGPU_TARGETS}" | tr -s '[:space:]' ';' | sed 's/^;//; s/;$//') && \ + set -- cmake \ + -DCMAKE_CXX_COMPILER="${ROCM_PATH}/llvm/bin/clang++" \ + -DCMAKE_HIP_COMPILER="${ROCM_PATH}/llvm/bin/clang++" \ + -DCMAKE_HIP_ARCHITECTURES="${hipblaslt_architectures}" \ + -DCMAKE_PREFIX_PATH="${ROCM_PATH};/usr/local" \ + -DBLAS_LIBRARIES=/usr/local/lib/libblas.a \ + -DLAPACK_LIBRARIES=/usr/local/lib/liblapack.a \ + -DCMAKE_BUILD_TYPE=Release \ + .. && \ + mkdir -p build && cd build && \ + CMAKE_POLICY_VERSION_MINIMUM= "$@" && \ + make -j${NUM_MAKE_JOBS} hipblaslt-bench && \ + cp -v hipblaslt-bench /opt/superbench/bin/ +RUN cd third_party/Megatron/Megatron-DeepSpeed && \ + git apply ../megatron_deepspeed_rocm6.patch + +# Install TransformerEngine - pin to v2.10_rocm, a release line validated on ROCm 7.2 (it bundles +# AOTriton 0.11.2b GPU images for gfx942 and gfx950). CK fused attention stays disabled, as in the +# ROCm 6.4 image. AOTriton is enabled only when every requested target is gfx942 or gfx950, +# and disabled when any other architecture is requested. +# onnxscript/onnx are imported unconditionally by transformer_engine.pytorch; install them with +# pip up front rather than relying on `setup.py install` to resolve them. +RUN transformer_engine_architectures=$(printf '%s' "${AMDGPU_TARGETS}" | tr -s '[:space:]' ';' | sed 's/^;//; s/;$//') && \ + nvte_fused_attn_aotriton=0 && \ + if [ -n "${transformer_engine_architectures}" ]; then \ + nvte_fused_attn_aotriton=1; \ + for arch in $(printf '%s' "${transformer_engine_architectures}" | tr ';' ' '); do \ + case "${arch}" in \ + gfx942|gfx950) ;; \ + *) nvte_fused_attn_aotriton=0 ;; \ + esac; \ + done; \ + fi && \ + python3 -m pip install onnxscript onnx && \ + git clone --recursive -b v2.10_rocm https://github.com/ROCm/TransformerEngine.git && \ + cd TransformerEngine && \ + MAX_JOBS="${NUM_MAKE_JOBS}" \ + NVTE_FRAMEWORK=pytorch \ + NVTE_FUSED_ATTN_CK=0 \ + NVTE_FUSED_ATTN_AOTRITON="${nvte_fused_attn_aotriton}" \ + NVTE_ROCM_ARCH="${transformer_engine_architectures}" \ + python3 setup.py install +RUN python3 -c "import transformer_engine.pytorch; print('TE installed successfully')" + +ADD . . +ENV USE_HIP_DATATYPE=1 +ENV USE_HIPBLAS_COMPUTETYPE=1 +RUN python3 -m pip install .[amdworker] && \ + CXX=/opt/rocm/bin/hipcc make cppbuild && \ + make postinstall && \ + rm -rf .git + +# Fix stale hypothesis plugin from base image (imports removed pkg_resources) +# and add test dependencies missing from the base image. +RUN python3 -m pip install --upgrade hypothesis setuptools pytest-timeout vcrpy diff --git a/tests/test_rocm72_dockerfile.py b/tests/test_rocm72_dockerfile.py new file mode 100644 index 000000000..bb26e7043 --- /dev/null +++ b/tests/test_rocm72_dockerfile.py @@ -0,0 +1,106 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +"""Tests for ROCm 7.2 Dockerfile build configuration.""" + +import os +import subprocess +import unittest +from pathlib import Path + + +class Rocm72DockerfileTestCase(unittest.TestCase): + """Test ROCm 7.2 architecture routing without building an image.""" + @classmethod + def setUpClass(cls): + """Load the Dockerfile and extract its architecture-routing shell blocks.""" + repo_root = Path(__file__).resolve().parents[1] + cls.dockerfile = (repo_root / 'dockerfile' / 'rocm7.2.x.dockerfile').read_text(encoding='utf-8') + cls.standalone_cmake_path = repo_root / 'dockerfile' / 'etc' / 'hipblaslt-bench-standalone.cmake' + cls.hipblaslt_script = cls._extract_script( + 'hipblaslt_architectures=$(printf', + ' mkdir -p build && cd build', + 'printf \'%s\\n\' "$@"\n', + ) + cls.transformer_engine_script = cls._extract_script( + 'transformer_engine_architectures=$(printf', + ' python3 -m pip install onnxscript onnx', + 'printf \'%s\\n\' "$transformer_engine_architectures" "$nvte_fused_attn_aotriton"\n', + ) + + @classmethod + def _extract_script(cls, start_marker, end_marker, result_command): + """Extract an executable shell block between two Dockerfile markers.""" + start = cls.dockerfile.index(start_marker) + end = cls.dockerfile.index(end_marker, start) + return cls.dockerfile[start:end] + result_command + + def _run_script(self, script, targets): + """Run an extracted routing block for the requested targets.""" + env = os.environ.copy() + env.update({'AMDGPU_TARGETS': targets, 'NUM_MAKE_JOBS': '64', 'ROCM_PATH': '/opt/rocm'}) + result = subprocess.run( + ['/bin/sh', '-c', script], + check=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + universal_newlines=True, + env=env, + ) + return result.stdout.splitlines() + + def _expected_hipblaslt_command(self, architectures): + """Return the expected standalone hipblaslt-bench CMake configure command.""" + return [ + 'cmake', + '-DCMAKE_CXX_COMPILER=/opt/rocm/llvm/bin/clang++', + '-DCMAKE_HIP_COMPILER=/opt/rocm/llvm/bin/clang++', + f'-DCMAKE_HIP_ARCHITECTURES={architectures}', + '-DCMAKE_PREFIX_PATH=/opt/rocm;/usr/local', + '-DBLAS_LIBRARIES=/usr/local/lib/libblas.a', + '-DLAPACK_LIBRARIES=/usr/local/lib/liblapack.a', + '-DCMAKE_BUILD_TYPE=Release', + '..', + ] + + def test_architecture_routing(self): + """Test default, single, lower, mixed, and whitespace-normalized target routing.""" + configurations = ( + ('gfx942 gfx950', 'gfx942;gfx950', ['gfx942;gfx950', '1']), + ('gfx942', 'gfx942', ['gfx942', '1']), + ('gfx950', 'gfx950', ['gfx950', '1']), + ('gfx90a', 'gfx90a', ['gfx90a', '0']), + ('gfx90a gfx942 gfx950', 'gfx90a;gfx942;gfx950', ['gfx90a;gfx942;gfx950', '0']), + (' gfx942\t gfx950 ', 'gfx942;gfx950', ['gfx942;gfx950', '1']), + ('', '', ['', '0']), + ) + + for targets, expected_architectures, expected_transformer_engine in configurations: + with self.subTest(targets=targets): + self.assertEqual( + self._expected_hipblaslt_command(expected_architectures), + self._run_script(self.hipblaslt_script, targets), + ) + self.assertEqual( + expected_transformer_engine, + self._run_script(self.transformer_engine_script, targets), + ) + + def test_transformer_engine_receives_routed_configuration(self): + """Test that TransformerEngine receives the computed architecture settings.""" + self.assertIn('ARG AMDGPU_TARGETS="gfx942 gfx950"', self.dockerfile) + self.assertIn('NVTE_FUSED_ATTN_AOTRITON="${nvte_fused_attn_aotriton}"', self.dockerfile) + self.assertIn('NVTE_ROCM_ARCH="${transformer_engine_architectures}"', self.dockerfile) + + def test_standalone_hipblaslt_cmake_is_used(self): + """Test that the standalone hipblaslt-bench CMake script is shipped and copied into the build.""" + self.assertTrue(self.standalone_cmake_path.is_file()) + self.assertIn( + 'COPY dockerfile/etc/hipblaslt-bench-standalone.cmake /tmp/hipblaslt-bench-standalone.cmake', + self.dockerfile, + ) + self.assertIn('cp /tmp/hipblaslt-bench-standalone.cmake hipBLASLt/CMakeLists.txt', self.dockerfile) + + +if __name__ == '__main__': + unittest.main() diff --git a/third_party/Makefile b/third_party/Makefile index ddd4c440c..61fcf3887 100755 --- a/third_party/Makefile +++ b/third_party/Makefile @@ -180,9 +180,11 @@ rocm_hipblaslt: sb_micro_path # Build hipBusBandwidth. # HIP is released with rocm, like rocm-4.2.0 and so on. # The version we use is the released tag which is consistent with the rocm version in the environment or docker. - +# Inject include: newer clang (ROCm >= 7) rejects use of assert() without it. rocm_bandwidthTest: sb_micro_path git clone -b ${ROCM_VER} https://github.com/ROCm-Developer-Tools/HIP.git + grep -q '' ./HIP/samples/1_Utils/hipBusBandwidth/hipBusBandwidth.cpp || \ + sed -i '1i #include ' ./HIP/samples/1_Utils/hipBusBandwidth/hipBusBandwidth.cpp cd ./HIP/samples/1_Utils/hipBusBandwidth/ && mkdir -p build && cd build && cmake .. && make cp -v ./HIP/samples/1_Utils/hipBusBandwidth/build/hipBusBandwidth $(SB_MICRO_PATH)/bin/ From 7bd824dad2ead5e9faa336f6be95533a973c9c4f Mon Sep 17 00:00:00 2001 From: "Nguyen Vuong (from Dev Box)" Date: Wed, 23 Sep 2026 16:54:16 -0700 Subject: [PATCH 2/7] Dockerfile - Inherit CMAKE_POLICY_VERSION_MINIMUM for hipBLASLt configure Stop clearing the global CMAKE_POLICY_VERSION_MINIMUM=3.5 for the hipblaslt-bench configure step so CMake 4.x compatibility also applies to any nested project. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- dockerfile/rocm7.2.x.dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockerfile/rocm7.2.x.dockerfile b/dockerfile/rocm7.2.x.dockerfile index 664ef403f..aacbfb802 100644 --- a/dockerfile/rocm7.2.x.dockerfile +++ b/dockerfile/rocm7.2.x.dockerfile @@ -229,7 +229,7 @@ RUN cd third_party && \ -DCMAKE_BUILD_TYPE=Release \ .. && \ mkdir -p build && cd build && \ - CMAKE_POLICY_VERSION_MINIMUM= "$@" && \ + "$@" && \ make -j${NUM_MAKE_JOBS} hipblaslt-bench && \ cp -v hipblaslt-bench /opt/superbench/bin/ RUN cd third_party/Megatron/Megatron-DeepSpeed && \ From addef074c0fe84ebd953dedd3c20db6bea94b7a3 Mon Sep 17 00:00:00 2001 From: "Nguyen Vuong (from Dev Box)" Date: Wed, 23 Sep 2026 16:58:29 -0700 Subject: [PATCH 3/7] Dockerfile - Cap OpenMPI build parallelism with NUM_MAKE_JOBS Use the configured NUM_MAKE_JOBS limit instead of $(nproc) when building OpenMPI so the image build honors the CI job cap. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- dockerfile/rocm7.2.x.dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dockerfile/rocm7.2.x.dockerfile b/dockerfile/rocm7.2.x.dockerfile index aacbfb802..a9007e534 100644 --- a/dockerfile/rocm7.2.x.dockerfile +++ b/dockerfile/rocm7.2.x.dockerfile @@ -136,8 +136,8 @@ RUN cd /tmp && \ mkdir build && \ cd build && \ ../configure --prefix=/usr/local/mpi --enable-orterun-prefix-by-default --enable-mpirun-prefix-by-default --enable-prte-prefix-by-default --with-rocm=/opt/rocm && \ - make -j $(nproc) && \ - make -j $(nproc) install && \ + make -j ${NUM_MAKE_JOBS} && \ + make -j ${NUM_MAKE_JOBS} install && \ ldconfig && \ cd / && \ rm -rf /tmp/ompi From 53f0b897783520d52712ae92a86402096bf40c46 Mon Sep 17 00:00:00 2001 From: "Nguyen Vuong (from Dev Box)" Date: Thu, 24 Sep 2026 14:17:28 -0700 Subject: [PATCH 4/7] Dockerfile - Refresh apt index before third_party ROCm build rocBLAS install.sh --dependencies runs apt-get install. When the earlier apt-get update layer is restored from the registry cache, its package index can be stale and fail with 404s on superseded Ubuntu packages (seen in the rocm6.4 PR gate once third_party changes invalidate later layers). Run apt-get update in the same layer as the third_party make. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- dockerfile/rocm6.4.x.dockerfile | 5 ++++- dockerfile/rocm7.2.x.dockerfile | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dockerfile/rocm6.4.x.dockerfile b/dockerfile/rocm6.4.x.dockerfile index ad551a559..4243069f4 100644 --- a/dockerfile/rocm6.4.x.dockerfile +++ b/dockerfile/rocm6.4.x.dockerfile @@ -186,7 +186,10 @@ ADD third_party third_party # rocm_megatron_lm: skipped (broken upstream - pretrain_deepseek.py missing in rocm_dev branch). # apex_rocm: skipped - all apex imports in Megatron-DeepSpeed are guarded with try/except, # superbench has zero direct apex usage, and PyTorch 2.7 has native fused optimizers/AMP. -RUN make RCCL_HOME=/opt/rccl/build/ ROCBLAS_BRANCH=release-staging/rocm-rel-6.4 HIPBLASLT_BRANCH=release-staging/rocm-rel-6.4 ROCM_VER=rocm-5.5.0 -C third_party rocm -o cpu_hpl -o cpu_stream -o megatron_lm -o rocm_hipblaslt -o rocm_megatron_lm -o apex_rocm +# Refresh the apt index first: rocBLAS's install.sh --dependencies runs apt-get install, and the +# earlier apt-get update layer may come from a stale registry cache (404s on superseded packages). +RUN apt-get update && \ + make RCCL_HOME=/opt/rccl/build/ ROCBLAS_BRANCH=release-staging/rocm-rel-6.4 HIPBLASLT_BRANCH=release-staging/rocm-rel-6.4 ROCM_VER=rocm-5.5.0 -C third_party rocm -o cpu_hpl -o cpu_stream -o megatron_lm -o rocm_hipblaslt -o rocm_megatron_lm -o apex_rocm # Build hipblaslt separately with the Tensile target-triple fix for the ROCm 6.4 clang. # Also work around a joblib race (github.com/joblib/joblib/issues/1788, fixed upstream in diff --git a/dockerfile/rocm7.2.x.dockerfile b/dockerfile/rocm7.2.x.dockerfile index a9007e534..e058b65c4 100644 --- a/dockerfile/rocm7.2.x.dockerfile +++ b/dockerfile/rocm7.2.x.dockerfile @@ -196,7 +196,10 @@ ADD third_party third_party # rocm_megatron_lm: skipped (broken upstream - pretrain_deepseek.py missing in rocm_dev branch). # apex_rocm: skipped - all apex imports in Megatron-DeepSpeed are guarded with try/except, # superbench has zero direct apex usage, and PyTorch 2.9 has native fused optimizers/AMP. -RUN make RCCL_HOME=/opt/rccl/build/ ROCBLAS_BRANCH=release/rocm-rel-7.2 HIPBLASLT_BRANCH=release/rocm-rel-7.2 ROCM_VER=rocm-5.5.0 -C third_party rocm -o cpu_hpl -o cpu_stream -o megatron_lm -o rocm_hipblaslt -o rocm_megatron_lm -o apex_rocm +# Refresh the apt index first: rocBLAS's install.sh --dependencies runs apt-get install, and the +# earlier apt-get update layer may come from a stale registry cache (404s on superseded packages). +RUN apt-get update && \ + make RCCL_HOME=/opt/rccl/build/ ROCBLAS_BRANCH=release/rocm-rel-7.2 HIPBLASLT_BRANCH=release/rocm-rel-7.2 ROCM_VER=rocm-5.5.0 -C third_party rocm -o cpu_hpl -o cpu_stream -o megatron_lm -o rocm_hipblaslt -o rocm_megatron_lm -o apex_rocm # Build hipblaslt-bench only (not the hipBLASLt library/Tensile kernels) and run it against the # hipBLASLt shipped in the base image. This avoids the multi-hour, memory-hungry Tensile library From 8d72f6bc34d54d7830a1189f9e200c449e3a8dd0 Mon Sep 17 00:00:00 2001 From: "Nguyen Vuong (from Dev Box)" Date: Thu, 24 Sep 2026 14:17:28 -0700 Subject: [PATCH 5/7] Dockerfile - Require CMake 3.24.4 for ROCm 7.2 image rocBLAS release/rocm-rel-7.2 install.sh and CMakeLists.txt require CMake >= 3.24.4; the ROCm 7.2 base image has no suitable CMake, so the previously bootstrapped 3.24.1 made the rocm_rocblas build fail. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- dockerfile/rocm7.2.x.dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockerfile/rocm7.2.x.dockerfile b/dockerfile/rocm7.2.x.dockerfile index e058b65c4..5f6339138 100644 --- a/dockerfile/rocm7.2.x.dockerfile +++ b/dockerfile/rocm7.2.x.dockerfile @@ -73,7 +73,7 @@ ARG NUM_MAKE_JOBS=64 # Check if CMake is installed and its version RUN cmake_version=$(cmake --version 2>/dev/null | awk 'NR == 1 { print $3 }') && \ cmake_version=${cmake_version:-0.0.0} && \ - required_version="3.24.1" && \ + required_version="3.24.4" && \ if [ "$(printf "%s\n" "$required_version" "$cmake_version" | sort -V | head -n 1)" != "$required_version" ]; then \ echo "existing cmake version is ${cmake_version}" && \ cd /tmp && \ From fa2e0c0dcb56c7d1c2323f89274f3db68420626f Mon Sep 17 00:00:00 2001 From: "Nguyen Vuong (from Dev Box)" Date: Fri, 25 Sep 2026 07:18:30 -0700 Subject: [PATCH 6/7] Dockerfile - Require CMake 3.25.3 for ROCm 7.2 image The ROCm 7.2 hipblaslt-config.cmake uses the block() command added in CMake 3.25, and hipBLASLt 7.2 itself requires CMake 3.25.2. With 3.24.4, find_package(hipblaslt) in the rocBLAS clients build fails with 'Unknown CMake command \"block\"'. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- dockerfile/rocm7.2.x.dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockerfile/rocm7.2.x.dockerfile b/dockerfile/rocm7.2.x.dockerfile index 5f6339138..385a383fc 100644 --- a/dockerfile/rocm7.2.x.dockerfile +++ b/dockerfile/rocm7.2.x.dockerfile @@ -73,7 +73,7 @@ ARG NUM_MAKE_JOBS=64 # Check if CMake is installed and its version RUN cmake_version=$(cmake --version 2>/dev/null | awk 'NR == 1 { print $3 }') && \ cmake_version=${cmake_version:-0.0.0} && \ - required_version="3.24.4" && \ + required_version="3.25.3" && \ if [ "$(printf "%s\n" "$required_version" "$cmake_version" | sort -V | head -n 1)" != "$required_version" ]; then \ echo "existing cmake version is ${cmake_version}" && \ cd /tmp && \ From 0e7eab81376ff87360fec0079612980e7bdba141 Mon Sep 17 00:00:00 2001 From: "Nguyen Vuong (from Dev Box)" Date: Mon, 5 Oct 2026 11:09:05 -0700 Subject: [PATCH 7/7] Dockerfile - Address ROCm 7.2 review feedback - Pin hipBLASLt, RCCL and rocBLAS sources to the rocm-7.2.4 tag matching the base image, so the hipblaslt-bench headers stay in lockstep with the installed libhipblaslt.so and rebuilds are reproducible. - Only pass CMAKE_HIP_ARCHITECTURES to the hipblaslt-bench configure when AMDGPU_TARGETS is non-empty; CMake rejects a defined-but-empty value. - Add gfortran to the apt list (needed for LAPACK in hipBLASLt deps). - Pin onnxscript 0.7.2 and onnx 1.23.0, the versions validated with TE v2.10_rocm. - Remove the hipBLASLt source/build trees after copying hipblaslt-bench. - Drop the unused HIPBLASLT_INTERNAL_API define from the standalone CMake. - Bump Intel MLC to v3.13 with checksum verification, matching main. - Update tests: empty targets omit the architecture flag; add tag pin, MLC and apt refresh checks. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../etc/hipblaslt-bench-standalone.cmake | 1 - dockerfile/rocm7.2.x.dockerfile | 44 ++++++++++++------- tests/test_rocm72_dockerfile.py | 37 ++++++++++++++-- 3 files changed, 63 insertions(+), 19 deletions(-) diff --git a/dockerfile/etc/hipblaslt-bench-standalone.cmake b/dockerfile/etc/hipblaslt-bench-standalone.cmake index 67f3ad986..013b0e97f 100644 --- a/dockerfile/etc/hipblaslt-bench-standalone.cmake +++ b/dockerfile/etc/hipblaslt-bench-standalone.cmake @@ -92,7 +92,6 @@ target_compile_definitions(hipblaslt-clients-common ROCM_USE_FLOAT16 __HIP_PLATFORM_AMD__ HIPBLASLT_BENCH - HIPBLASLT_INTERNAL_API ) target_link_libraries(hipblaslt-clients-common diff --git a/dockerfile/rocm7.2.x.dockerfile b/dockerfile/rocm7.2.x.dockerfile index 385a383fc..fc50ed01d 100644 --- a/dockerfile/rocm7.2.x.dockerfile +++ b/dockerfile/rocm7.2.x.dockerfile @@ -9,13 +9,13 @@ FROM ${BASE_IMAGE} # - ROCm: 7.2 # Lib: # - torch: 2.9.1 -# - rccl: release/rocm-rel-7.2 -# - hipblaslt: release/rocm-rel-7.2 (hipblaslt-bench only, against system hipBLASLt) -# - rocblas: release/rocm-rel-7.2 +# - rccl: rocm-7.2.4 +# - hipblaslt: rocm-7.2.4 (hipblaslt-bench only, against system hipBLASLt) +# - rocblas: rocm-7.2.4 # - transformer_engine: v2.10_rocm # - openmpi: 4.1.x # Intel: -# - mlc: v3.12 +# - mlc: v3.13 # Network: # - OFED: 25.10-3.1.8 user-space (via NVIDIA DOCA-Host 3.2.3, matches host) @@ -39,6 +39,7 @@ RUN apt-get update && \ curl \ dmidecode \ flex \ + gfortran \ git \ hipify-clang \ iproute2 \ @@ -144,18 +145,20 @@ RUN cd /tmp && \ # Install Intel MLC RUN cd /tmp && \ - wget -q https://downloadmirror.intel.com/866182/mlc_v3.12.tgz -O mlc.tgz && \ + wget -q https://downloadmirror.intel.com/926327/mlc_v3.13.tgz -O mlc.tgz && \ + echo "a8537e8ff3fad626d75a383fabc224ccc4cc98a0111c9989f7fb26b639f12019 mlc.tgz" | sha256sum -c - && \ tar xzf mlc.tgz Linux/mlc && \ - cp ./Linux/mlc /usr/local/bin/ && \ + install -m 755 ./Linux/mlc /usr/local/bin/ && \ rm -rf ./Linux mlc.tgz # Set CMAKE_POLICY_VERSION_MINIMUM globally so subprojects (RCCL's mscclpp, etc.) still configure # with CMake 4.0+, which dropped compatibility for cmake_minimum_required < 3.5. ENV CMAKE_POLICY_VERSION_MINIMUM=3.5 -# Install RCCL +# Install RCCL. Pinned to the release tag matching the base image: /opt/rccl/build comes first on +# LD_LIBRARY_PATH, so this build replaces the base image's RCCL for rccl-tests and PyTorch. RUN cd /opt/ && \ - git clone -b release/rocm-rel-7.2 https://github.com/ROCmSoftwarePlatform/rccl.git && \ + git clone -b rocm-7.2.4 https://github.com/ROCmSoftwarePlatform/rccl.git && \ cd rccl && \ mkdir build && \ cd build && \ @@ -199,7 +202,7 @@ ADD third_party third_party # Refresh the apt index first: rocBLAS's install.sh --dependencies runs apt-get install, and the # earlier apt-get update layer may come from a stale registry cache (404s on superseded packages). RUN apt-get update && \ - make RCCL_HOME=/opt/rccl/build/ ROCBLAS_BRANCH=release/rocm-rel-7.2 HIPBLASLT_BRANCH=release/rocm-rel-7.2 ROCM_VER=rocm-5.5.0 -C third_party rocm -o cpu_hpl -o cpu_stream -o megatron_lm -o rocm_hipblaslt -o rocm_megatron_lm -o apex_rocm + make RCCL_HOME=/opt/rccl/build/ ROCBLAS_BRANCH=rocm-7.2.4 HIPBLASLT_BRANCH=rocm-7.2.4 ROCM_VER=rocm-5.5.0 -C third_party rocm -o cpu_hpl -o cpu_stream -o megatron_lm -o rocm_hipblaslt -o rocm_megatron_lm -o apex_rocm # Build hipblaslt-bench only (not the hipBLASLt library/Tensile kernels) and run it against the # hipBLASLt shipped in the base image. This avoids the multi-hour, memory-hungry Tensile library @@ -210,9 +213,13 @@ RUN apt-get update && \ # The deps superbuild builds but does not install LAPACK; install it explicitly so the standalone # build can find /usr/local/lib/{liblapack.a,libcblas.a,libblas.a}. The deps project's reserved # "install" target is renamed so it also configures on CMake versions without CMP0037 OLD. +# The source is pinned to the release tag matching the base image, because the bench compiles +# against this checkout's (including internal) headers but links the installed libhipblaslt.so. +# CMAKE_HIP_ARCHITECTURES is only passed when AMDGPU_TARGETS is non-empty: a defined-but-empty +# value makes CMake fail at generate time, while leaving it undefined lets CMake auto-detect. COPY dockerfile/etc/hipblaslt-bench-standalone.cmake /tmp/hipblaslt-bench-standalone.cmake RUN cd third_party && \ - git clone --depth 1 -b release/rocm-rel-7.2 https://github.com/ROCmSoftwarePlatform/hipBLASLt.git && \ + git clone --depth 1 -b rocm-7.2.4 https://github.com/ROCmSoftwarePlatform/hipBLASLt.git && \ cp /tmp/hipblaslt-bench-standalone.cmake hipBLASLt/CMakeLists.txt && \ cd hipBLASLt && \ sed -i '/cmake_policy( SET CMP0037 OLD )/d; s/add_custom_target( install/add_custom_target( hipblaslt_deps_install/' deps/CMakeLists.txt && \ @@ -224,8 +231,11 @@ RUN cd third_party && \ hipblaslt_architectures=$(printf '%s' "${AMDGPU_TARGETS}" | tr -s '[:space:]' ';' | sed 's/^;//; s/;$//') && \ set -- cmake \ -DCMAKE_CXX_COMPILER="${ROCM_PATH}/llvm/bin/clang++" \ - -DCMAKE_HIP_COMPILER="${ROCM_PATH}/llvm/bin/clang++" \ - -DCMAKE_HIP_ARCHITECTURES="${hipblaslt_architectures}" \ + -DCMAKE_HIP_COMPILER="${ROCM_PATH}/llvm/bin/clang++" && \ + if [ -n "${hipblaslt_architectures}" ]; then \ + set -- "$@" -DCMAKE_HIP_ARCHITECTURES="${hipblaslt_architectures}"; \ + fi && \ + set -- "$@" \ -DCMAKE_PREFIX_PATH="${ROCM_PATH};/usr/local" \ -DBLAS_LIBRARIES=/usr/local/lib/libblas.a \ -DLAPACK_LIBRARIES=/usr/local/lib/liblapack.a \ @@ -234,7 +244,9 @@ RUN cd third_party && \ mkdir -p build && cd build && \ "$@" && \ make -j${NUM_MAKE_JOBS} hipblaslt-bench && \ - cp -v hipblaslt-bench /opt/superbench/bin/ + cp -v hipblaslt-bench /opt/superbench/bin/ && \ + cd /opt/superbench/third_party && \ + rm -rf hipBLASLt /tmp/hipblaslt-bench-standalone.cmake RUN cd third_party/Megatron/Megatron-DeepSpeed && \ git apply ../megatron_deepspeed_rocm6.patch @@ -243,7 +255,9 @@ RUN cd third_party/Megatron/Megatron-DeepSpeed && \ # ROCm 6.4 image. AOTriton is enabled only when every requested target is gfx942 or gfx950, # and disabled when any other architecture is requested. # onnxscript/onnx are imported unconditionally by transformer_engine.pytorch; install them with -# pip up front rather than relying on `setup.py install` to resolve them. +# pip up front rather than relying on `setup.py install` to resolve them. They are pinned to the +# versions validated with TE v2.10_rocm and torch 2.9.1 so rebuilds don't pull newer releases +# whose protobuf/numpy requirements conflict with the base image. RUN transformer_engine_architectures=$(printf '%s' "${AMDGPU_TARGETS}" | tr -s '[:space:]' ';' | sed 's/^;//; s/;$//') && \ nvte_fused_attn_aotriton=0 && \ if [ -n "${transformer_engine_architectures}" ]; then \ @@ -255,7 +269,7 @@ RUN transformer_engine_architectures=$(printf '%s' "${AMDGPU_TARGETS}" | tr -s ' esac; \ done; \ fi && \ - python3 -m pip install onnxscript onnx && \ + python3 -m pip install onnxscript==0.7.2 onnx==1.23.0 && \ git clone --recursive -b v2.10_rocm https://github.com/ROCm/TransformerEngine.git && \ cd TransformerEngine && \ MAX_JOBS="${NUM_MAKE_JOBS}" \ diff --git a/tests/test_rocm72_dockerfile.py b/tests/test_rocm72_dockerfile.py index bb26e7043..0e910ef34 100644 --- a/tests/test_rocm72_dockerfile.py +++ b/tests/test_rocm72_dockerfile.py @@ -24,7 +24,7 @@ def setUpClass(cls): ) cls.transformer_engine_script = cls._extract_script( 'transformer_engine_architectures=$(printf', - ' python3 -m pip install onnxscript onnx', + ' python3 -m pip install onnxscript==0.7.2 onnx==1.23.0', 'printf \'%s\\n\' "$transformer_engine_architectures" "$nvte_fused_attn_aotriton"\n', ) @@ -51,11 +51,12 @@ def _run_script(self, script, targets): def _expected_hipblaslt_command(self, architectures): """Return the expected standalone hipblaslt-bench CMake configure command.""" + architecture_flags = [f'-DCMAKE_HIP_ARCHITECTURES={architectures}'] if architectures else [] return [ 'cmake', '-DCMAKE_CXX_COMPILER=/opt/rocm/llvm/bin/clang++', '-DCMAKE_HIP_COMPILER=/opt/rocm/llvm/bin/clang++', - f'-DCMAKE_HIP_ARCHITECTURES={architectures}', + *architecture_flags, '-DCMAKE_PREFIX_PATH=/opt/rocm;/usr/local', '-DBLAS_LIBRARIES=/usr/local/lib/libblas.a', '-DLAPACK_LIBRARIES=/usr/local/lib/liblapack.a', @@ -64,7 +65,11 @@ def _expected_hipblaslt_command(self, architectures): ] def test_architecture_routing(self): - """Test default, single, lower, mixed, and whitespace-normalized target routing.""" + """Test default, single, lower, mixed, whitespace-normalized, and empty target routing. + + An empty target list must omit -DCMAKE_HIP_ARCHITECTURES entirely, because CMake rejects a + defined-but-empty value and only auto-detects when the variable is undefined. + """ configurations = ( ('gfx942 gfx950', 'gfx942;gfx950', ['gfx942;gfx950', '1']), ('gfx942', 'gfx942', ['gfx942', '1']), @@ -101,6 +106,32 @@ def test_standalone_hipblaslt_cmake_is_used(self): ) self.assertIn('cp /tmp/hipblaslt-bench-standalone.cmake hipBLASLt/CMakeLists.txt', self.dockerfile) + def test_rocm_sources_pinned_to_base_image_release(self): + """Test that ROCm library sources are pinned to the tag matching the base image.""" + self.assertIn('rocm/pytorch:rocm7.2.4_', self.dockerfile) + self.assertIn('git clone -b rocm-7.2.4 https://github.com/ROCmSoftwarePlatform/rccl.git', self.dockerfile) + self.assertIn( + 'git clone --depth 1 -b rocm-7.2.4 https://github.com/ROCmSoftwarePlatform/hipBLASLt.git', + self.dockerfile, + ) + self.assertIn('ROCBLAS_BRANCH=rocm-7.2.4', self.dockerfile) + self.assertNotIn('release/rocm-rel-7.2', self.dockerfile) + + def test_mlc_checksum_verification(self): + """Test MLC download is checksum-verified and installed as an executable.""" + self.assertIn('wget -q https://downloadmirror.intel.com/926327/mlc_v3.13.tgz -O mlc.tgz', self.dockerfile) + self.assertIn( + 'echo "a8537e8ff3fad626d75a383fabc224ccc4cc98a0111c9989f7fb26b639f12019 mlc.tgz" | sha256sum -c -', + self.dockerfile, + ) + self.assertIn('install -m 755 ./Linux/mlc /usr/local/bin/', self.dockerfile) + + def test_rocm_build_refreshes_package_index(self): + """Test APT metadata is refreshed before installing ROCm dependencies.""" + build_command = 'RUN apt-get update && \\\n make RCCL_HOME=/opt/rccl/build/ ' + self.assertIn(build_command, self.dockerfile) + self.assertEqual(self.dockerfile.count('make RCCL_HOME='), 1) + if __name__ == '__main__': unittest.main()