From 244c8d93eb1e735ce05e778bb9cda6962b93ccc4 Mon Sep 17 00:00:00 2001 From: Wenqing Lan Date: Fri, 20 Nov 2026 14:17:50 -0800 Subject: [PATCH] add cuda13.5.dockerfile with nvbandwidth v0.11 and cutlass 4.8.1 --- .github/workflows/build-image.yml | 11 + dockerfile/cuda13.5.dockerfile | 212 ++++++++++++++ .../benchmarks/micro-benchmarks.md | 11 + .../micro_benchmarks/nvbandwidth.py | 258 ++++++++++++------ .../micro_benchmarks/test_nvbandwidth.py | 163 ++++++++++- tests/data/nvbandwidth_v0.11.log | 106 +++++++ third_party/Makefile | 22 +- third_party/Megatron/requirements.txt | 2 +- third_party/nvbandwidth-0.11.0.patch | 40 +++ third_party/nvbandwidth_testcases_0.11.0.h | 109 ++++++++ 10 files changed, 844 insertions(+), 90 deletions(-) create mode 100644 dockerfile/cuda13.5.dockerfile create mode 100644 tests/data/nvbandwidth_v0.11.log create mode 100644 third_party/nvbandwidth-0.11.0.patch create mode 100644 third_party/nvbandwidth_testcases_0.11.0.h diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index 4a04cb6e4..57f837fcf 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -32,6 +32,13 @@ jobs: fail-fast: false matrix: include: + - name: cuda13.5-arm64 + dockerfile: cuda13.5 + tags: superbench/main:cuda13.5-arm64 + platforms: linux/arm64 + runner: [self-hosted, linux/arm64] + build_args: "NUM_MAKE_JOBS=16" + registry_cache: true - name: cuda13.4-arm64 dockerfile: cuda13.4 tags: superbench/main:cuda13.4-arm64 @@ -197,6 +204,10 @@ jobs: fail-fast: false matrix: include: + - name: cuda13.5 + tags: superbench/main:cuda13.5 + sources: >- + superbench/main:cuda13.5-arm64 - name: cuda13.4 tags: superbench/main:cuda13.4 sources: >- diff --git a/dockerfile/cuda13.5.dockerfile b/dockerfile/cuda13.5.dockerfile new file mode 100644 index 000000000..646f36f38 --- /dev/null +++ b/dockerfile/cuda13.5.dockerfile @@ -0,0 +1,212 @@ +# Build the streamOlympus STREAM variant in a separate stage. -mcpu=olympus needs GCC 15 and +# binutils 2.46, while the base image ships GCC 13 / binutils 2.42. Building it here keeps +# that toolchain (and its runtime libraries) out of the final image. +FROM nvcr.io/nvidia/pytorch:26.11-py3@sha256:0d31ce7e80cda1b1f07357004530a2f41d6754a6ddae28af508134c63c59fe0b AS stream-olympus-builder + +ARG NUM_MAKE_JOBS=64 +ENV DEBIAN_FRONTEND=noninteractive \ + BINUTILS_VERSION=2.46.1 \ + BINUTILS_SHA256=e127a709cba24c76de8936cb7083dd768f28cd37eb010492e2f19b71eb1294e4 + +COPY third_party/stream-tests/Makefile /build/Makefile + +RUN mkdir -p /out && \ + if [ "$(uname -m)" != "aarch64" ]; then \ + echo "Skipping streamOlympus for non-aarch64 architecture"; \ + exit 0; \ + fi && \ + apt-get update && \ + apt-get install -y --no-install-recommends \ + software-properties-common ca-certificates wget xz-utils zlib1g-dev libzstd-dev && \ + add-apt-repository -y ppa:ubuntu-toolchain-r/test && \ + apt-get update && \ + apt-get install -y --no-install-recommends gcc-15 && \ + cd /tmp && \ + for base in https://sourceware.org/pub/binutils/releases https://mirrors.kernel.org/gnu/binutils https://ftp.gnu.org/gnu/binutils; do \ + wget -nv --tries=3 --timeout=60 "${base}/binutils-${BINUTILS_VERSION}.tar.xz" -O binutils.tar.xz && break; \ + done && \ + echo "${BINUTILS_SHA256} binutils.tar.xz" | sha256sum -c - && \ + tar -xf binutils.tar.xz && \ + cd binutils-${BINUTILS_VERSION} && \ + ./configure --prefix=/opt/binutils-${BINUTILS_VERSION} \ + --with-system-zlib \ + --disable-werror \ + --disable-gprofng && \ + make -j "${NUM_MAKE_JOBS}" MAKEINFO=true && \ + make install MAKEINFO=true && \ + cd /build && \ + gcc-15 --version | head -n1 && \ + make OLYMPUS CC="gcc-15 -B/opt/binutils-${BINUTILS_VERSION}/bin/" && \ + sha256sum stream.c streamOlympus && \ + cp streamOlympus /out/ + +FROM nvcr.io/nvidia/pytorch:26.11-py3@sha256:0d31ce7e80cda1b1f07357004530a2f41d6754a6ddae28af508134c63c59fe0b + +# OS: +# - Ubuntu: 24.04 +# - OpenMPI: 5.0.10rc2 (from HPC-X 2.51) +# - Docker Client: 20.10.8 (installed in this dockerfile) +# NVIDIA: +# - CUDA: 13.5 V13.5.37 (from pytorch:26.11-py3) +# - cuDNN: 9.28.0.42 +# - cuBLAS: 13.10.0.20 +# - NCCL: 2.32.6 +# - TransformerEngine: 2.21.0 +# - torch: 2.15.0a0+fd23299d96.nv26.11 +# - CUTLASS: v4.8.1 (SHA-verified by third_party/Makefile) +# - nvbandwidth: v0.11.0 (SHA-verified, with SuperBench concurrent batch cases) +# - sm_107 / compute capability 10.7 +# Mellanox (from base image - not reinstalled): +# - OFED: inbox (kernel-provided) +# - HPC-X: 2.51 (includes ompi4 + ompi5, UCX 1.22.0) +# Intel: +# - mlc: 3.13 (amd64 only) +# +# Notes for sm_107: +# - This image is validated on aarch64 (ARM). cpu_hpl, Intel MLC, AOCC and AMD BLIS auto-skip on aarch64. +# - CUDA 13.5 builds the in-tree CUDA benchmarks, CUTLASS, NVBench, +# cuBLASLt and NCCL tests for sm_107. +# - streamOlympus is built with GCC 15 in the stream-olympus-builder stage above. +# +# Build (from repo root), e.g.: +# docker build -t superbench-cuda13.5 \ +# --build-arg NUM_MAKE_JOBS=16 \ +# -f dockerfile/cuda13.5.dockerfile . + +LABEL maintainer="SuperBench" + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + autoconf \ + automake \ + bc \ + build-essential \ + curl \ + dmidecode \ + ffmpeg \ + git \ + iproute2 \ + jq \ + libaio-dev \ + libavcodec-dev \ + libavformat-dev \ + libavutil-dev \ + libboost-program-options-dev \ + libcap2 \ + libcurl4-openssl-dev \ + libnuma-dev \ + libpci-dev \ + libswresample-dev \ + libncurses-dev \ + libtool \ + lshw \ + python3-mpi4py \ + net-tools \ + nlohmann-json3-dev \ + openssh-client \ + openssh-server \ + pciutils \ + sudo \ + util-linux \ + vim \ + wget \ + rsync \ + && \ + apt-get autoremove && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* /tmp/* + +# Number of parallel jobs for NVBench and nvbandwidth. Override with --build-arg NUM_MAKE_JOBS=... +ARG NUM_MAKE_JOBS=64 + +ARG TARGETPLATFORM +ARG TARGETARCH + +# Install Docker +ENV DOCKER_VERSION=20.10.8 +RUN TARGETARCH_HW=$(uname -m) && \ + wget -q https://download.docker.com/linux/static/stable/${TARGETARCH_HW}/docker-${DOCKER_VERSION}.tgz -O docker.tgz && \ + tar --extract --file docker.tgz --strip-components 1 --directory /usr/local/bin/ && \ + 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 + +# OFED and HPC-X: Using the base image's versions (inbox OFED, HPC-X 2.51). +# The base NGC pytorch:26.11-py3 image ships HPC-X at /opt/hpcx with +# ompi4+ompi5 and the ompi_mpi_short_float symbol that PyTorch is linked against. +# Note: HPC-X 2.51 no longer has hpcx-init.sh; use /opt/hpcx/ompi/bin directly. +# DO NOT install a separate OFED or HPC-X - it breaks PyTorch's MPI linkage. + +# Installs specific to amd64 platform +RUN if [ "$TARGETARCH" = "amd64" ]; then \ + # Install Intel MLC + cd /tmp && \ + 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 && \ + install -m 755 ./Linux/mlc /usr/local/bin/ && \ + rm -rf ./Linux mlc.tgz && \ + # Install AOCC compiler + wget https://download.amd.com/developer/eula/aocc-compiler/aocc-compiler-4.0.0_1_amd64.deb && \ + apt install -y ./aocc-compiler-4.0.0_1_amd64.deb && \ + rm -rf aocc-compiler-4.0.0_1_amd64.deb && \ + # Install AMD BLIS + wget https://download.amd.com/developer/eula/blis/blis-4-0/aocl-blis-linux-aocc-4.0.tar.gz && \ + tar xzf aocl-blis-linux-aocc-4.0.tar.gz && \ + mv amd-blis /opt/AMD && \ + rm -rf aocl-blis-linux-aocc-4.0.tar.gz; \ + else \ + echo "Skipping Intel MLC, AOCC and AMD BLIS installations for non-amd64 architecture: $TARGETARCH"; \ + fi + +# Add the base image's HPC-X 2.51 UCX and ompi to the library path and add mpicc to PATH. +ENV MPI_HOME=/opt/hpcx/ompi +ENV PATH="/opt/hpcx/ompi/bin:${PATH}" \ + LD_LIBRARY_PATH="/opt/hpcx/ucx/lib:/opt/hpcx/ompi/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 + +# Add config files +ADD dockerfile/etc /opt/microsoft/ + +WORKDIR ${SB_HOME} + +# Copy everything before release clones so legacy submodules cannot overlay them later. +ADD . . +# Build the CUDA targets (the `cuda` aggregate; MSCCL is not included). mpicc comes from the +# base image's HPC-X 2.51 via the PATH set above. +RUN make -C third_party cuda NUM_MAKE_JOBS=${NUM_MAKE_JOBS} +COPY --from=stream-olympus-builder /out/ ${SB_MICRO_PATH}/bin/ +# Validate runtime linkage and require the Olympus binary on ARM64. +RUN f=${SB_MICRO_PATH}/bin/streamOlympus; \ + if [ "$TARGETARCH" = "arm64" ]; then \ + test -x "$f" || { echo "Missing required ARM64 STREAM binary: $f" >&2; exit 1; }; \ + fi; \ + if [ -e "$f" ]; then \ + output="$(ldd -r "$f" 2>&1)" || { printf '%s\n' "$output"; exit 1; }; \ + printf '%s\n' "$output"; \ + if printf '%s\n' "$output" | grep -Eq 'not found|undefined symbol'; then exit 1; fi; \ + fi + +# Keep the base image's setuptools version for NVIDIA ModelOpt compatibility. +RUN python3 -m pip install --upgrade setuptools==81.0.0 && \ + python3 -m pip install --no-cache-dir .[nvworker] && \ + make cppbuild && \ + make postinstall && \ + rm -rf .git diff --git a/docs/user-tutorial/benchmarks/micro-benchmarks.md b/docs/user-tutorial/benchmarks/micro-benchmarks.md index 4b385c10d..6001b3ad0 100644 --- a/docs/user-tutorial/benchmarks/micro-benchmarks.md +++ b/docs/user-tutorial/benchmarks/micro-benchmarks.md @@ -587,6 +587,17 @@ with topology distance of 2, 4, 6, respectively. Measures bandwidth and latency for various memcpy patterns across different links using copy engine or kernel copy methods, performed by [nvbandwidth](https://github.com/NVIDIA/nvbandwidth) +CUDA >=13.5 images use nvbandwidth v0.11.0. Bidirectional device-to-device tests retain the +unsuffixed metrics below as aliases for the first matrix, and additionally report +`_read1_*`, `_read2_*`, `_write1_*`, `_write2_*` and `_total_*` metrics as applicable, +including each matrix's `sum_bw`. GPU-local matrices report `_gpu[0-9]_bw` without +an artificial CPU axis. Bandwidth remains in GB/s and latency remains in ns. + +In v0.11.0, `device_local_copy_*` bandwidth counts both reads and writes (`2 * size`). +These values are not directly comparable to older one-way-byte-count baselines. +SuperBench's default buffer size remains 64 MiB, and the four custom batch cases still +copy equal-sized buffers concurrently on all GPUs and report each GPU separately. + #### Metrics | Metrics | Unit | Description | diff --git a/superbench/benchmarks/micro_benchmarks/nvbandwidth.py b/superbench/benchmarks/micro_benchmarks/nvbandwidth.py index 3ce83c206..48facb2ac 100644 --- a/superbench/benchmarks/micro_benchmarks/nvbandwidth.py +++ b/superbench/benchmarks/micro_benchmarks/nvbandwidth.py @@ -15,11 +15,15 @@ class NvBandwidthBenchmark(MicroBenchmarkWithInvoke): """The NV Bandwidth Test benchmark class.""" # Regular expressions for summary line and matrix header detection - re_block_start_pattern = re.compile(r'^Running\s+(.+)$') - re_matrix_header_line = re.compile(r'^(memcpy|memory latency)') + re_version_pattern = re.compile(r'^nvbandwidth Version:\s*v?(\d+)\.(\d+)', re.MULTILINE) + re_block_start_pattern = re.compile(r'^Running\s+(\w+)\.$') + re_matrix_header_line = re.compile(r'^(memcpy|memory latency|Device to Device Latency)\b', re.IGNORECASE) + re_matrix_axis_pattern = re.compile(r'\b(CPU|GPU)\((row|column)\)', re.IGNORECASE) + re_matrix_direction_pattern = re.compile(r'\b(Read[12]|Write[12]|Total) bandwidth\b', re.IGNORECASE) re_matrix_row_pattern = re.compile(r'^\s*\d') - re_summary_pattern = re.compile(r'SUM (\S+) (\d+\.\d+)') - re_unsupported_pattern = re.compile(r'ERROR: Testcase (\S+) not found!') + re_summary_pattern = re.compile(r'^SUM\s+(\S+)\s+([+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)$') + re_unsupported_pattern = re.compile(r'^(?:ERROR: Testcase (\S+) not found!|ERROR (\S+): Testcase \S+ not found!)$') + re_status_pattern = re.compile(r'^(Waived|Error)(?:\s+(\w+))?:\s*(.*)$', re.IGNORECASE) def __init__(self, name, parameters=''): """Constructor. @@ -109,17 +113,21 @@ def _preprocess(self): command += ' --testcase ' + ' '.join(self._args.test_cases) else: self._args.test_cases = self._get_all_test_cases() + if not self._args.test_cases: + logger.error('Cannot run nvbandwidth without discovered testcases.') + self._result.set_return_code(ReturnCode.MICROBENCHMARK_EXECUTION_FAILURE) + return False - if self._args.skip_verification: - command += ' --skipVerification' - - if self._args.disable_affinity: - command += ' --disableAffinity' - if self._args.numa is not None: - command = f'numactl --cpunodebind={self._args.numa} --membind={self._args.numa} ' + command + for enabled, flag in ( + (self._args.skip_verification, '--skipVerification'), + (self._args.disable_affinity, '--disableAffinity'), + (self._args.use_mean, '--useMean'), + ): + if enabled: + command += ' ' + flag - if self._args.use_mean: - command += ' --useMean' + if self._args.disable_affinity and self._args.numa is not None: + command = f'numactl --cpunodebind={self._args.numa} --membind={self._args.numa} ' + command if self._args.num_loops: command += f' --testSamples {self._args.num_loops}' @@ -128,6 +136,58 @@ def _preprocess(self): return True + def _process_matrix_line(self, line, parse_status): + """Parse a single-node matrix header or row without ending its enclosing testcase. + + Args: + line (str): Stripped output line. + parse_status (dict): Current testcase, matrix state and collected results. + """ + test_name = parse_status['test_name'] + if not test_name: + return + + if self.re_matrix_header_line.match(line): + axes = {axis.lower(): name.lower() for name, axis in self.re_matrix_axis_pattern.findall(line)} + direction_match = self.re_matrix_direction_pattern.search(line) + suffix = direction_match.group(1).lower() if direction_match else '' + parse_status['matrix_index'] += 1 + parse_status['matrix_name'] = test_name + ('_' + suffix if suffix else '') + parse_status['benchmark_type'] = 'bw' if 'bandwidth' in line.lower() else 'lat' + parse_status['matrix_header'] = [] + parse_status['metrix_row'] = axes.get('row', '') + parse_status['metrix_col'] = axes.get('column', '') + parse_status['matrix_has_values'] = False + expected = parse_status['testcase_matrices'][test_name] + if suffix: + direction = 'read' if '_read_' in test_name else 'write' + expected.update((f'{test_name}_{direction}1', f'{test_name}_{direction}2', f'{test_name}_total')) + else: + expected.add(test_name) + return + + if not parse_status['benchmark_type'] or not self.re_matrix_row_pattern.match(line): + return + + row_data = line.split() + if not parse_status['matrix_header']: + parse_status['matrix_header'] = row_data + return + + for col_index, value in enumerate(row_data[1:]): + if value == 'N/A': + continue + row_name = parse_status['metrix_row'] + col_name = parse_status['metrix_col'] + col_header = parse_status['matrix_header'][col_index] + row_metric = f'{row_name}{row_data[0]}_' if row_name else '' + metric = f'{row_metric}{col_name}{col_header}_{parse_status["benchmark_type"]}' + measurement = float(value) + parse_status['results'].setdefault(f'{parse_status["matrix_name"]}_{metric}', measurement) + if parse_status['matrix_index'] == 1: + parse_status['results'].setdefault(f'{test_name}_{metric}', measurement) + parse_status['matrix_has_values'] = True + def _process_raw_line(self, line, parse_status): """Process a raw line of text and update the parse status accordingly. @@ -141,68 +201,101 @@ def _process_raw_line(self, line, parse_status): """ line = line.strip() - # Detect unsupported test cases - if self.re_unsupported_pattern.match(line): - parse_status['unsupported_testcases'].add(self.re_unsupported_pattern.match(line).group(1).lower()) + unsupported = self.re_unsupported_pattern.match(line) + if unsupported: + parse_status['unsupported_testcases'].add((unsupported.group(1) or unsupported.group(2)).lower()) return - # Detect the start of a test - if self.re_block_start_pattern.match(line): - parse_status['test_name'] = self.re_block_start_pattern.match(line).group(1).lower()[:-1] - parse_status['excuted_testcases'].add(parse_status['test_name']) - return - - # Detect the start of matrix data - if parse_status['test_name'] and self.re_matrix_header_line.match(line): - parse_status['benchmark_type'] = 'bw' if 'bandwidth' in line else 'lat' - # Parse the row and column name - tmp_idx = line.find('(row)') - parse_status['metrix_row'] = line[tmp_idx - 3:tmp_idx].lower() - tmp_idx = line.find('(column)') - parse_status['metrix_col'] = line[tmp_idx - 3:tmp_idx].lower() - return - - # Parse the matrix header - if ( - parse_status['test_name'] and parse_status['benchmark_type'] and not parse_status['matrix_header'] - and self.re_matrix_row_pattern.match(line) - ): - parse_status['matrix_header'] = line.split() + running = self.re_block_start_pattern.match(line) + if running: + test_name = running.group(1).lower() + parse_status.update( + test_name=test_name, + matrix_name='', + matrix_index=0, + benchmark_type=None, + matrix_header=[], + matrix_has_values=False, + ) + parse_status['testcase_matrices'].setdefault(test_name, set()) return - # Parse matrix rows - if parse_status['test_name'] and parse_status['benchmark_type'] and self.re_matrix_row_pattern.match(line): - row_data = line.split() - row_index = row_data[0] - for col_index, value in enumerate(row_data[1:], start=1): - # Skip 'N/A' values, 'N/A' indicates the test path is self to self. - if value == 'N/A': - continue - - col_header = parse_status['matrix_header'][col_index - 1] - test_name = parse_status['test_name'] - benchmark_type = parse_status['benchmark_type'] - row_name = parse_status['metrix_row'] - col_name = parse_status['metrix_col'] - metric_name = f'{test_name}_{row_name}{row_index}_{col_name}{col_header}_{benchmark_type}' - parse_status['results'][metric_name] = float(value) + status = self.re_status_pattern.match(line) + if status: + state, named_test, message = status.groups() + test_name = (named_test or parse_status['test_name']).lower() + completed = bool( + parse_status['testcase_matrices'].get(test_name, set()) & parse_status['completed_matrices'] + ) + # Legacy output has anonymous, empty waivers between completed testcases. + legacy_waiver = ( + parse_status['legacy_waivers'] and state.lower() == 'waived' and not named_test and not message + and completed + ) + if not test_name or legacy_waiver: + return + status_key = 'waived_testcases' if state.lower() == 'waived' else 'failed_testcases' + parse_status[status_key][test_name] = message + parse_status.update(test_name='', matrix_name='', benchmark_type=None, matrix_header=[]) return - # Parse summary results - if self.re_summary_pattern.match(line): - value = self.re_summary_pattern.match(line).group(2) + summary = self.re_summary_pattern.match(line) + if summary: + if not parse_status['matrix_name']: + return + matrix_name, value = summary.groups() + matrix_name = matrix_name.lower() test_name = parse_status['test_name'] benchmark_type = parse_status['benchmark_type'] - parse_status['results'][f'{test_name}_sum_{benchmark_type}'] = float(value) - - # Reset parsing state for next test - parse_status['test_name'] = '' - parse_status['benchmark_type'] = None - parse_status['matrix_header'].clear() - parse_status['metrix_row'] = '' - parse_status['metrix_col'] = '' + if matrix_name != parse_status['matrix_name']: + parse_status['failed_testcases'][test_name] = f'Unexpected SUM identifier: {matrix_name}' + elif parse_status['matrix_has_values']: + parse_status['results'][f'{matrix_name}_sum_{benchmark_type}'] = float(value) + if parse_status['matrix_index'] == 1: + parse_status['results'].setdefault(f'{test_name}_sum_{benchmark_type}', float(value)) + parse_status['completed_matrices'].add(matrix_name) + # A SUM ends a matrix, not necessarily its enclosing testcase. + parse_status.update(matrix_name='', benchmark_type=None, matrix_header=[]) return + self._process_matrix_line(line, parse_status) + + def _get_testcase_return_code(self, parsing_status): + """Report unsupported, incomplete and failed testcases. + + Args: + parsing_status (dict): Parsed testcase outcomes and completed matrices. + + Return: + ReturnCode: Combined testcase status. + """ + return_code = ReturnCode.SUCCESS + for testcase in parsing_status['unsupported_testcases']: + logger.warning(f'Test case {testcase} is not supported.') + return_code = ReturnCode.INVALID_ARGUMENT + self._result.add_raw_data(testcase, 'Not supported', self._args.log_raw_data) + + # Running alone, or only one direction of a bidirectional test, is not success. + waived = set(parsing_status['waived_testcases']) + testcases = {name.lower() for name in self._args.test_cases} | set(parsing_status['testcase_matrices']) + for testcase in testcases: + expected = parsing_status['testcase_matrices'].get(testcase, set()) + if not expected or not expected <= parsing_status['completed_matrices']: + waived.add(testcase) + waived -= parsing_status['unsupported_testcases'] | set(parsing_status['failed_testcases']) + for testcase in waived: + reason = parsing_status['waived_testcases'].get(testcase) or 'No complete results' + logger.warning(f'Test case {testcase} was waived or incomplete: {reason}.') + self._result.add_raw_data(testcase, 'waived', self._args.log_raw_data) + return_code = ReturnCode.INVALID_ARGUMENT + + for testcase, message in parsing_status['failed_testcases'].items(): + logger.error(f'Test case {testcase} failed: {message}.') + self._result.add_raw_data(testcase, f'Error: {message}', self._args.log_raw_data) + return_code = ReturnCode.MICROBENCHMARK_EXECUTION_FAILURE + + return return_code + def _process_raw_result(self, cmd_idx, raw_output): """Function to parse raw results and save the summarized results. @@ -218,12 +311,20 @@ def _process_raw_result(self, cmd_idx, raw_output): try: self._result.add_raw_data('raw_output_' + str(cmd_idx), raw_output, self._args.log_raw_data) content = raw_output.splitlines() + version = self.re_version_pattern.search(raw_output) parsing_status = { 'results': {}, - 'excuted_testcases': set(), + 'legacy_waivers': bool(version and tuple(map(int, version.groups())) < (0, 11)), 'unsupported_testcases': set(), + 'waived_testcases': {}, + 'failed_testcases': {}, + 'testcase_matrices': {}, + 'completed_matrices': set(), 'benchmark_type': None, 'matrix_header': [], + 'matrix_name': '', + 'matrix_index': 0, + 'matrix_has_values': False, 'test_name': '', 'metrix_row': '', 'metrix_col': '', @@ -232,26 +333,11 @@ def _process_raw_result(self, cmd_idx, raw_output): for line in content: self._process_raw_line(line, parsing_status) - return_code = ReturnCode.SUCCESS - # Log unsupported test cases - for testcase in parsing_status['unsupported_testcases']: - logger.warning(f'Test case {testcase} is not supported.') - return_code = ReturnCode.INVALID_ARGUMENT - self._result.add_raw_data(testcase, 'Not supported', self._args.log_raw_data) - - # Check if the test case was waived - for testcase in self._args.test_cases: - if ( - testcase not in parsing_status['unsupported_testcases'] - and testcase not in parsing_status['excuted_testcases'] - ): - logger.warning(f'Test case {testcase} was waived.') - self._result.add_raw_data(testcase, 'waived', self._args.log_raw_data) - return_code = ReturnCode.INVALID_ARGUMENT + return_code = self._get_testcase_return_code(parsing_status) if not parsing_status['results']: self._result.add_raw_data('nvbandwidth', 'No valid results found', self._args.log_raw_data) - return_code = ReturnCode.MICROBENCHMARK_RESULT_PARSING_FAILURE + self._result.set_return_code(ReturnCode.MICROBENCHMARK_RESULT_PARSING_FAILURE) return False # Store parsed results @@ -267,6 +353,7 @@ def _process_raw_result(self, cmd_idx, raw_output): ) ) self._result.add_result('abort', 1) + self._result.set_return_code(ReturnCode.MICROBENCHMARK_RESULT_PARSING_FAILURE) return False def _get_all_test_cases(self): @@ -289,7 +376,10 @@ def _get_all_test_cases(self): return [] # Parse the output - return [name for _, name in test_case_pattern.findall(result.stdout)] + test_cases = [name for _, name in test_case_pattern.findall(result.stdout)] + if not test_cases: + logger.error(f'{command} returned no testcases.') + return test_cases except Exception as e: logger.error(f'Failed to get all test case names: {e}') return [] diff --git a/tests/benchmarks/micro_benchmarks/test_nvbandwidth.py b/tests/benchmarks/micro_benchmarks/test_nvbandwidth.py index a36c510a8..cae45af17 100644 --- a/tests/benchmarks/micro_benchmarks/test_nvbandwidth.py +++ b/tests/benchmarks/micro_benchmarks/test_nvbandwidth.py @@ -6,10 +6,12 @@ import os import unittest +from unittest import mock from tests.helper import decorator from tests.helper.testcase import BenchmarkTestCase from superbench.benchmarks import BenchmarkRegistry, ReturnCode, Platform +from superbench.benchmarks.micro_benchmarks import NvBandwidthBenchmark class TestNvBandwidthBenchmark(BenchmarkTestCase, unittest.TestCase): @@ -20,6 +22,14 @@ def setUpClass(cls): super().setUpClass() cls.createMockEnvs(cls) cls.createMockFiles(cls, ['bin/nvbandwidth']) + # Default discovery must return real case names, not an empty successful listing. + with open(os.path.join(cls._tmp_dir, 'bin/nvbandwidth'), 'w') as mock_binary: + mock_binary.write( + '#!/bin/sh\n' + 'printf "0, host_to_device_memcpy_ce:\\n' + '1, device_to_host_memcpy_ce:\\n' + '2, host_device_latency_sm:\\n"\n' + ) def test_nvbandwidth_preprocess(self): """Test NV Bandwidth benchmark preprocess.""" @@ -87,6 +97,153 @@ def test_nvbandwidth_result_parsing_real_output(self, results): assert benchmark.result['host_device_latency_sm_cpu0_gpu0_lat'][0] == 772.58 assert benchmark.result['host_device_latency_sm_sum_lat'][0] == 772.58 + @decorator.load_data('tests/data/nvbandwidth_v0.11.log') + def test_nvbandwidth_v011_single_node_output(self, results): + """Parse native directional, latency, local and custom batch matrices without losing legacy aliases.""" + test_cases = ( + 'device_to_device_bidirectional_memcpy_read_ce ' + 'device_to_device_bidirectional_memcpy_write_sm ' + 'device_to_device_latency_sm device_to_device_latency_tma ' + 'device_local_copy device_local_read_sm ' + 'all_to_host_batch_memcpy_ce host_to_all_batch_memcpy_ce ' + 'all_to_host_batch_memcpy_sm host_to_all_batch_memcpy_sm' + ) + benchmark = NvBandwidthBenchmark('nvbandwidth', parameters='--test_cases ' + test_cases) + assert benchmark._preprocess() + assert benchmark._process_raw_result(0, results) + assert benchmark.return_code == ReturnCode.SUCCESS + + for case, direction, values in ( + ('device_to_device_bidirectional_memcpy_read_ce', 'read', (41.0, 51.0, 92.0, 83.0, 103.0, 186.0)), + ('device_to_device_bidirectional_memcpy_write_sm', 'write', (61.0, 71.0, 132.0, 123.0, 143.0, 266.0)), + ): + with self.subTest(case=case): + assert benchmark.result[f'{case}_gpu0_gpu1_bw'] == [values[0]] + assert benchmark.result[f'{case}_sum_bw'] == [values[3]] + assert benchmark.result[f'{case}_{direction}1_gpu0_gpu1_bw'] == [values[0]] + assert benchmark.result[f'{case}_{direction}2_gpu0_gpu1_bw'] == [values[1]] + assert benchmark.result[f'{case}_total_gpu0_gpu1_bw'] == [values[2]] + assert benchmark.result[f'{case}_{direction}1_sum_bw'] == [values[3]] + assert benchmark.result[f'{case}_{direction}2_sum_bw'] == [values[4]] + assert benchmark.result[f'{case}_total_sum_bw'] == [values[5]] + assert f'{case}_gpu0_gpu0_bw' not in benchmark.result + + assert benchmark.result['device_to_device_latency_sm_gpu0_gpu1_lat'] == [154.25] + assert benchmark.result['device_to_device_latency_sm_sum_lat'] == [310.0] + assert benchmark.result['device_to_device_latency_tma_gpu0_gpu1_lat'] == [108.25] + assert benchmark.result['device_to_device_latency_tma_sum_lat'] == [218.5] + assert benchmark.result['device_local_copy_gpu0_bw'] == [12000.0] + assert benchmark.result['device_local_copy_gpu1_bw'] == [12500.0] + assert benchmark.result['device_local_copy_sum_bw'] == [24500.0] + assert benchmark.result['device_local_read_sm_gpu1_bw'] == [14000.0] + for case in test_cases.split()[-4:]: + assert benchmark.result[f'{case}_cpu0_gpu0_bw'] == [130.0] + assert benchmark.result[f'{case}_cpu0_gpu1_bw'] == [140.0] + assert benchmark.result[f'{case}_sum_bw'] == [270.0] + + def test_nvbandwidth_v011_matrix_lines(self): + """A new matrix resets its columns without overwriting the first matrix's legacy alias.""" + benchmark = NvBandwidthBenchmark('nvbandwidth') + case = 'device_to_device_bidirectional_memcpy_read_ce' + status = {'test_name': case, 'matrix_index': 0, 'testcase_matrices': {case: set()}, 'results': {}} + benchmark._process_matrix_line('memcpy CE GPU(row) <-> GPU(column) Read1 bandwidth (GB/s)', status) + benchmark._process_matrix_line('0 1', status) + benchmark._process_matrix_line('0 N/A 41.00', status) + benchmark._process_matrix_line('memcpy CE GPU(row) <-> GPU(column) Read2 bandwidth (GB/s)', status) + benchmark._process_matrix_line('0 1', status) + benchmark._process_matrix_line('0 N/A 51.00', status) + assert status['results'] == { + f'{case}_gpu0_gpu1_bw': 41.0, + f'{case}_read1_gpu0_gpu1_bw': 41.0, + f'{case}_read2_gpu0_gpu1_bw': 51.0, + } + + @decorator.load_data('tests/data/nvbandwidth_v0.11.log') + def test_nvbandwidth_v011_status_completeness(self, results): + """Keep valid measurements but fail unsupported, waived, failed and missing requested cases.""" + statuses = ( + ('ERROR missing_case: Testcase missing_case not found!', 'Not supported', ReturnCode.INVALID_ARGUMENT), + ('Waived missing_case: no accessible peers', 'waived', ReturnCode.INVALID_ARGUMENT), + ('Running missing_case.\nWaived: buffer not supported', 'waived', ReturnCode.INVALID_ARGUMENT), + ('Running missing_case.\nWaived:', 'waived', ReturnCode.INVALID_ARGUMENT), + ( + 'Running missing_case.\nError: verification failed', + 'Error: verification failed', + ReturnCode.MICROBENCHMARK_EXECUTION_FAILURE, + ), + ('Running missing_case.', 'waived', ReturnCode.INVALID_ARGUMENT), + ('', 'waived', ReturnCode.INVALID_ARGUMENT), + ) + for status, raw_status, return_code in statuses: + with self.subTest(status=status): + benchmark = NvBandwidthBenchmark('nvbandwidth', parameters='--test_cases missing_case') + assert benchmark._preprocess() + assert benchmark._process_raw_result(0, results + '\n' + status) + assert benchmark.return_code == return_code + assert benchmark._result.raw_data['missing_case'] == [raw_status] + assert benchmark.result['device_local_copy_gpu0_bw'] == [12000.0] + assert not any(metric.startswith('missing_case_') for metric in benchmark.result) + + empty_benchmark = NvBandwidthBenchmark('nvbandwidth', parameters='--test_cases missing_case') + assert empty_benchmark._preprocess() + assert not empty_benchmark._process_raw_result(0, status) + assert empty_benchmark.return_code != ReturnCode.SUCCESS + + # A late status must not be hidden by an earlier valid SUM for the same testcase. + for status, return_code in ( + ('Error: verification failed', ReturnCode.MICROBENCHMARK_EXECUTION_FAILURE), + ('Waived: buffer not supported', ReturnCode.INVALID_ARGUMENT), + ('Waived:', ReturnCode.INVALID_ARGUMENT), + ): + with self.subTest(late_status=status): + benchmark = NvBandwidthBenchmark('nvbandwidth', parameters='--test_cases host_to_all_batch_memcpy_sm') + assert benchmark._preprocess() + assert benchmark._process_raw_result(0, results + '\n' + status) + assert benchmark.return_code == return_code + assert benchmark.result['host_to_all_batch_memcpy_sm_sum_bw'] == [270.0] + + @decorator.load_data('tests/data/nvbandwidth_v0.11.log') + def test_nvbandwidth_v011_incomplete_matrices(self, results): + """A first bidirectional matrix is useful partial data, not a complete successful testcase.""" + case = 'device_to_device_bidirectional_memcpy_read_ce' + benchmark = NvBandwidthBenchmark('nvbandwidth', parameters='--test_cases ' + case) + assert benchmark._preprocess() + first_matrix = results.split('memcpy CE GPU(row) <-> GPU(column) Read2 bandwidth (GB/s)')[0] + assert benchmark._process_raw_result(0, first_matrix) + assert benchmark.return_code == ReturnCode.INVALID_ARGUMENT + assert benchmark.result[f'{case}_gpu0_gpu1_bw'] == [41.0] + assert benchmark.result[f'{case}_read1_sum_bw'] == [83.0] + assert f'{case}_read2_sum_bw' not in benchmark.result + assert f'{case}_total_sum_bw' not in benchmark.result + + # A native SUM of an all-N/A matrix is not a measured zero. + benchmark = NvBandwidthBenchmark('nvbandwidth', parameters='--test_cases device_to_device_memcpy_read_ce') + assert benchmark._preprocess() + raw_output = ( + 'Running device_to_device_memcpy_read_ce.\n' + 'memcpy CE GPU(row) -> GPU(column) bandwidth (GB/s)\n' + ' 0\n' + ' 0 N/A\n\n' + 'SUM device_to_device_memcpy_read_ce 0.00\n' + ) + assert not benchmark._process_raw_result(0, raw_output) + assert benchmark.return_code == ReturnCode.MICROBENCHMARK_RESULT_PARSING_FAILURE + assert set(benchmark.result) == {'return_code'} + + def test_nvbandwidth_preprocess_discovery_failure(self): + """Do not launch an untracked run when discovery fails or returns no testcases.""" + for return_code, stdout, stderr in ((0, '', ''), (0, 'Index, Name:\n', ''), (1, '', 'list failed')): + with self.subTest(return_code=return_code, stdout=stdout): + benchmark = NvBandwidthBenchmark('nvbandwidth', parameters='') + with mock.patch('subprocess.run') as mock_run: + mock_run.return_value.returncode = return_code + mock_run.return_value.stdout = stdout + mock_run.return_value.stderr = stderr + with self.assertLogs('superbench', level='ERROR'): + assert not benchmark._preprocess() + assert benchmark.return_code == ReturnCode.MICROBENCHMARK_EXECUTION_FAILURE + assert benchmark._commands == [] + def test_nvbandwidth_process_raw_result_unsupported_testcases(self): """Test NV Bandwidth benchmark result parsing with unsupported test cases.""" benchmark_name = 'nvbandwidth' @@ -152,7 +309,7 @@ def test_get_all_test_cases(self): assert benchmark._preprocess() # Mock subprocess.run for successful execution with valid output - with unittest.mock.patch('subprocess.run') as mock_run: + with mock.patch('subprocess.run') as mock_run: mock_run.return_value.returncode = 0 mock_run.return_value.stdout = ( '1, host_to_device_memcpy_ce:\n' @@ -163,7 +320,7 @@ def test_get_all_test_cases(self): assert test_cases == ['host_to_device_memcpy_ce', 'device_to_host_bidirectional_memcpy_ce'] # Mock subprocess.run for execution with non-zero return code - with unittest.mock.patch('subprocess.run') as mock_run: + with mock.patch('subprocess.run') as mock_run: mock_run.return_value.returncode = 1 mock_run.return_value.stdout = '' mock_run.return_value.stderr = 'Error' @@ -171,7 +328,7 @@ def test_get_all_test_cases(self): assert test_cases == [] # Mock subprocess.run for execution with error message in stderr - with unittest.mock.patch('subprocess.run') as mock_run: + with mock.patch('subprocess.run') as mock_run: mock_run.return_value.returncode = 0 mock_run.return_value.stdout = '' mock_run.return_value.stderr = 'Error' diff --git a/tests/data/nvbandwidth_v0.11.log b/tests/data/nvbandwidth_v0.11.log new file mode 100644 index 000000000..eaea235db --- /dev/null +++ b/tests/data/nvbandwidth_v0.11.log @@ -0,0 +1,106 @@ +nvbandwidth Version: v0.11.0 +Built from Git version: v0.11.0 + +Running device_to_device_bidirectional_memcpy_read_ce. +memcpy CE GPU(row) <-> GPU(column) Read1 bandwidth (GB/s) + 0 1 + 0 N/A 41.00 + 1 42.00 N/A + +SUM device_to_device_bidirectional_memcpy_read_ce_read1 83.00 +COEFFICIENT_OF_VARIATION device_to_device_bidirectional_memcpy_read_ce_read1 0.012345 + +memcpy CE GPU(row) <-> GPU(column) Read2 bandwidth (GB/s) + 0 1 + 0 N/A 51.00 + 1 52.00 N/A + +SUM device_to_device_bidirectional_memcpy_read_ce_read2 103.00 + +memcpy CE GPU(row) <-> GPU(column) Total bandwidth (GB/s) + 0 1 + 0 N/A 92.00 + 1 94.00 N/A + +SUM device_to_device_bidirectional_memcpy_read_ce_total 186.00 +COEFFICIENT_OF_VARIATION device_to_device_bidirectional_memcpy_read_ce_total 0.023456 + +Running device_to_device_bidirectional_memcpy_write_sm. +memcpy SM GPU(row) <-> GPU(column) Write1 bandwidth (GB/s) + 0 1 + 0 N/A 61.00 + 1 62.00 N/A + +SUM device_to_device_bidirectional_memcpy_write_sm_write1 123.00 + +memcpy SM GPU(row) <-> GPU(column) Write2 bandwidth (GB/s) + 0 1 + 0 N/A 71.00 + 1 72.00 N/A + +SUM device_to_device_bidirectional_memcpy_write_sm_write2 143.00 + +memcpy SM GPU(row) <-> GPU(column) Total bandwidth (GB/s) + 0 1 + 0 N/A 132.00 + 1 134.00 N/A + +SUM device_to_device_bidirectional_memcpy_write_sm_total 266.00 + +Running device_to_device_latency_sm. +Device to Device Latency SM GPU(row) <-> GPU(column) (ns) + 0 1 + 0 N/A 154.25 + 1 155.75 N/A + +SUM device_to_device_latency_sm 310.00 + +Running device_to_device_latency_tma. +Device to Device Latency TMA GPU(row) <-> GPU(column) (ns) + 0 1 + 0 N/A 108.25 + 1 110.25 N/A + +SUM device_to_device_latency_tma 218.50 + +Running device_local_copy. +memcpy CE local GPU(column) bandwidth (GB/s) + 0 1 + 0 12000.00 12500.00 + +SUM device_local_copy 24500.00 + +Running device_local_read_sm. +memcpy SM local GPU(column) read-only bandwidth (GB/s) + 0 1 + 0 13500.00 14000.00 + +SUM device_local_read_sm 27500.00 + +Running all_to_host_batch_memcpy_ce. +memcpy CE CPU(row) <- GPU(column) batch bandwidth (GB/s) + 0 1 + 0 130.00 140.00 + +SUM all_to_host_batch_memcpy_ce 270.00 + +Running host_to_all_batch_memcpy_ce. +memcpy CE CPU(row) -> GPU(column) batch bandwidth (GB/s) + 0 1 + 0 130.00 140.00 + +SUM host_to_all_batch_memcpy_ce 270.00 + +Running all_to_host_batch_memcpy_sm. +memcpy SM CPU(row) <- GPU(column) batch bandwidth (GB/s) + 0 1 + 0 130.00 140.00 + +SUM all_to_host_batch_memcpy_sm 270.00 + +Running host_to_all_batch_memcpy_sm. +memcpy SM CPU(row) -> GPU(column) batch bandwidth (GB/s) + 0 1 + 0 130.00 140.00 + +SUM host_to_all_batch_memcpy_sm 270.00 diff --git a/third_party/Makefile b/third_party/Makefile index 5dd73372c..01516bb12 100755 --- a/third_party/Makefile +++ b/third_party/Makefile @@ -39,9 +39,14 @@ sb_micro_path: mkdir -p $(SB_MICRO_PATH)/lib # Build cutlass. -# for cuda 12.9 and later Build from commit v3.9 (3.9 release commit) for blackwell support +# CUDA >=13.5 uses stable CUTLASS v4.8.1; keep older CUDA release selections below. cuda_cutlass: -ifeq ($(shell echo $(CUDA_VER)">=12.9" | bc -l), 1) +ifeq ($(shell printf '%s\n' "13.5" "$(CUDA_VER)" | sort -V | head -n1),13.5) + $(eval ARCHS := "100;103a;107a") + if [ -d cutlass ]; then rm -rf cutlass; fi + git clone --branch v4.8.1 --depth 1 https://github.com/NVIDIA/cutlass.git && \ + test "$$(git -C cutlass rev-parse HEAD)" = "2c85f497547eb441f0fe80bfb0fb2e6f9add1719" +else ifeq ($(shell echo $(CUDA_VER)">=12.9" | bc -l), 1) $(eval ARCHS := "100;103") ifeq ($(shell echo $(CUDA_VER)">=13.4" | bc -l), 1) $(eval ARCHS := "100;103;107") @@ -342,8 +347,21 @@ endif # Build nvbandwidth. nvbandwidth: sb_micro_path +ifeq ($(shell printf '%s\n' "13.5" "$(CUDA_VER)" | sort -V | head -n1),13.5) + if [ -d nvbandwidth ]; then rm -rf nvbandwidth; fi + git clone --branch v0.11.0 --depth 1 https://github.com/NVIDIA/nvbandwidth.git && \ + test "$$(git -C nvbandwidth rev-parse HEAD)" = "201eaf7f25eda954d08a7c4fed9d8325e3c32ddf" + cd ./nvbandwidth && \ + git apply ../nvbandwidth-0.11.0.patch && \ + cp ../nvbandwidth_testcases_0.11.0.h ./testcases_patched.h && \ + cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DMULTINODE=OFF \ + -DCMAKE_CUDA_ARCHITECTURES="100;103;107" && \ + cmake --build build --parallel $(NUM_MAKE_JOBS) + cp -v ./nvbandwidth/build/nvbandwidth $(SB_MICRO_PATH)/bin +else cd ./nvbandwidth && git apply ../nvbandwidth.patch && cp ../nvbandwidth_testcases_patched.h ./testcases_patched.h && cmake . && make && cd .. cp -v ./nvbandwidth/nvbandwidth $(SB_MICRO_PATH)/bin +endif # Build nvbench cuda_nvbench: sb_micro_path diff --git a/third_party/Megatron/requirements.txt b/third_party/Megatron/requirements.txt index a41efd476..a71226970 100644 --- a/third_party/Megatron/requirements.txt +++ b/third_party/Megatron/requirements.txt @@ -12,6 +12,6 @@ sentencepiece wandb einops typing_extensions==4.9.0; python_version < '3.12' -typing_extensions==4.12.2; python_version >= '3.12' +typing_extensions>=4.12.2; python_version >= '3.12' apex mpi4py diff --git a/third_party/nvbandwidth-0.11.0.patch b/third_party/nvbandwidth-0.11.0.patch new file mode 100644 index 000000000..2a7590a29 --- /dev/null +++ b/third_party/nvbandwidth-0.11.0.patch @@ -0,0 +1,40 @@ +diff --git a/nvbandwidth.cpp b/nvbandwidth.cpp +--- a/nvbandwidth.cpp ++++ b/nvbandwidth.cpp +@@ -36,6 +36,7 @@ + #include "nvbandwidth_version.h" + #include "output.h" + #include "testcase.h" ++#include "testcases_patched.h" + #include "test_settings.h" + #include "inline_common.h" + +@@ -79,6 +80,8 @@ std::vector createNodeTestcases() { + new AllToHostTransfer(CopyInitiator::CE), + new AllToHostBidirTransfer(CopyInitiator::CE), ++ new AllToHostBatchCE(), + new HostToAllTransfer(CopyInitiator::CE), + new HostToAllBidirTransfer(CopyInitiator::CE), ++ new HostToAllBatchCE(), + new AllToOneTransfer(CopyInitiator::CE, AccessType::Write), + new AllToOneTransfer(CopyInitiator::CE, AccessType::Read), +@@ -95,6 +98,8 @@ std::vector createNodeTestcases() { + new AllToHostTransfer(CopyInitiator::SM), + new AllToHostBidirTransfer(CopyInitiator::SM), ++ new AllToHostBatchSM(), + new HostToAllTransfer(CopyInitiator::SM), + new HostToAllBidirTransfer(CopyInitiator::SM), ++ new HostToAllBatchSM(), + new AllToOneTransfer(CopyInitiator::SM, AccessType::Write), + new AllToOneTransfer(CopyInitiator::SM, AccessType::Read), +diff --git a/testcase.h b/testcase.h +--- a/testcase.h ++++ b/testcase.h +@@ -524,6 +524,7 @@ class Testcase { + void allToOneHelper(unsigned long long size, MemcpyOperation &memcpyInstance, PeerValueMatrix &bandwidthValues); + void oneToAllHelper(unsigned long long size, MemcpyOperation &memcpyInstance, PeerValueMatrix &bandwidthValues); + void allHostHelper(unsigned long long size, MemcpyOperation &memcpyInstance, PeerValueMatrix &bandwidthValues, bool sourceIsHost); + void allHostBidirHelper(unsigned long long size, MemcpyOperation &memcpyInstance, PeerValueMatrix &bandwidthValues, bool sourceIsHost); ++ void allHostHelperBatch(unsigned long long size, MemcpyOperation &memcpyInstance, PeerValueMatrix &bandwidthValues, bool sourceIsHost); + + // Copy the operation's worst coefficient of variation onto the result diff --git a/third_party/nvbandwidth_testcases_0.11.0.h b/third_party/nvbandwidth_testcases_0.11.0.h new file mode 100644 index 000000000..81c10d49d --- /dev/null +++ b/third_party/nvbandwidth_testcases_0.11.0.h @@ -0,0 +1,109 @@ +// Copyright(c) Microsoft Corporation. +// Licensed under the MIT License. + +#pragma once + +#include +#include + +#include "common.h" +#include "inline_common.h" +#include "memcpy.h" +#include "output.h" +#include "testcase.h" + +// Inherit the native all-host filters, including the bounce-buffer CC waiver. +class AllToHostBatchCE : public AllToHostTransfer { + public: + AllToHostBatchCE() : AllToHostTransfer(CopyInitiator::CE) { + key = "all_to_host_batch_memcpy_ce"; + desc = "\tMeasures bandwidth of cuMemcpyAsync from all devices to host simultaneously.\n" + "\tAll devices perform memcpy operations concurrently with the same buffer size.\n" + "\tIndividual device bandwidths are measured and reported separately."; + } + void run(unsigned long long size, unsigned long long loopCount) override; +}; + +class HostToAllBatchCE : public HostToAllTransfer { + public: + HostToAllBatchCE() : HostToAllTransfer(CopyInitiator::CE) { + key = "host_to_all_batch_memcpy_ce"; + desc = "\tMeasures bandwidth of cuMemcpyAsync from host to all devices simultaneously.\n" + "\tAll devices perform memcpy operations concurrently with the same buffer size.\n" + "\tIndividual device bandwidths are measured and reported separately."; + } + void run(unsigned long long size, unsigned long long loopCount) override; +}; + +class AllToHostBatchSM : public AllToHostTransfer { + public: + AllToHostBatchSM() : AllToHostTransfer(CopyInitiator::SM) { + key = "all_to_host_batch_memcpy_sm"; + desc = "\tMeasures bandwidth of copy kernels from all devices to host simultaneously.\n" + "\tAll devices perform memcpy operations concurrently with the same buffer size.\n" + "\tIndividual device bandwidths are measured and reported separately."; + } + void run(unsigned long long size, unsigned long long loopCount) override; +}; + +class HostToAllBatchSM : public HostToAllTransfer { + public: + HostToAllBatchSM() : HostToAllTransfer(CopyInitiator::SM) { + key = "host_to_all_batch_memcpy_sm"; + desc = "\tMeasures bandwidth of copy kernels from host to all devices simultaneously.\n" + "\tAll devices perform memcpy operations concurrently with the same buffer size.\n" + "\tIndividual device bandwidths are measured and reported separately."; + } + void run(unsigned long long size, unsigned long long loopCount) override; +}; + +void Testcase::allHostHelperBatch(unsigned long long size, MemcpyOperation &memcpyInstance, + PeerValueMatrix &bandwidthValues, bool sourceIsHost) { + std::vector> hostBuffers; + std::vector> deviceBuffers; + std::vector allSrcBuffers; + std::vector allDstBuffers; + + // Keep an equal-sized buffer pair per GPU alive for one native concurrent operation. + for (int deviceId = 0; deviceId < deviceCount; deviceId++) { + hostBuffers.push_back(std::make_unique(size, deviceId)); + deviceBuffers.push_back(std::make_unique(size, deviceId)); + allSrcBuffers.push_back(sourceIsHost ? hostBuffers.back().get() : deviceBuffers.back().get()); + allDstBuffers.push_back(sourceIsHost ? deviceBuffers.back().get() : hostBuffers.back().get()); + } + + // Native dispatch owns verification, timing, sampling and per-copy bandwidth calculation. + std::vector deviceBandwidths = memcpyInstance.doMemcpyVector(allSrcBuffers, allDstBuffers); + for (int deviceId = 0; deviceId < deviceCount; deviceId++) { + bandwidthValues.value(0, deviceId) = deviceBandwidths[deviceId]; + } + recordStability(bandwidthValues, memcpyInstance); +} + +void AllToHostBatchCE::run(unsigned long long size, unsigned long long loopCount) { + PeerValueMatrix bandwidthValues(1, deviceCount, key); + MemcpyOperation memcpyInstance(loopCount, new MemcpyInitiatorCE(), PREFER_SRC_CONTEXT, MemcpyOperation::VECTOR_BW); + allHostHelperBatch(size, memcpyInstance, bandwidthValues, false); + output->addTestcaseResults(bandwidthValues, "memcpy CE CPU(row) <- GPU(column) batch bandwidth (GB/s)"); +} + +void HostToAllBatchCE::run(unsigned long long size, unsigned long long loopCount) { + PeerValueMatrix bandwidthValues(1, deviceCount, key); + MemcpyOperation memcpyInstance(loopCount, new MemcpyInitiatorCE(), PREFER_SRC_CONTEXT, MemcpyOperation::VECTOR_BW); + allHostHelperBatch(size, memcpyInstance, bandwidthValues, true); + output->addTestcaseResults(bandwidthValues, "memcpy CE CPU(row) -> GPU(column) batch bandwidth (GB/s)"); +} + +void AllToHostBatchSM::run(unsigned long long size, unsigned long long loopCount) { + PeerValueMatrix bandwidthValues(1, deviceCount, key); + MemcpyOperation memcpyInstance(loopCount, new MemcpyInitiatorSM(), PREFER_SRC_CONTEXT, MemcpyOperation::VECTOR_BW); + allHostHelperBatch(size, memcpyInstance, bandwidthValues, false); + output->addTestcaseResults(bandwidthValues, "memcpy SM CPU(row) <- GPU(column) batch bandwidth (GB/s)"); +} + +void HostToAllBatchSM::run(unsigned long long size, unsigned long long loopCount) { + PeerValueMatrix bandwidthValues(1, deviceCount, key); + MemcpyOperation memcpyInstance(loopCount, new MemcpyInitiatorSM(), PREFER_SRC_CONTEXT, MemcpyOperation::VECTOR_BW); + allHostHelperBatch(size, memcpyInstance, bandwidthValues, true); + output->addTestcaseResults(bandwidthValues, "memcpy SM CPU(row) -> GPU(column) batch bandwidth (GB/s)"); +}