diff --git a/deploy/b300-build/Dockerfile.fast b/deploy/b300-build/Dockerfile.fast index f64dd34c9a..999fc16340 100644 --- a/deploy/b300-build/Dockerfile.fast +++ b/deploy/b300-build/Dockerfile.fast @@ -1,15 +1,50 @@ -# fast 路径:python/pyproject.toml 未变化时使用(build.sh 自动判断)。 -# --no-deps 跳过全部依赖解析(连 index 元数据请求都省掉),纯源码迭代秒级完成。 -# 依赖有变化时必须走 Dockerfile 全量路径(build.sh 按 pyproject sha256 自动切换)。 +# fast 路径(2026-10-08 v3.1):python/pyproject.toml 未变化时使用(build.sh 自动判断)。 +# 与 Dockerfile 全量路径同构:同样跑 check_deps.py 增量安装。 +# 原因:全量构建若装过 kernel wheel 增量(如 sglang-kernel 0.4.7),随后 pyproject 未变的 +# fast 构建若只 --no-deps,会静默退回基底的旧 kernel(0.4.6.post1)——镜像内容漂移。 +# check_deps 本地比对 ~0.5s,增量命中 pip cache 秒级,成本可忽略。 FROM uhub.service.ucloud.cn/umirror/sglang:dev-dsv41 ARG PIP_INDEX=https://pypi.tuna.tsinghua.edu.cn/simple ENV PIP_INDEX_URL=${PIP_INDEX} +# 构建后端(pyproject build-system.requires,torch 除外——基底已有) RUN --mount=type=cache,target=/root/.cache/pip \ pip install "setuptools>=61" "setuptools-scm>=8" "setuptools-rust>=1.11" wheel +# 依赖增量计算脚本(对照 pyproject 与基底已装版本,产出轻量/kernel 增量清单) +# 注意 build context 是 /data/ymk 且 .dockerignore 排除了 build/,只能从 sglang/ 树内 COPY +COPY sglang/deploy/b300-build/check_deps.py /tmp/check_deps.py + +# 整个源码树(含 .git,用于 setuptools-scm 版本打戳) COPY sglang/ /sgl-workspace/sglang/ +# 计算依赖增量(重型 torch/nvidia/cuda 永不进入清单;不满足则 check_deps 非零、构建失败) +RUN python /tmp/check_deps.py /sgl-workspace/sglang/python/pyproject.toml \ + /tmp/missing_light.txt /tmp/missing_kernel.txt \ + && echo "== kernel wheel delta (pip --no-deps) ==" && cat /tmp/missing_kernel.txt \ + && echo "== lightweight dep delta ==" && cat /tmp/missing_light.txt + +# kernel wheel 增量(如 sglang-kernel 升版):--no-deps 防止 pip 顺藤摸瓜解析 torch +RUN --mount=type=cache,target=/root/.cache/pip \ + if grep -q '[^[:space:]]' /tmp/missing_kernel.txt; then \ + pip install --no-deps -r /tmp/missing_kernel.txt; \ + else \ + echo "== no kernel wheel delta"; \ + fi + +# 轻量依赖增量(通常为空或几个小包),重型全家桶原样复用基底。 +# ⚠️ 必须 --no-deps:即使目标只是 xgrammar 这种小包,只要依赖图里出现 torch, +# pip 就会校验 torch+cu130 元数据钉死的 nvidia-nccl-cu13==2.29.7,发现基底装的是 +# 2.30.7 便"好心"下载 206MB 降级(10-08 v3 首跑实测踩中)。基底的传递依赖本来就 +# 齐全,增量小包的二级依赖也一样;若有漏网,b300 冒烟会在 import 阶段显式暴露。 +RUN --mount=type=cache,target=/root/.cache/pip \ + if grep -q '[^[:space:]]' /tmp/missing_light.txt; then \ + pip install --no-deps -r /tmp/missing_light.txt; \ + else \ + echo "== no lightweight delta, skipping dependency install"; \ + fi + +# editable 安装 sglang 本体,--no-deps 保证 pip 完全不碰依赖图 RUN --mount=type=cache,target=/root/.cache/pip \ pip install --no-deps --no-build-isolation -e /sgl-workspace/sglang/python diff --git a/python/sglang/kernels/ops/attention/dsv4/low_ratio_compress.py b/python/sglang/kernels/ops/attention/dsv4/low_ratio_compress.py index 6e1438550b..76ae09d2b3 100644 --- a/python/sglang/kernels/ops/attention/dsv4/low_ratio_compress.py +++ b/python/sglang/kernels/ops/attention/dsv4/low_ratio_compress.py @@ -18,6 +18,7 @@ import torch from sglang.kernels.jit.utils import ( cache_once, is_arch_support_pdl, + is_hip_runtime, load_jit, make_cpp_args, )