Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Install a prebuilt wheel's declared runtime dependencies before smoke importing it (#11536)
Daniel Hanba40410868f6
diff --git a/.github/workflows/prebuilt-cuda-wheels.yml b/.github/workflows/prebuilt-cuda-wheels.ymlindex 73e2c07a6e0..a0ac7f77cb4 100644--- a/.github/workflows/prebuilt-cuda-wheels.yml+++ b/.github/workflows/prebuilt-cuda-wheels.yml@@ -297,13 +297,37 @@ jobs:"$RUNNER_TEMP/smoke/bin/python" -m pip install --quiet --upgrade pip"$RUNNER_TEMP/smoke/bin/python" -m pip install --quiet --no-cache-dir \"torch==${MATRIX_TORCH}" --index-url https://download.pytorch.org/whl/cu130- # The pure-Python modules the three packages import at module load: flash-attn and- # mamba-ssm both `from einops import ...` on import, torch wants numpy for its tensor- # conversions, and packaging is read by the version checks. None of these can pull a- # second torch into the venv, which is what --no-deps on the wheel itself is for:- # causal-conv1d and mamba-ssm declare each other and transformers, none of which has- # anything to do with whether this .so loads.- "$RUNNER_TEMP/smoke/bin/python" -m pip install --quiet einops numpy packaging+ # The wheel is installed with --no-deps so nothing can drag a second torch into the+ # venv; every other runtime dependency the package declares is installed first, read+ # from the wheel's own metadata rather than from a hand-kept list. The hand-kept list+ # broke twice: einops was missing, then huggingface_hub (mamba_ssm.modules.mamba2+ # imports PyTorchModelHubMixin at module load). Excluded on purpose: torch itself and+ # the two sibling packages built by this same workflow, which pip would otherwise try+ # to compile from source because no matching wheel exists on PyPI. The constraints+ # file pins torch and triton to what is already in the venv, so a dependency that+ # wants a different one fails the step loudly instead of swapping torch under us.+ "$RUNNER_TEMP/smoke/bin/python" -m pip freeze | grep -E '^(torch|triton)==' \+ > "$RUNNER_TEMP/smoke-constraints.txt"+ cat "$RUNNER_TEMP/smoke-constraints.txt"+ "$RUNNER_TEMP/smoke/bin/python" - "src/dist/${WHEEL_NAME}" "$RUNNER_TEMP/smoke-constraints.txt" <<'PY'+ import email.parser, pathlib, re, subprocess, sys, zipfile+ wheel = pathlib.Path(sys.argv[1])+ with zipfile.ZipFile(wheel) as zf:+ meta = next(n for n in zf.namelist() if n.endswith(".dist-info/METADATA"))+ headers = email.parser.Parser().parsestr(zf.read(meta).decode())+ excluded = {"torch", "flash-attn", "flash_attn", "causal-conv1d", "causal_conv1d", "mamba-ssm", "mamba_ssm"}+ deps = []+ for req in headers.get_all("Requires-Dist") or []:+ if ";" in req: # extras and environment markers: not runtime requirements+ continue+ name = re.split(r"[\s<>=!~\[;]", req.strip(), maxsplit=1)[0].lower()+ if name in excluded:+ continue+ deps.append(req.strip())+ deps += ["numpy"] # torch wants numpy for its tensor conversions and only warns without it+ print("runtime dependencies from METADATA:", deps)+ subprocess.check_call([sys.executable, "-m", "pip", "install", "--quiet", "--constraint", sys.argv[2], *deps])+ PY"$RUNNER_TEMP/smoke/bin/python" -m pip install --quiet --no-deps \"src/dist/${WHEEL_NAME}"for name in $IMPORT_NAMES; dodiff --git a/tests/python/test_prebuilt_cuda_wheels.py b/tests/python/test_prebuilt_cuda_wheels.pyindex 16f3c1ebc1e..f0e520ec341 100644--- a/tests/python/test_prebuilt_cuda_wheels.py+++ b/tests/python/test_prebuilt_cuda_wheels.py@@ -612,6 +612,27 @@ class TestWorkflow:assert "continue-on-error" not in smokeassert "importlib.import_module" in smoke["run"]+ def test_the_smoke_venv_takes_its_dependencies_from_the_wheel_metadata(self, workflow):+ """A hand-kept dependency list failed the run twice (einops, then huggingface_hub).+ The venv installs what the wheel's own METADATA declares, minus torch and the two+ sibling packages, under a constraints file so torch can never be swapped."""+ smoke = next(+ step+ for step in workflow["jobs"]["build"]["steps"]+ if step.get("name", "").startswith("Smoke test")+ )+ run = smoke["run"]+ assert 'Requires-Dist' in run+ assert '"torch", "flash-attn"' in run and '"mamba-ssm"' in run and '"causal-conv1d"' in run+ assert "--constraint" in run+ assert "pip freeze | grep -E '^(torch|triton)=='" in run+ # The wheel itself still goes in without dependency resolution.+ assert "--no-deps" in run.split("importlib.import_module")[0]+ lines = run.splitlines()+ start = next(i for i, line in enumerate(lines) if line.endswith("<<'PY'"))+ end = next(i for i, line in enumerate(lines) if line == "PY")+ compile("\n".join(lines[start + 1:end]), "<smoke>", "exec")+def test_the_build_runs_on_the_older_ubuntu(self, workflow):"""The wheels are tagged linux_x86_64, which pip installs without a glibc check, so therunner's glibc is the real compatibility floor."""