Skip to content

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.

Trim 2.59 GiB per generation from the Colab smoke job's pip cache (#11270)

Daniel Hanc40326810e24
diff --git a/.github/workflows/cache-janitor.yml b/.github/workflows/cache-janitor.yml
index 54411d0037a..516f067894a 100644
--- a/.github/workflows/cache-janitor.yml
+++ b/.github/workflows/cache-janitor.yml
@@ -307,6 +307,21 @@ jobs:
pre=$(printf '%s' "$key" | sed -E 's/-[0-9a-f]{40}$//'); fkeep=1 ;;
v0-rust-*)
pre=$(printf '%s' "$key" | sed -E 's/-[0-9a-f]{8,}$//') ;;
+ pip-v2-notebooks-colab-*)
+ # One generation, not `keep`. This family replays a 697-pin Colab
+ # freeze and measures 6.97 GB per generation, so two copies of one
+ # job's downloads held 13.95 GB, 30% of the repo's whole 50 GiB
+ # budget (2026-09-18, with the repo at 92% full and evicting).
+ # Every other pip family averages 0.5 GB.
+ #
+ # The general argument for keep=2 is that the previous generation
+ # still answers an exact-key restore. It does here too, but only
+ # for an exact revert of colab_pip_freeze.gpu.txt or of
+ # notebooks-ci.yml, which is rarer than the eviction pressure the
+ # second copy causes on every other family. Same trade as the
+ # CodeQL rule above: keep is a budget dial, and this family spends
+ # more of it than the hit it buys is worth.
+ pre=$(printf '%s' "$key" | sed -E 's/-[0-9a-f]{64}$//'); fkeep=1 ;;
pip-v2-*|uv-*|fe-dist-*)
# Strip only the trailing dependency hash. Everything before it --
# the job name for pip-v2, the OS for uv and fe-dist -- stays in the
diff --git a/scripts/data/colab_to_cpu_pin.json b/scripts/data/colab_to_cpu_pin.json
index 9bad6b52166..ef1dcae1af3 100644
--- a/scripts/data/colab_to_cpu_pin.json
+++ b/scripts/data/colab_to_cpu_pin.json
@@ -19,34 +19,76 @@
"module_spoof": {
"torchcodec": "no CPU wheel published; smoke job sys.modules-stubs torchcodec before importing unsloth"
},
- "_skip_comment": "Two kinds. The nvidia-*/triton entries are CUDA runtime wheels a CPU runner cannot use. The rest are sdist-only packages whose builds need system libraries the hosted image does not carry (ipopt, dbus-1, cmake, gdal-config, cairo, R), so they cannot install on any interpreter and only ever cost build time. Observed failing in the 2026-08-31 scheduled run.",
+ "_skip_comment": "Three kinds. (1) CUDA wheels a CPU runner cannot use: the nvidia-*/triton entries, plus the RAPIDS stack (libcudf, libcuml, cudf, cuml, rmm, raft, ucxx, dask-cuda, numba-cuda, cuda-bindings) and cupy-cuda12x and the jax-cuda12-* plugins. (2) Sdist-only packages whose builds need system libraries the hosted image does not carry (ipopt, dbus-1, cmake, gdal-config, cairo, R), so they cannot install on any interpreter and only ever cost build time. Observed failing in the 2026-08-31 scheduled run. (3) Large wheels nothing in this job's import graph reaches: pyspark and its connector, the Intel math runtime (mkl/intel-openmp/tbb/umf -- CPU torch links its own BLAS and nothing here loads pip's mkl), and xgboost, which is CPU-capable but declares nvidia-nccl-cu13 unconditionally on Linux and so drags 241 MiB behind it.",
+ "_skip_size_comment": "This list is the only lever on the cache, so it is sized deliberately. The pip cache this job writes measured 6.97 GB per generation on 2026-09-18, 30% of the repo's 50 GiB Actions budget across its two generations, with the repo 92% full and evicting other families' live entries. Kind (1) and kind (3) together are 2.59 GiB of that per generation.",
+ "_skip_closure_comment": "A skip only saves the download if NOTHING RETAINED REQUIRES IT: the seed step installs bare `name==ver`, so pip re-resolves any dropped package a kept pin depends on and downloads it anyway, unpinned. So these were chosen as a dependency closure over the freeze, not as a list of names. That is why the parents come too -- cuml-cu12 and dask-cudf-cu12 for cupy, pylibcudf-cu12 and cudf-polars-cu12 for libcudf, ucxx-cu12 and distributed-ucxx-cu12 for rmm, dataproc-spark-connect for pyspark, xgboost for nvidia-nccl-cu13. Re-derive the closure after any Colab rotation; adding a name without its parents is a no-op that looks like a saving.",
+ "_skip_retained_comment": "TensorFlow, Flax, JAX, keras-hub, ydf and dopamine-rl are deliberately NOT skipped, though they are 761 MiB and nothing in this repo imports them. Transformers imports the TF and Flax backends merely because they are INSTALLED, via processing_utils -> image_transforms, so their presence changes what `import unsloth` does -- that is the whole subject of tests/test_broken_tf_does_not_break_import.py. Colab ships them, so a seed env without them stops reproducing the interaction this job exists to catch. Fabricating .dist-info metadata without the wheel is worse than either choice: it reproduces the BROKEN-TF path (find_spec hit, import fails) rather than Colab's healthy TF, which would make the smoke job assert against a condition that is not real on Colab.",
"skip": [
+ "cuda-bindings",
+ "cuda-core",
+ "cuda-pathfinder",
+ "cuda-python",
+ "cudf-cu12",
+ "cudf-polars-cu12",
+ "cuml-cu12",
+ "cupy-cuda12x",
"cyipopt",
+ "dask-cuda",
+ "dask-cudf-cu12",
+ "dataproc-spark-connect",
"dbus-python",
+ "distributed-ucxx-cu12",
"dlib",
"gdal",
+ "intel-cmplr-lib-ur",
+ "intel-openmp",
+ "jax-cuda12-pjrt",
+ "jax-cuda12-plugin",
+ "libcudf-cu12",
"libcugraph-cu12",
+ "libcuml-cu12",
"libcuvs-cu12",
+ "libkvikio-cu12",
+ "libraft-cu12",
+ "libucxx-cu12",
+ "mkl",
+ "numba-cuda",
"nvidia-cublas-cu12",
+ "nvidia-cuda-cccl-cu12",
"nvidia-cuda-cupti-cu12",
+ "nvidia-cuda-nvcc-cu12",
"nvidia-cuda-nvrtc-cu12",
"nvidia-cuda-runtime-cu12",
"nvidia-cudnn-cu12",
"nvidia-cufft-cu12",
+ "nvidia-cufile-cu12",
"nvidia-curand-cu12",
"nvidia-cusolver-cu12",
"nvidia-cusparse-cu12",
"nvidia-cusparselt-cu12",
+ "nvidia-libnvcomp-cu12",
"nvidia-nccl-cu12",
+ "nvidia-nccl-cu13",
+ "nvidia-nvimgcodec-cu12",
"nvidia-nvjitlink-cu12",
+ "nvidia-nvshmem-cu12",
"nvidia-nvtx-cu12",
"psycopg2",
"pycairo",
"pygobject",
+ "pylibcudf-cu12",
"pylibcugraph-cu12",
+ "pylibraft-cu12",
+ "pyspark",
"python-apt",
+ "raft-dask-cu12",
+ "rmm-cu12",
"rpy2",
- "triton"
+ "tbb",
+ "triton",
+ "ucxx-cu12",
+ "umf",
+ "xgboost"
],
"no_binary": [
"antlr4-python3-runtime",
@@ -63,9 +105,8 @@
"moviepy",
"promise",
"pydotplus",
- "pyspark",
"python-louvain",
"wadllib"
],
- "_no_binary_comment": "Passed to pip as --no-binary, which overrides --only-binary=:all: per package. Without it the bulk resolve fails on the first of these and every run falls into the per-pin path, which is the failure this whole job kept hitting. Derived by asking PyPI, for every pin in the freeze, whether it publishes a wheel COMPATIBLE with the pinned interpreter and manylinux x86_64, not merely whether a wheel exists: editdistance ships wheels but none for cp313, and checking only for existence missed it. 18 pins have no usable wheel; psycopg2 is in skip because it needs pg_config and cannot build here, the other 17 are pure Python or build in seconds. Re-derive after any Colab rotation."
+ "_no_binary_comment": "Passed to pip as --no-binary, which overrides --only-binary=:all: per package. Without it the bulk resolve fails on the first of these and every run falls into the per-pin path, which is the failure this whole job kept hitting. Derived by asking PyPI, for every pin in the freeze, whether it publishes a wheel COMPATIBLE with the pinned interpreter and manylinux x86_64, not merely whether a wheel exists: editdistance ships wheels but none for cp313, and checking only for existence missed it. 18 pins have no usable wheel; psycopg2 and pyspark are in skip instead -- psycopg2 needs pg_config and cannot build here, pyspark is a 414 MiB sdist nothing in this job's import graph reaches -- and the other 16 are pure Python or build in seconds. A name in both lists is not an error (the seed step only passes --no-binary for pins still present after the skip filter), but it is dead config, so it goes. Re-derive after any Colab rotation."
}
diff --git a/tests/notebooks/test_smoke_install_contract.py b/tests/notebooks/test_smoke_install_contract.py
index e20c6198429..cd54433f6d6 100644
--- a/tests/notebooks/test_smoke_install_contract.py
+++ b/tests/notebooks/test_smoke_install_contract.py
@@ -55,6 +55,19 @@ def _mapping() -> dict:
return json.loads(MAPPING.read_text(encoding = "utf-8"))
+def _freeze_names() -> set[str]:
+ """The pinned package names in the Colab snapshot, lowercased.
+
+ Every rule below is scoped to what the freeze actually pins, so a Colab rotation
+ that drops a package cannot fail these on a name that is no longer there.
+ """
+ return {
+ m.group(1).lower()
+ for line in FREEZE.read_text(encoding = "utf-8").splitlines()
+ if (m := re.match(r"^([A-Za-z0-9._-]+)\s*==", line.strip()))
+ }
+
+
# --- the interpreter the snapshot was taken on ---------------------------------------
@@ -197,3 +210,110 @@ def test_the_known_unbuildable_pins_are_skipped():
f"these pins cannot build on ubuntu-latest on any interpreter and only cost "
f"build time, so they belong in the skip list: {missing}"
)
+
+
+# --- what the skip list costs and what it must not spend -----------------------------
+
+
+def test_the_cuda_only_wheels_are_skipped():
+ """The skip list is the only lever on this job's pip cache, which measured 6.97 GB
+ per generation on 2026-09-18 -- 30% of the repo's 50 GiB Actions budget across its
+ two generations, while the repo sat at 92% full and evicted other families' live
+ entries. These cannot execute without a GPU, so caching them buys nothing at all.
+ """
+ skip = set(_mapping()["skip"])
+ cuda_only = {
+ "libcudf-cu12",
+ "libcuml-cu12",
+ "cudf-cu12",
+ "cuml-cu12",
+ "rmm-cu12",
+ "pylibcudf-cu12",
+ "pylibraft-cu12",
+ "raft-dask-cu12",
+ "ucxx-cu12",
+ "dask-cuda",
+ "numba-cuda",
+ "cuda-bindings",
+ "cupy-cuda12x",
+ "jax-cuda12-pjrt",
+ "jax-cuda12-plugin",
+ "nvidia-nvshmem-cu12",
+ "nvidia-cuda-nvcc-cu12",
+ "nvidia-nccl-cu13",
+ }
+ missing = sorted((cuda_only & _freeze_names()) - skip)
+ assert not missing, (
+ f"these are CUDA-only wheels the CPU runner can never load, so they are pure "
+ f"cache weight: {missing}"
+ )
+
+
+def test_the_backends_transformers_detects_stay_installed():
+ """TensorFlow and Flax are 761 MiB that nothing in this repo imports, which makes
+ them look like the obvious next thing to skip. They are not.
+
+ Transformers imports either backend merely because it is INSTALLED, via
+ processing_utils -> image_transforms, so their presence changes what
+ `import unsloth` does. That is the subject of
+ tests/test_broken_tf_does_not_break_import.py, and Colab ships them, so a seed env
+ without them stops reproducing the interaction this job exists to catch.
+
+ Fabricating .dist-info metadata without the wheel is worse than either choice: a
+ find_spec hit whose import fails is the BROKEN-TF path, not Colab's healthy TF.
+ """
+ skip = set(_mapping()["skip"])
+ detected = {"tensorflow", "flax", "jax", "jaxlib", "tf-keras"}
+ wrongly_skipped = sorted((detected & _freeze_names()) & skip)
+ assert not wrongly_skipped, (
+ f"{wrongly_skipped} are detected-if-installed backends. Skipping them saves "
+ f"cache at the cost of the fidelity this job is for; see "
+ f"tests/test_broken_tf_does_not_break_import.py"
+ )
+
+
+def test_skipped_pins_are_not_also_marked_no_binary():
+ """Dead config. The seed step only passes --no-binary for pins still present after
+ the skip filter, so an entry in both lists is silently ignored and reads as though
+ the package were still being built.
+ """
+ mapping = _mapping()
+ both = sorted(set(mapping["skip"]) & set(mapping.get("no_binary", [])))
+ assert not both, f"these are in skip and no_binary at once, so no_binary is dead: {both}"
+
+
+def test_the_skip_list_is_closed_under_the_freezes_dependencies():
+ """A skip only saves the download if nothing retained requires it.
+
+ The seed step installs bare `name==ver`, so pip re-resolves any dropped package a
+ KEPT pin depends on and downloads it anyway, unpinned -- a saving that is not one,
+ and the failure mode is invisible because the install still succeeds. These edges
+ were read off the freeze's own metadata; each pair is `child: parents`, and skipping
+ the child obliges skipping the parents.
+ """
+ skip = set(_mapping()["skip"])
+ names = _freeze_names()
+ edges = {
+ "cupy-cuda12x": {"cudf-cu12", "cuml-cu12", "dask-cudf-cu12"},
+ "libcudf-cu12": {"pylibcudf-cu12"},
+ "pylibcudf-cu12": {"cudf-polars-cu12"},
+ "libcuml-cu12": {"cuml-cu12"},
+ "rmm-cu12": {"ucxx-cu12"},
+ "ucxx-cu12": {"distributed-ucxx-cu12"},
+ "numba-cuda": {"dask-cuda", "distributed-ucxx-cu12"},
+ "cuda-bindings": {"numba-cuda"},
+ "pylibraft-cu12": {"cuml-cu12", "raft-dask-cu12"},
+ "pyspark": {"dataproc-spark-connect"},
+ "intel-openmp": {"mkl"},
+ "tbb": {"mkl"},
+ "nvidia-nccl-cu13": {"xgboost"},
+ }
+ leaks = {
+ child: sorted(parents & names - skip)
+ for child, parents in edges.items()
+ if child in skip and (parents & names - skip)
+ }
+ assert not leaks, (
+ f"each of these is skipped while a retained pin still requires it, so pip "
+ f"downloads it anyway and the skip saves nothing: {leaks}"
+ )