Files
DeepInfer/build.sh
T
shunyadandClaude Opus 5.5 fe13eb0251 fix(build): check the SM120 NCCL pin after installing it
build.sh builds DeepEP against NCCL 2.32.3 and then replaces NCCL with 2.30.7
for Cake. deepinfer imports deep_ep on every platform, so if that build no
longer loaded with 2.30.7 every SM120 run would fail at import, with nothing
pointing at the NCCL swap; and if torch loaded another libnccl.so.2, auto
would quietly pick the slower nccl backend.

- scripts/check_sm120_nccl.py runs after the pin: it fails the build when
  deep_ep has an undefined symbol under the pinned NCCL, and warns when it
  cannot import deep_ep for another reason (e.g. no GPU on the build host)
  or when torch loads an NCCL other than the pin.
- The pin is CAKE_NCCL_VERSION in build.sh; tests/test_build_nccl_pin.py
  keeps it equal to sm120_support.CAKE_NCCL_VERSION and covers the check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 22:46:30 -08:00

64 lines
2.5 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
case "${DEEPINFER_ACCELERATOR:-}" in
nvidia|ascend) ;;
*)
echo "Usage: DEEPINFER_ACCELERATOR=nvidia|ascend $0" >&2
exit 1
;;
esac
REQUIREMENTS="requirements-${DEEPINFER_ACCELERATOR}.txt"
SM120=0
if [ "${DEEPINFER_ACCELERATOR}" = nvidia ]; then
# A separate assignment so that a detection failure stops the build (set -e) before any pip install;
# exported so build_vendor.sh builds for the same family.
NVIDIA_ARCH="$(bash ./scripts/nvidia_arch.sh)"
export DEEPINFER_NVIDIA_ARCH="${NVIDIA_ARCH}"
fi
if [ "${NVIDIA_ARCH:-}" = sm120 ]; then
REQUIREMENTS=requirements-nvidia-sm120.txt
SM120=1
# FlashInfer is built from source: skip its optional EP backends and its build-time pip installs.
export BUILD_NVEP=0 FLASHINFER_BUILD_NO_PIP=1
fi
# Install other Python dependencies
pip install -r "${REQUIREMENTS}"
if [ "${SM120}" = 1 ]; then
# The pinned FlashInfer commit reports the same version as a release, so pip keeps an installed
# build of another commit; reinstall unless the pinned commit is already installed.
FLASHINFER_REQUIREMENT="$(grep -E '^flashinfer-python' "${REQUIREMENTS}")"
if [ "$(python -c 'import flashinfer; print(flashinfer.__git_commit__)' 2>/dev/null)" != "${FLASHINFER_REQUIREMENT##*@}" ]; then
pip install --no-deps --force-reinstall "${FLASHINFER_REQUIREMENT}"
fi
fi
if [ "${DEEPINFER_ACCELERATOR}" = nvidia ]; then
# Patch NCCL to 2.32.3
pip install --no-deps --force-reinstall nvidia-nccl-cu13==2.32.3
fi
# Build and install vendored dependencies
bash ./scripts/build_vendor.sh
if [ "${SM120}" = 1 ]; then
# FlashInfer's Cake MegaMoE (DEEPINFER_SM120_EP_BACKEND=cake, which the default auto picks with this NCCL) compiles
# NCCL's Device API into its kernel and requires exactly this NCCL in the process (2.32.3 spills its registers).
# Keep it equal to deepinfer/sm120_support.py CAKE_NCCL_VERSION (tests/test_build_nccl_pin.py checks).
# DeepEP needs NCCL 2.31 or newer to build and to create its EPBuffer, so it is built above against 2.32.3 and only
# imported on SM120: its backend (deepep) is unavailable here, and nccl remains the fallback.
CAKE_NCCL_VERSION=2.30.7
pip install --no-deps --force-reinstall "nvidia-nccl-cu13==${CAKE_NCCL_VERSION}"
# Fails if deep_ep (built against 2.32.3) no longer imports; warns if torch loads another NCCL
python scripts/check_sm120_nccl.py "${CAKE_NCCL_VERSION}"
fi
# Build DeepInfer
bash ./scripts/build.sh build
echo "✅ DeepInfer is successfully built"