From 9fea20a078c1458ab460c6be0f692b462d71fba5 Mon Sep 17 00:00:00 2001 From: Yao Matrix Date: Wed, 27 May 2026 19:58:09 -0700 Subject: [PATCH] update XPU Dockerfile (#25174) Signed-off-by: Matrix Yao Co-authored-by: MingxuZh <109504044+MingxuZh@users.noreply.github.com> Co-authored-by: Ma Mingfei --- .github/workflows/pr-test-xpu.yml | 20 +++++----- docker/xpu.Dockerfile | 65 ++++++++++--------------------- 2 files changed, 30 insertions(+), 55 deletions(-) diff --git a/.github/workflows/pr-test-xpu.yml b/.github/workflows/pr-test-xpu.yml index 22dac03fc..6e38f9a2b 100644 --- a/.github/workflows/pr-test-xpu.yml +++ b/.github/workflows/pr-test-xpu.yml @@ -108,16 +108,16 @@ jobs: timeout-minutes: 20 run: | cid="${{ steps.start_container.outputs.container_id }}" - docker exec "$cid" /home/sdp/miniforge3/envs/py3.12/bin/python3 -m pip install --upgrade pip - docker exec "$cid" /home/sdp/miniforge3/envs/py3.12/bin/python3 -m pip install pytest expecttest ray huggingface_hub tabulate - docker exec "$cid" /home/sdp/miniforge3/envs/py3.12/bin/python3 -m pip uninstall -y flashinfer-python - docker exec "$cid" /bin/bash -c '/home/sdp/miniforge3/envs/py3.12/bin/hf auth login --token ${HF_TOKEN} ' + docker exec "$cid" /opt/venv/bin/python3 -m pip install --upgrade pip + docker exec "$cid" /opt/venv/bin/python3 -m pip install pytest expecttest ray huggingface_hub tabulate + docker exec "$cid" /opt/venv/bin/python3 -m pip uninstall -y flashinfer-python + docker exec "$cid" /bin/bash -c '/opt/venv/bin/hf auth login --token ${HF_TOKEN} ' - name: Run stage-a tests timeout-minutes: 30 run: | cid="${{ steps.start_container.outputs.container_id }}" - docker exec "$cid" bash -c "source /home/sdp/miniforge3/bin/activate && conda activate py3.12 && cd /home/sdp/sglang/test && python3 run_suite.py --hw xpu --suite stage-a-test-1-gpu-xpu" + docker exec "$cid" bash -c "source /opt/venv/bin/activate && cd /sgl-workspace/sglang/test && python3 run_suite.py --hw xpu --suite stage-a-test-1-gpu-xpu" - name: Cleanup container if: always() @@ -172,16 +172,16 @@ jobs: timeout-minutes: 20 run: | cid="${{ steps.start_container.outputs.container_id }}" - docker exec "$cid" /home/sdp/miniforge3/envs/py3.12/bin/python3 -m pip install --upgrade pip - docker exec "$cid" /home/sdp/miniforge3/envs/py3.12/bin/python3 -m pip install pytest expecttest ray huggingface_hub tabulate - docker exec "$cid" /home/sdp/miniforge3/envs/py3.12/bin/python3 -m pip uninstall -y flashinfer-python - docker exec "$cid" /bin/bash -c '/home/sdp/miniforge3/envs/py3.12/bin/hf auth login --token ${HF_TOKEN} ' + docker exec "$cid" /opt/venv/bin/python3 -m pip install --upgrade pip + docker exec "$cid" /opt/venv/bin/python3 -m pip install pytest expecttest ray huggingface_hub tabulate + docker exec "$cid" /opt/venv/bin/python3 -m pip uninstall -y flashinfer-python + docker exec "$cid" /bin/bash -c '/opt/venv/bin/hf auth login --token ${HF_TOKEN} ' - name: Run stage-b tests timeout-minutes: 60 run: | cid="${{ steps.start_container.outputs.container_id }}" - docker exec "$cid" bash -c "source /home/sdp/miniforge3/bin/activate && conda activate py3.12 && cd /home/sdp/sglang/test && python3 run_suite.py --hw xpu --suite stage-b-test-1-gpu-xpu" + docker exec "$cid" bash -c "source /opt/venv/bin/activate && cd /sgl-workspace/sglang/test && python3 run_suite.py --hw xpu --suite stage-b-test-1-gpu-xpu" - name: Cleanup container if: always() diff --git a/docker/xpu.Dockerfile b/docker/xpu.Dockerfile index 832df26f3..b4dbd2f09 100644 --- a/docker/xpu.Dockerfile +++ b/docker/xpu.Dockerfile @@ -1,6 +1,4 @@ -# If the device is Battlemage, we need to set UBUNTU_VERSION to 24.10 - -# Usage: docker build --build-arg UBUNTU_VERSION=24.04 --build-arg PYTHON_VERSION=3.10 -t sglang:xpu_kernel -f xpu.Dockerfile --no-cache . +# 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:2025.3.2-0-devel-ubuntu24.04 @@ -17,9 +15,6 @@ ARG SG_LANG_BRANCH=main ARG SG_LANG_KERNEL_REPO=https://github.com/sgl-project/sgl-kernel-xpu.git ARG SG_LANG_KERNEL_BRANCH=main -RUN useradd -m -d /home/sdp -s /bin/bash sdp && \ - chown -R sdp:sdp /home/sdp - USER root # Install the latest UMD driver for SYCL-TLA @@ -32,50 +27,30 @@ RUN apt-get update && apt-get install -y software-properties-common && \ libze-dev intel-ocloc && \ rm -rf /var/lib/apt/lists/* -# Switch to non-root user 'sdp' -USER sdp -# Set HOME and WORKDIR to user's home directory -ENV HOME=/home/sdp -WORKDIR /home/sdp +RUN apt-get update && apt-get install -y \ + python3-dev \ + build-essential \ + && rm -rf /var/lib/apt/lists/* -RUN curl -fsSL -v -o miniforge.sh -O https://github.com/conda-forge/miniforge/releases/download/25.1.1-0/Miniforge3-Linux-x86_64.sh && \ - bash miniforge.sh -b -p ./miniforge3 && \ - rm miniforge.sh && \ - # Initialize conda environment and install pip - . ./miniforge3/bin/activate && \ - conda create -y -n py${PYTHON_VERSION} python=${PYTHON_VERSION} && \ - conda activate py${PYTHON_VERSION} && \ - conda install pip && \ - # Append environment activation to .bashrc for interactive shells - echo ". /home/sdp/miniforge3/bin/activate; conda activate py${PYTHON_VERSION}; . /opt/intel/oneapi/setvars.sh; cd /home/sdp" >> /home/sdp/.bashrc +RUN curl -LsSf https://astral.sh/uv/install.sh | sh +ENV PATH="/root/.local/bin:$PATH" +ENV VIRTUAL_ENV="/opt/venv" +ENV UV_PYTHON_INSTALL_DIR=/opt/uv/python +RUN uv venv --python ${PYTHON_VERSION} --seed ${VIRTUAL_ENV} +ENV PATH="$VIRTUAL_ENV/bin:$PATH" -RUN --mount=type=secret,id=github_token \ - cd /home/sdp && \ - . /home/sdp/miniforge3/bin/activate && \ - conda activate py${PYTHON_VERSION} && \ - conda install libsqlite=3.48.0 -y && \ - pip install msgspec blake3 py-cpuinfo compressed_tensors gguf partial_json_parser einops tabulate --root-user-action=ignore && \ - pip3 install torch==2.11.0+xpu torchao torchvision torchaudio==2.11.0+xpu --index-url https://download.pytorch.org/whl/xpu +WORKDIR /sgl-workspace -RUN --mount=type=secret,id=github_token \ - cd /home/sdp && \ - . /home/sdp/miniforge3/bin/activate && \ - conda activate py${PYTHON_VERSION} && \ - echo "Cloning ${SG_LANG_BRANCH} from ${SG_LANG_REPO}" && \ +RUN pip install --no-cache-dir msgspec blake3 py-cpuinfo compressed_tensors gguf partial_json_parser einops tabulate --root-user-action=ignore && \ + pip install --no-cache-dir torch==2.11.0+xpu torchao torchvision torchaudio==2.11.0+xpu --index-url https://download.pytorch.org/whl/xpu + +RUN echo "Cloning ${SG_LANG_BRANCH} from ${SG_LANG_REPO}" && \ git clone --branch ${SG_LANG_BRANCH} --single-branch ${SG_LANG_REPO} sglang && \ cd sglang && cd python && \ cp pyproject_xpu.toml pyproject.toml && \ - pip install . --extra-index-url https://download.pytorch.org/whl/xpu && \ - pip install --no-deps xgrammar==0.1.33 && \ - pip install apache-tvm-ffi && \ - pip install triton-xpu==3.7.1 --index-url https://download.pytorch.org/whl/xpu --force-reinstall && \ - # Add environment setup commands to .bashrc again (in case it was overwritten) - echo ". /home/sdp/miniforge3/bin/activate; conda activate py${PYTHON_VERSION}; cd /home/sdp" >> /home/sdp/.bashrc + pip install --no-cache-dir . --extra-index-url https://download.pytorch.org/whl/xpu && \ + pip install --no-cache-dir --no-deps xgrammar==0.1.33 && \ + pip install triton-xpu==3.7.1 --index-url https://download.pytorch.org/whl/test/xpu --force-reinstall -# Use bash as default shell with initialization from .bashrc -SHELL ["bash", "-c"] - -# Start an interactive bash shell with all environment set up -USER sdp -CMD ["bash", "-c", "source /home/sdp/.bashrc && exec bash"] +CMD ["bash", "-c", "source /opt/intel/oneapi/setvars.sh --force && exec bash"]