[XPU] Upgrade XPU backend to PyTorch 2.14 (#42003)
Co-authored-by: Ashwini Rathi <arathi@habana.ai> Co-authored-by: Y <ashwini.rathi@intel.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Ashwini Rathi
Y
Claude Opus 4.7
parent
28621739fc
commit
8afe107c24
+12
-22
@@ -1,7 +1,7 @@
|
||||
# docker build -t sglang:xpu -f xpu.Dockerfile --build-arg http_proxy=${http_proxy} --build-arg https_proxy=${https_proxy} --build-arg no_proxy=${no_proxy} --no-cache .
|
||||
|
||||
# Use Intel deep learning essentials base image with Ubuntu 24.04
|
||||
FROM intel/deep-learning-essentials:2026.0.0-devel-ubuntu24.04
|
||||
FROM intel/deep-learning-essentials:2026.1.2-devel-ubuntu24.04
|
||||
|
||||
# Avoid interactive prompts during package install
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
@@ -17,15 +17,13 @@ ARG SG_LANG_KERNEL_REPO=https://github.com/sgl-project/sgl-kernel-xpu.git
|
||||
ARG SG_LANG_KERNEL_BRANCH=main
|
||||
# wheel: prebuilt sglang-kernel-xpu pinned in pyproject_xpu.toml; source: build SG_LANG_KERNEL_BRANCH.
|
||||
ARG SG_LANG_KERNEL_SOURCE=wheel
|
||||
# AOT target for source builds (bmg | cri); set explicitly since no GPU is visible during docker build.
|
||||
ARG SG_LANG_KERNEL_TARGET=bmg
|
||||
|
||||
USER root
|
||||
|
||||
# Pin Level-Zero UMD + IGC (rolling PPA once faulted libze on B580; see sgl-kernel-xpu#296).
|
||||
# Keep in lockstep with the host xe KMD; override via --build-arg.
|
||||
ARG COMPUTE_RUNTIME_VERSION=26.18.38308.1
|
||||
ARG IGC_VERSION=2.34.4+21428
|
||||
ARG COMPUTE_RUNTIME_VERSION=26.27.39122.11
|
||||
ARG IGC_VERSION=2.38.2+22051
|
||||
ARG GMM_VERSION=22.10.0
|
||||
|
||||
RUN apt-get update && apt-get install -y software-properties-common curl && \
|
||||
@@ -78,33 +76,25 @@ ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
||||
|
||||
WORKDIR /sgl-workspace
|
||||
|
||||
RUN pip install --no-cache-dir torch==2.13.0+xpu torchvision==0.28.0+xpu torchaudio==2.11.0+xpu --index-url https://download.pytorch.org/whl/xpu && \
|
||||
RUN pip install --no-cache-dir torch==2.14.0+xpu torchvision==0.29.0+xpu torchaudio==2.11.0+xpu --index-url https://download.pytorch.org/whl/xpu && \
|
||||
pip install --no-cache-dir msgspec blake3 py-cpuinfo compressed_tensors gguf partial_json_parser einops tabulate --root-user-action=ignore
|
||||
|
||||
# SG_LANG_KERNEL_SOURCE=source points the sglang-kernel-xpu dependency at the kernel repo.
|
||||
RUN echo "Cloning ${SG_LANG_BRANCH} from ${SG_LANG_REPO}" && \
|
||||
git clone --branch ${SG_LANG_BRANCH} --single-branch ${SG_LANG_REPO} sglang && \
|
||||
git -C sglang fetch --tags --force origin && \
|
||||
cd sglang && cd python && \
|
||||
if [ "${SG_LANG_KERNEL_SOURCE}" = "source" ]; then \
|
||||
echo "Building sgl-kernel-xpu ${SG_LANG_KERNEL_BRANCH} from ${SG_LANG_KERNEL_REPO}" && \
|
||||
sed -i -E "s|\"sglang-kernel-xpu @ [^\"]*\"|\"sglang-kernel-xpu @ git+${SG_LANG_KERNEL_REPO}@${SG_LANG_KERNEL_BRANCH}\"|" pyproject_xpu.toml && \
|
||||
grep -q "sglang-kernel-xpu @ git+" pyproject_xpu.toml; \
|
||||
elif [ "${SG_LANG_KERNEL_SOURCE}" != "wheel" ]; then \
|
||||
echo "Invalid SG_LANG_KERNEL_SOURCE=${SG_LANG_KERNEL_SOURCE} (expected wheel or source)" && exit 1; \
|
||||
fi && \
|
||||
cp pyproject_xpu.toml pyproject.toml && \
|
||||
pip install --no-cache-dir ".[dev,diffusion]" --extra-index-url https://download.pytorch.org/whl/xpu && \
|
||||
pip install --no-cache-dir --no-deps xgrammar==0.1.33
|
||||
|
||||
# Optionally replace the prebuilt kernel wheel with a source build. --no-build-isolation
|
||||
# so CMake finds the installed torch; build/ is removed to keep the image small.
|
||||
RUN if [ "${SG_LANG_KERNEL_SOURCE}" = "source" ]; then \
|
||||
echo "Building sgl-kernel-xpu ${SG_LANG_KERNEL_BRANCH} from ${SG_LANG_KERNEL_REPO} for ${SG_LANG_KERNEL_TARGET}" && \
|
||||
git clone ${SG_LANG_KERNEL_REPO} sgl-kernel-xpu && \
|
||||
git -C sgl-kernel-xpu checkout ${SG_LANG_KERNEL_BRANCH} && \
|
||||
git -C sgl-kernel-xpu log -1 --format='sgl-kernel-xpu commit: %H %s' && \
|
||||
pip install --no-cache-dir "scikit-build-core>=0.10" wheel cmake ninja && \
|
||||
pip install -v --no-cache-dir --no-build-isolation --no-deps --force-reinstall \
|
||||
--config-settings=cmake.define.DPCPP_SYCL_TARGET=${SG_LANG_KERNEL_TARGET} \
|
||||
./sgl-kernel-xpu && \
|
||||
rm -rf sgl-kernel-xpu/build; \
|
||||
elif [ "${SG_LANG_KERNEL_SOURCE}" != "wheel" ]; then \
|
||||
echo "Invalid SG_LANG_KERNEL_SOURCE=${SG_LANG_KERNEL_SOURCE} (expected wheel or source)" && exit 1; \
|
||||
fi
|
||||
|
||||
# Install torch_memory_saver for release/resume_memory_occupation ("memory saver").
|
||||
# XPU ships no prebuilt wheel: it is built from source against the local oneAPI +
|
||||
# torch-XPU runtime (the .so links libsycl.so.<N>, which must match the installed
|
||||
|
||||
@@ -36,7 +36,7 @@ conda create -n sgl-xpu python=3.12 -y
|
||||
conda activate sgl-xpu
|
||||
|
||||
# Set PyTorch XPU as primary pip install channel to avoid installing the larger CUDA-enabled version and prevent potential runtime issues.
|
||||
pip3 install torch==2.13.0+xpu torchvision==0.28.0+xpu torchaudio==2.11.0+xpu --index-url https://download.pytorch.org/whl/xpu
|
||||
pip3 install torch==2.14.0+xpu torchvision==0.29.0+xpu torchaudio==2.11.0+xpu --index-url https://download.pytorch.org/whl/xpu
|
||||
pip3 install xgrammar==0.1.33 --no-deps # xgrammar will introduce CUDA-enabled triton which might conflict with XPU
|
||||
|
||||
# Clone the SGLang code
|
||||
@@ -49,7 +49,7 @@ cd python
|
||||
cp pyproject_xpu.toml pyproject.toml
|
||||
# Install SGLang dependent libs, and build SGLang main package
|
||||
pip install --upgrade pip setuptools
|
||||
pip install -v . --extra-index-url https://download.pytorch.org/whl/xpu
|
||||
pip install -v ".[dev,diffusion]" --extra-index-url https://download.pytorch.org/whl/xpu
|
||||
```
|
||||
|
||||
### Install Using Docker
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[build-system]
|
||||
requires = ["setuptools>=61.0", "setuptools-rust>=1.10", "setuptools-scm>=8.0", "torch==2.13.0+xpu", "wheel"]
|
||||
requires = ["setuptools>=61.0", "setuptools-rust>=1.10", "setuptools-scm>=8.0", "torch==2.14.0+xpu", "wheel"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
@@ -56,15 +56,15 @@ dependencies = [
|
||||
"scipy",
|
||||
"sentencepiece==0.2.1", # 0.2.2 rejects null pieces in InternVL tokenizers.
|
||||
"setproctitle",
|
||||
"sglang-kernel-xpu @ https://github.com/sgl-project/whl/releases/download/v0.3.0+xpu/sglang_kernel_xpu-0.3.0-cp310-abi3-manylinux_2_38_x86_64.whl",
|
||||
"sglang-kernel-xpu @ https://github.com/sgl-project/whl/releases/download/v0.4.0+xpu/sglang_kernel_xpu-0.4.0-cp310-abi3-manylinux_2_38_x86_64.whl",
|
||||
"smg-grpc-servicer>=0.9.0",
|
||||
"soundfile==0.13.1",
|
||||
"tiktoken",
|
||||
"timm==1.0.16",
|
||||
"torch==2.13.0+xpu",
|
||||
"torch==2.14.0+xpu",
|
||||
"torchaudio==2.11.0+xpu",
|
||||
"torchcodec==0.13.0 ; sys_platform != 'linux' or (sys_platform == 'linux' and platform_machine != 'aarch64' and platform_machine != 'arm64' and platform_machine != 'armv7l')", # torch==2.13.0 on XPU uses torchcodec 0.13.0
|
||||
"torchvision==0.28.0+xpu",
|
||||
"torchcodec==0.17.0 ; sys_platform != 'linux' or (sys_platform == 'linux' and platform_machine != 'aarch64' and platform_machine != 'arm64' and platform_machine != 'armv7l')", # torch==2.14.0 on XPU uses torchcodec 0.17.0
|
||||
"torchvision==0.29.0+xpu",
|
||||
"tqdm",
|
||||
"transformers==5.19.0",
|
||||
"uvicorn",
|
||||
|
||||
Reference in New Issue
Block a user