[CI] Renovation of nightly wheel build & generation (#29690)

Signed-off-by: Shengqi Chen <harry-chen@outlook.com>
This commit is contained in:
Shengqi Chen
2025-12-01 21:25:39 +08:00
committed by GitHub
parent 5cfa967efa
commit 36db0a35e4
9 changed files with 568 additions and 181 deletions

101
setup.py
View File

@@ -310,9 +310,6 @@ class cmake_build_ext(build_ext):
class precompiled_build_ext(build_ext):
"""Disables extension building when using precompiled binaries."""
def run(self) -> None:
assert _is_cuda(), "VLLM_USE_PRECOMPILED is only supported for CUDA builds"
def build_extensions(self) -> None:
print("Skipping build_ext: using precompiled extensions.")
return
@@ -648,37 +645,97 @@ package_data = {
]
}
def _fetch_metadata_for_variant(
commit: str, variant: str | None
) -> tuple[list[dict], str]:
variant_dir = f"{variant}/" if variant is not None else ""
repo_url = f"https://wheels.vllm.ai/{commit}/{variant_dir}vllm/"
meta_url = repo_url + "metadata.json"
logger.info("Trying to fetch metadata from {}", meta_url)
from urllib.request import urlopen
with urlopen(meta_url) as resp:
# urlopen raises HTTPError on unexpected status code
wheels = json.loads(resp.read().decode("utf-8"))
return wheels, repo_url
# If using precompiled, extract and patch package_data (in advance of setup)
if envs.VLLM_USE_PRECOMPILED:
assert _is_cuda(), "VLLM_USE_PRECOMPILED is only supported for CUDA builds"
# Attempts:
# 1. user-specified wheel location (can be either local or remote, via
# VLLM_PRECOMPILED_WHEEL_LOCATION)
# 2. user-specified variant from nightly repo (current main commit via
# VLLM_PRECOMPILED_WHEEL_VARIANT)
# 3. the variant corresponding to VLLM_MAIN_CUDA_VERSION from nightly repo
# 4. the default variant from nightly repo (current main commit)
wheel_location = os.getenv("VLLM_PRECOMPILED_WHEEL_LOCATION", None)
if wheel_location is not None:
wheel_url = wheel_location
logger.info("Using user-specified precompiled wheel location: {}", wheel_url)
else:
import platform
arch = platform.machine()
if arch == "x86_64":
wheel_tag = "manylinux1_x86_64"
elif arch == "aarch64":
wheel_tag = "manylinux2014_aarch64"
else:
raise ValueError(f"Unsupported architecture: {arch}")
base_commit = precompiled_wheel_utils.get_base_commit_in_main_branch()
wheel_url = f"https://wheels.vllm.ai/{base_commit}/vllm-1.0.0.dev-cp38-abi3-{wheel_tag}.whl"
nightly_wheel_url = (
f"https://wheels.vllm.ai/nightly/vllm-1.0.0.dev-cp38-abi3-{wheel_tag}.whl"
# try to fetch the wheel metadata from the nightly wheel repo
main_variant = envs.VLLM_MAIN_CUDA_VERSION.replace(".", "")
variant = os.getenv("VLLM_PRECOMPILED_WHEEL_VARIANT", main_variant)
commit = os.getenv(
"VLLM_PRECOMPILED_WHEEL_COMMIT",
precompiled_wheel_utils.get_base_commit_in_main_branch(),
)
from urllib.request import urlopen
logger.info(
"Using precompiled wheel commit {} with variant {}", commit, variant
)
try_default = False
wheels, repo_url = None, None
try:
with urlopen(wheel_url) as resp:
if resp.status != 200:
wheel_url = nightly_wheel_url
wheels, repo_url = _fetch_metadata_for_variant(commit, variant)
except Exception as e:
print(f"[warn] Falling back to nightly wheel: {e}")
wheel_url = nightly_wheel_url
logger.warning(
"Failed to fetch precompiled wheel metadata for variant {}",
variant,
exc_info=e,
)
try_default = True # try outside handler to keep the stacktrace simple
if try_default:
logger.info("Trying the default variant")
wheels, repo_url = _fetch_metadata_for_variant(commit, None)
# if this also fails, then we have nothing more to try / cache
assert wheels is not None and repo_url is not None, (
"Failed to fetch precompiled wheel metadata"
)
# The metadata.json has the following format:
# see .buildkite/scripts/generate-nightly-index.py for details
"""[{
"package_name": "vllm",
"version": "0.11.2.dev278+gdbc3d9991",
"build_tag": null,
"python_tag": "cp38",
"abi_tag": "abi3",
"platform_tag": "manylinux1_x86_64",
"variant": null,
"filename": "vllm-0.11.2.dev278+gdbc3d9991-cp38-abi3-manylinux1_x86_64.whl",
"path": "../vllm-0.11.2.dev278+gdbc3d9991-cp38-abi3-manylinux1_x86_64.whl"
},
...]"""
for wheel in wheels:
if wheel.get("package_name") == "vllm" and arch in wheel.get(
"platform_tag", ""
):
logger.info("Found precompiled wheel metadata: {}", wheel)
if "path" not in wheel:
raise ValueError(f"Wheel metadata missing path: {wheel}")
# TODO: maybe check more compatibility later? (python_tag, abi_tag, etc)
wheel_url = repo_url + wheel["path"]
logger.info("Using precompiled wheel URL: {}", wheel_url)
break
else:
raise ValueError(
f"No precompiled vllm wheel found for architecture {arch} "
f"from repo {repo_url}. All available wheels: {wheels}"
)
patch = precompiled_wheel_utils.extract_precompiled_and_patch_package(wheel_url)
for pkg, files in patch.items():
package_data.setdefault(pkg, []).extend(files)