DeepInfer/scripts/build_vendor.sh
whn09 d0f7e4f69c Neuron packaging: requirements-neuron.txt, build.sh support, Dockerfile, README
- requirements-neuron.txt: requirements.txt + dev deps without tilelang /
  tile-kernels (pure-torch drop-ins are vendored), torch 2.14 +
  torch-neuronx 2.14 from the Neuron repository.
- build_vendor.sh: nothing to build for neuron; setup.py drops tilelang /
  tile-kernels from install_requires on neuron.
- setup.py and get_platform(): an exported DEEPINFER_ACCELERATOR wins over
  device detection, so images build where no accelerator is visible.
- docker/neuron/Dockerfile (+ per-Dockerfile ignore): on the native PyTorch
  Neuron DLC public.ecr.aws/neuron/torch-neuronx:2.14.0-neuronx-py314-
  sdk2.33.0-ubuntu26.04; build.sh with TORCH_DEVICE_BACKEND_AUTOLOAD=0 and an
  import self-check in Neuron CPU mode.
- README: Trainium in supported hardware and a "DeepInfer on AWS Trainium"
  section (English + folded Chinese); the pip torch-neuronx wheel needs
  glibc >= 2.43, so on Ubuntu 24.04 layer the venv on the DLAMI env.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 14:57:51 +08:00

62 lines
1.9 KiB
Bash
Executable File

#!/bin/bash
set -e
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
VENDOR_DIR="${REPO_ROOT}/vendor"
case "${DEEPINFER_ACCELERATOR:-nvidia}" in
nvidia)
BUILD_TARGET=CUDA
PACKAGES=(DeepSelect FlashMLA DeepEP DeepGEMM)
INSTALL=(deep_select flash_mla deep_ep deep_gemm)
;;
ascend)
BUILD_TARGET=ASCEND
PACKAGES=(DeepSelect FlashMLA DeepEP-Ascend DeepGEMM-Ascend)
INSTALL=(deep_select flash_mla deep_ep deep_gemm)
;;
neuron)
# Neuron uses the pure-torch drop-ins vendored in deepinfer/neuron_ops/vendor; nothing to build.
echo "✅ Neuron: vendored kernel packages are pure torch (deepinfer/neuron_ops/vendor), nothing to build"
exit 0
;;
*)
echo "Unsupported DEEPINFER_ACCELERATOR: '${DEEPINFER_ACCELERATOR}' (expect nvidia, ascend or neuron)" >&2
exit 1
;;
esac
PLATFORM_TAG="${DEEPINFER_ACCELERATOR:-nvidia}-$(uname -m)"
WHEEL_DIR="${WHEEL_DIR:-${REPO_ROOT}/build/${PLATFORM_TAG}/vendor-wheels}"
GIT_REWRITE=(-c url."https://github.com/".insteadOf="git@github.com:")
echo "📥 Initializing submodules ..."
git -C "${REPO_ROOT}" "${GIT_REWRITE[@]}" submodule update --init
target_var() {
case "$1" in
DeepSelect) echo DEEP_SELECT_BUILD_TARGET_PLATFORM ;;
FlashMLA) echo FLASH_MLA_BUILD_TARGET_PLATFORM ;;
*) echo "" ;;
esac
}
mkdir -p "${WHEEL_DIR}"
for pkg in "${PACKAGES[@]}"; do
echo "🔧 Building ${pkg} (${BUILD_TARGET}) ..."
envs=()
var="$(target_var "${pkg}")"
[ -n "${var}" ] && envs+=("${var}=${BUILD_TARGET}")
[ "${pkg}" = DeepGEMM ] && envs+=(DG_FORCE_BUILD=1)
(
cd "${VENDOR_DIR}/${pkg}"
git "${GIT_REWRITE[@]}" submodule update --init --recursive
env "${envs[@]}" python setup.py bdist_wheel --dist-dir "${WHEEL_DIR}"
)
done
echo "📦 Installing wheels from ${WHEEL_DIR} ..."
python -m pip install --no-deps --no-index --find-links "${WHEEL_DIR}" "${INSTALL[@]}"
echo "✅ vendor operators installed"