Repository navigation
NIXLBench: Initial squashed commit for NIXLBench #194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| ``` | ||
|
|
||
| ### 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. | ||
|
sb17v marked this conversation as resolved.
Resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.