[CI] Build the Rust extension modules once per run instead of in every CUDA job (#33384)

This commit is contained in:
Liangsheng Yin
2026-08-03 18:56:48 -07:00
committed by GitHub
parent 572924634b
commit cdff33d738
9 changed files with 567 additions and 28 deletions
+35
View File
@@ -326,6 +326,40 @@ uninstall_stale_flashinfer() {
mark_step_done "${FUNCNAME[0]}"
}
require_prebuilt_rust_exts() {
# Stages whose download succeeded set this to none. Runs before
# setup_pip_toolchain uninstalls sglang, so clearing it here still reaches
# install_sglang below - setup.py reads it from the environment at build time.
if [ "${SGLANG_BUILD_RUST_EXTS:-}" != "none" ]; then
mark_step_done "${FUNCNAME[0]}"
return
fi
# Exact EXT_SUFFIX rather than a _core*.so glob: no crate sets abi3, so a module
# built for another minor version satisfies the glob while the import system
# ignores it, leaving is_rust_server_built() false and the Rust-server tests
# silently skipped. Stages have no setup-python, so the interpreter is whatever
# the image ships, and the pools are not on one version (h20 is 3.12 while
# h100 is 3.10) - a mismatch is drift to route around, not a failure.
local suffix
suffix=$(python3 -c 'import sysconfig; print(sysconfig.get_config_var("EXT_SUFFIX"))')
local missing=()
local pkg
for pkg in server grpc multimodal; do
[ -f "python/sglang/srt/${pkg}/_core${suffix}" ] || missing+=("${pkg}")
done
if [ ${#missing[@]} -gt 0 ]; then
echo "::warning::no prebuilt _core${suffix} for: ${missing[*]}; building from source"
ls -l python/sglang/srt/*/_core*.so 2>/dev/null || echo "(no extension modules at all)"
export SGLANG_BUILD_RUST_EXTS=
mark_step_done "${FUNCNAME[0]}"
return
fi
echo "Using prebuilt Rust extension modules; skipping the cargo build."
mark_step_done "${FUNCNAME[0]}"
}
install_sglang() {
EXTRAS="dev,runai,tracing"
if [ -n "$OPTIONAL_DEPS" ]; then
@@ -654,6 +688,7 @@ main() {
install_apt_packages
clean_site_packages
setup_cargo_cache
require_prebuilt_rust_exts
setup_pip_toolchain
remove_stale_cuda12_nvidia_wheels
uninstall_stale_flashinfer