Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 125 additions & 0 deletions benchmark/nixlbench/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<!--
SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

# NIXL Benchmark

A benchmarking tool for the NVIDIA Inference Xfer Library (NIXL) that uses ETCD for coordination.

## Features

- Benchmarks NIXL performance across different backends
- Supports multiple communication patterns
- Tests both CPU (DRAM) and GPU (VRAM) memory transfers
- Uses ETCD for worker coordination - ideal for containerized and cloud-native environments

## Building

### Prerequisites

- NIXL Library
- CUDA Toolkit
- GFlags
- ETCD C++ client (https://github.com/etcd-cpp-apiv3/etcd-cpp-apiv3)

### Building with Meson

Basic build:
```bash
# Configure build
meson setup build

# Build
cd build
meson compile

# Install (optional)
meson install
```

#### Custom Dependency Paths

If NIXL is installed in a non-standard location, you can specify the path:

```bash
# With custom NIXL path
meson setup /path/to/build/dir -Dnixl_path=/path/to/nixl/installation

# To view all meson project options
meson configure /path/to/build/dir
```

## Usage

### Basic Usage

```bash
# Run the benchmark with default settings
# using ETCD runtime and ETCD server
./nixlbench --etcd-endpoints http://etcd-server:2379 --backend UCX --initiator_seg_type VRAM
Comment thread
sb17v marked this conversation as resolved.
Resolved
```

### Command Line Options

```
--backend NAME # Communication backend [UCX, UCX_MO] (default: UCX)
--worker_type NAME # Worker to use to transfer data [nixl, nvshmem] (default: nixl)
--initiator_seg_type TYPE # Memory segment type for initiator [DRAM, VRAM] (default: DRAM)
--target_seg_type TYPE # Memory segment type for target [DRAM, VRAM] (default: DRAM)
--scheme NAME # Communication scheme [pairwise, manytoone, onetomany, tp] (default: pairwise)
--mode MODE # Process mode [SG (Single GPU per proc), MG (Multi GPU per proc)] (default: SG)
--op_type TYPE # Operation type [READ, WRITE] (default: WRITE)
--check_consistency # Enable consistency checking
--total_buffer_size SIZE # Total buffer size (default: 8GiB)
--start_block_size SIZE # Starting block size (default: 4KiB)
--max_block_size SIZE # Maximum block size (default: 64MiB)
--start_batch_size SIZE # Starting batch size (default: 1)
--max_batch_size SIZE # Maximum batch size (default: 1)
--num_iter NUM # Number of iterations (default: 1000)
--warmup_iter NUM # Number of warmup iterations (default: 100)
--num_threads NUM # Number of threads used by benchmark (default: 1)
--num_initiator_dev NUM # Number of devices in initiator processes (default: 1)
--num_target_dev NUM # Number of devices in target processes (default: 1)
--enable_pt # Enable progress thread
--device_list LIST # Comma-separated device names (default: all)
--runtime_type NAME # Type of runtime to use [ETCD] (default: ETCD)
--etcd-endpoints URL # ETCD server URL for coordination (default: http://localhost:2379)
```

### Using ETCD for Coordination

NIXL Benchmark uses an ETCD key-value store for coordination between benchmark workers. This is useful in containerized or cloud-native environments.

To run the benchmark:

1. Ensure ETCD server is running (e.g., `docker run -p 2379:2379 quay.io/coreos/etcd`
2. Launch multiple nixlbench instances pointing to the same ETCD server

Note: etcd can be installed directly on host as well:
```bash
apt install etcd-server
```

Example:
```bash
# On host 1
./nixlbench --runtime_type=ETCD --etcd-endpoints http://etcd-server:2379 --backend UCX --seg_type VRAM

# On host 2
./nixlbench --runtime_type=ETCD --etcd-endpoints http://etcd-server:2379 --backend UCX --seg_type VRAM
```

The workers automatically coordinate ranks through ETCD as they connect.
93 changes: 93 additions & 0 deletions benchmark/nixlbench/contrib/Dockerfile
Comment thread
sb17v marked this conversation as resolved.
Resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

ARG BASE_IMAGE="nvcr.io/nvidia/cuda-dl-base"
ARG BASE_IMAGE_TAG="25.03-cuda12.8-devel-ubuntu24.04"

FROM ${BASE_IMAGE}:${BASE_IMAGE_TAG}

ARG DEFAULT_PYTHON_VERSION="3.12"

RUN apt-get update -y && \
DEBIAN_FRONTEND=noninteractive apt-get -y install \
ninja-build \
pybind11-dev \
cmake \
libgflags-dev \
libgrpc-dev \
libgrpc++-dev \
libprotobuf-dev \
protobuf-compiler-grpc \
libcpprest-dev \
etcd-server \
etcd-client

WORKDIR /workspace
RUN git clone https://github.com/etcd-cpp-apiv3/etcd-cpp-apiv3.git &&\
cd etcd-cpp-apiv3 && mkdir build && cd build && \
cmake .. && make -j$(nproc) && make install

COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
COPY --from=nixl . /workspace/nixl
COPY --from=nixlbench . /workspace/nixlbench

WORKDIR /workspace/nixl

# LD_LIBRARY_PATH is needed for auditwheel to find libcuda.so.1
# Set incorrectly to `compat/lib` in cuda-dl-base image
ENV LD_LIBRARY_PATH=/usr/local/cuda/compat/lib.real:/usr/local/lib:$LD_LIBRARY_PATH

ENV VIRTUAL_ENV=/workspace/nixl/.venv
RUN uv venv $VIRTUAL_ENV --python $DEFAULT_PYTHON_VERSION && \
# pybind11 pip install needed for ubuntu 22.04
uv pip install --upgrade meson pybind11 patchelf

RUN rm -rf build && \
mkdir build && \
uv run meson setup build/ --prefix=/usr/local/nixl && \
cd build && \
ninja && \
ninja install

ENV NIXL_PLUGIN_DIR=/usr/local/nixl/lib/x86_64-linux-gnu/plugins
RUN echo "/usr/local/nixl/lib/x86_64-linux-gnu" > /etc/ld.so.conf.d/nixl.conf && \
echo "/usr/local/nixl/lib/x86_64-linux-gnu/plugins" >> /etc/ld.so.conf.d/nixl.conf && \
ldconfig

# Create the wheel
ARG WHL_PYTHON_VERSIONS="3.12"
ARG WHL_PLATFORM="manylinux_2_39_x86_64"
RUN IFS=',' read -ra PYTHON_VERSIONS <<< "$WHL_PYTHON_VERSIONS" && \
for PYTHON_VERSION in "${PYTHON_VERSIONS[@]}"; do \
uv build --wheel --out-dir /tmp/dist --python $PYTHON_VERSION; \
done
RUN uv pip install auditwheel && \
uv run auditwheel repair /tmp/dist/nixl-*cp31*.whl --plat $WHL_PLATFORM --wheel-dir /workspace/nixl/dist

RUN uv pip install dist/nixl-*cp${DEFAULT_PYTHON_VERSION//./}*.whl
Comment thread
sb17v marked this conversation as resolved.
Resolved

WORKDIR /workspace/nixlbench

RUN ls /usr/local/lib
RUN echo $LD_LIBRARY_PATH
RUN ldconfig

RUN ls -ll /workspace/nixlbench
RUN rm -rf build && \
mkdir build && \
uv run meson setup build -Dnixl_path=/usr/local/nixl/ && \
cd build && ninja

WORKDIR /workspace/nixlbench/build
171 changes: 171 additions & 0 deletions benchmark/nixlbench/contrib/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
#!/bin/bash

# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

SOURCE_DIR=$(dirname "$(readlink -f "$0")")
BUILD_CONTEXT=$(dirname "$(readlink -f "$SOURCE_DIR")")
BUILD_CONTEXT_ARGS=""
NIXL_BUILD_CONTEXT_ARGS=""
NIXL_BENCH_BUILD_CONTEXT_ARGS="--build-context nixlbench=$BUILD_CONTEXT/"
NIXL_SRC=""
DOCKER_FILE="${SOURCE_DIR}/Dockerfile"
commit_id=$(git rev-parse --short HEAD)

# Get latest TAG and add COMMIT_ID for dev
latest_tag=$(git describe --tags --abbrev=0 $(git rev-list --tags --max-count=1 main) | sed 's/^v//') || true
if [ -z ${latest_tag} ]; then
latest_tag="0.0.1"
echo "No git release tag found, setting to unknown version: ${latest_tag}"
fi

BASE_IMAGE=nvcr.io/nvidia/cuda-dl-base
BASE_IMAGE_TAG=25.03-cuda12.8-devel-ubuntu24.04
WHL_PLATFORM=manylinux_2_39_x86_64
WHL_PYTHON_VERSIONS="3.12"
OS="ubuntu24"

get_options() {
while :; do
case $1 in
-h | -\? | --help)
show_help
exit
;;
--base-image)
if [ "$2" ]; then
BASE_IMAGE="$2"
shift
else
missing_requirement $1
fi
;;
--base-image-tag)
if [ "$2" ]; then
BASE_IMAGE_TAG=$2
shift
else
missing_requirement $1
fi
;;
--nixl)
if [ "$2" ]; then
NIXL_BUILD_CONTEXT_ARGS="--build-context nixl=$2"
NIXL_SRC=$2
shift
else
missing_requirement $1
fi
;;
--nixlbench)
if [ "$2" ]; then
NIXL_BENCH_BUILD_CONTEXT_ARGS="--build-context nixlbench=$2"
commit_id=$(git --git-dir=$2/.git --work-tree=$2 rev-parse --short HEAD)
shift
else
missing_requirement $1
fi
;;
--no-cache)
NO_CACHE=" --no-cache"
;;
--python-versions)
if [ "$2" ]; then
WHL_PYTHON_VERSIONS=$2
shift
else
missing_requirement $1
fi
;;
--tag)
if [ "$2" ]; then
TAG="--tag $2"
shift
else
missing_requirement $1
fi
;;
--)
shift
break
;;
-?*)
error 'ERROR: Unknown option: ' $1
;;
?*)
error 'ERROR: Unknown option: ' $1
;;
*)
break
;;
esac
shift
done

