[CPU] Apply uv as package manager (#14106)

This commit is contained in:
Zaili Wang
2025-11-29 02:36:53 +08:00
committed by GitHub
parent 841eb29d3d
commit 0b0b2607ca
4 changed files with 44 additions and 24 deletions

View File

@@ -207,7 +207,7 @@
"can_tag_run_ci_label": true,
"can_rerun_failed_ci": true,
"cooldown_interval_minutes": 0,
"reason": "top contributor"
"reason": "custom override"
},
"ZhengdQin": {
"can_tag_run_ci_label": true,
@@ -230,7 +230,7 @@
"airMeng": {
"can_tag_run_ci_label": true,
"can_rerun_failed_ci": true,
"cooldown_interval_minutes": 60,
"cooldown_interval_minutes": 0,
"reason": "custom override"
},
"alisonshao": {

View File

@@ -80,13 +80,13 @@ jobs:
timeout-minutes: 5
run: |
docker exec -w /sglang-checkout/ ci_sglang_xeon \
bash -c "python3 -c 'import torch; import sgl_kernel; assert torch._C._cpu._is_amx_tile_supported(); assert hasattr(torch.ops.sgl_kernel, \"convert_weight_packed\"); '"
bash -c "source /opt/.venv/bin/activate && python3 -c 'import torch; import sgl_kernel; assert torch._C._cpu._is_amx_tile_supported(); assert hasattr(torch.ops.sgl_kernel, \"convert_weight_packed\"); '"
- name: Run unit tests
timeout-minutes: 36
run: |
docker exec -w /sglang-checkout/ ci_sglang_xeon \
bash -c "cd ./test/srt && python3 run_suite.py --suite per-commit-cpu --timeout-per-file 1500"
bash -c "source /opt/.venv/bin/activate && cd ./test/srt && python3 run_suite.py --suite per-commit-cpu --timeout-per-file 1500"
- name: Change permission
timeout-minutes: 2

View File

@@ -18,35 +18,39 @@ RUN apt-get update && \
vim \
gcc \
g++ \
make
make \
libsqlite3-dev \
google-perftools \
libtbb-dev \
libnuma-dev \
numactl
WORKDIR /opt
RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \
source $HOME/.local/bin/env && \
uv venv --python 3.12
RUN echo -e '[[index]]\nname = "torch"\nurl = "https://download.pytorch.org/whl/cpu"\n\n[[index]]\nname = "torchvision"\nurl = "https://download.pytorch.org/whl/cpu"\n\n[[index]]\nname = "triton"\nurl = "https://download.pytorch.org/whl/cpu"' > .venv/uv.toml
ENV UV_CONFIG_FILE=/opt/.venv/uv.toml
WORKDIR /sgl-workspace
RUN curl -fsSL -o miniforge.sh -O https://github.com/conda-forge/miniforge/releases/download/25.3.1-0/Miniforge3-25.3.1-0-Linux-x86_64.sh && \
bash miniforge.sh -b -p ./miniforge3 && \
rm -f miniforge.sh && \
. miniforge3/bin/activate && \
conda install -y libsqlite==3.48.0 gperftools tbb libnuma numactl
ENV PATH=/sgl-workspace/miniforge3/bin:/sgl-workspace/miniforge3/condabin:${PATH}
ENV PIP_ROOT_USER_ACTION=ignore
ENV CONDA_PREFIX=/sgl-workspace/miniforge3
RUN pip config set global.index-url https://download.pytorch.org/whl/cpu && \
pip config set global.extra-index-url https://pypi.org/simple
RUN git clone ${SGLANG_REPO} sglang && \
RUN source $HOME/.local/bin/env && \
source /opt/.venv/bin/activate && \
git clone ${SGLANG_REPO} sglang && \
cd sglang && \
git checkout ${VER_SGLANG} && \
cd python && \
cp pyproject_cpu.toml pyproject.toml && \
pip install . && \
pip install torch==${VER_TORCH} torchvision==${VER_TORCHVISION} triton==${VER_TRITON} --force-reinstall && \
uv pip install . && \
uv pip install torch==${VER_TORCH} torchvision==${VER_TORCHVISION} triton==${VER_TRITON} --force-reinstall && \
cd ../sgl-kernel && \
cp pyproject_cpu.toml pyproject.toml && \
pip install .
uv pip install .
ENV SGLANG_USE_CPU_ENGINE=1
ENV LD_PRELOAD=/sgl-workspace/miniforge3/lib/libiomp5.so:/sgl-workspace/miniforge3/lib/libtcmalloc.so:/sgl-workspace/miniforge3/lib/libtbbmalloc.so.2
ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libtcmalloc.so.4:/usr/lib/x86_64-linux-gnu/libtbbmalloc.so:/opt/.venv/lib/libiomp5.so
RUN echo 'source /opt/.venv/bin/activate' >> /root/.bashrc
WORKDIR /sgl-workspace/sglang

View File

@@ -54,6 +54,22 @@ if(DEFINED ENV{CONDA_PREFIX})
message(FATAL_ERROR "libnuma not found in Conda environment at ${CONDA_LIB_DIR}\n"
"Please install it using: conda install libnuma numactl\n")
endif()
else()
if(DEFINED ENV{VIRTUAL_ENV})
set(VENV_LIB_DIR "$ENV{VIRTUAL_ENV}/lib")
message(STATUS "Using venv lib dir: ${VENV_LIB_DIR}")
link_directories(${VENV_LIB_DIR})
set(VENV_INCLUDE_DIR "$ENV{VIRTUAL_ENV}/include")
include_directories(${VENV_INCLUDE_DIR})
endif()
# Look for libnuma in system env paths
find_library(NUMA_LIB numa)
if(NUMA_LIB)
message(STATUS "Found libnuma: ${NUMA_LIB}")
else()
message(FATAL_ERROR "libnuma not found in system environment\n"
"Please install it using: apt-get install libnuma numactl\n")
endif()
endif()
file(GLOB SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")