if [ -z "$NIXL_BUILD_CONTEXT_ARGS" ]; then
error "ERROR: --nixl <path to nixl source> is required"
fi

BUILD_CONTEXT_ARGS="$NIXL_BUILD_CONTEXT_ARGS $NIXL_BENCH_BUILD_CONTEXT_ARGS"

VERSION=v$latest_tag.dev.$commit_id
if [ -z "$TAG" ]; then
TAG="--tag nixlbench:${VERSION}"
echo $TAG
fi
}

show_build_options() {
echo ""
echo "Building NIXLBench Image"
echo "NIXL Source: ${NIXL_SRC}"
echo "Image Tag: ${TAG}"
echo "Build Context: ${BUILD_CONTEXT}"
echo "Build Context Args: ${BUILD_CONTEXT_ARGS}"
echo "Base Image: ${BASE_IMAGE}:${BASE_IMAGE_TAG}"
echo "Python Versions for wheel build: ${WHL_PYTHON_VERSIONS}"
echo "Wheel Platform: ${WHL_PLATFORM}"
}

show_help() {
echo "usage: build.sh --nixl <path to nixl source>"
echo " [--base base image]"
echo " [--base-image-tag base image tag]"
echo " [--nixlbench path/to/nixlbench/source/dir]"
echo " [--no-cache disable docker build cache]"
echo " [--os [ubuntu24|ubuntu22] to select Ubuntu version]"
echo " [--python-versions python versions to build for, comma separated]"
echo " [--tag tag for image]"
exit 0
}

missing_requirement() {
error "ERROR: $1 requires an argument."
}

error() {
printf '%s %s\n' "$1" "$2" >&2
exit 1
}

get_options "$@"

BUILD_ARGS+=" --build-arg BASE_IMAGE=$BASE_IMAGE --build-arg BASE_IMAGE_TAG=$BASE_IMAGE_TAG"
BUILD_ARGS+=" --build-arg WHL_PYTHON_VERSIONS=$WHL_PYTHON_VERSIONS"
BUILD_ARGS+=" --build-arg WHL_PLATFORM=$WHL_PLATFORM"

show_build_options

docker build -f $DOCKER_FILE $BUILD_ARGS $TAG $NO_CACHE $BUILD_ARGS $BUILD_CONTEXT_ARGS $BUILD_CONTEXT --progress plain
Loading