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
Make the Colab pip cache able to shrink, which #11270 assumed it already could (#11271)
Daniel Hana6ffbed933dc
diff --git a/.github/workflows/cache-janitor.yml b/.github/workflows/cache-janitor.ymlindex 516f067894a..340c1ad571b 100644--- a/.github/workflows/cache-janitor.yml+++ b/.github/workflows/cache-janitor.yml@@ -321,6 +321,13 @@ jobs:# 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.+ #+ # The glob is deliberately a prefix and not the exact job name:+ # it has to keep matching `notebooks-colab-cpu`, and any further+ # suffix, because retiring the prefix is how that job collects a+ # trim at all (see the comment on its `name` in notebooks-ci.yml).+ # Each retired prefix is then its own family here, so keep=1+ # drains it to one entry and the 7-day idle timer takes the last.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 --diff --git a/.github/workflows/notebooks-ci.yml b/.github/workflows/notebooks-ci.ymlindex 1d1f9fb1738..3226ae0b6e2 100644--- a/.github/workflows/notebooks-ci.yml+++ b/.github/workflows/notebooks-ci.yml@@ -474,17 +474,44 @@ jobs:# transfer is otherwise unbounded and lands on the job clock.timeout-minutes: 8with:- name: notebooks-colab- # The freeze is the pin set, so it is what the downloads depend on. The- # workflow comes too because the seed step rewrites those pins in place- # -- CPU index mapping, skips, spoofs -- so an edit there changes what- # gets installed without touching the freeze.+ # `-cpu`, not `notebooks-colab`, and the suffix is load-bearing rather+ # than descriptive: it retires the old prefix so nothing falls back to+ # it.+ #+ # pip's HTTP cache is cumulative and pip never evicts from it, while+ # the save step saves the whole directory. With restore-keys on, a run+ # that misses its exact key still restores the PREVIOUS generation's+ # wheels into that directory and saves them straight back out, so+ # dropping pins from the install set cannot shrink the entry. Measured+ # on the two live generations: 7,486,810,247 bytes on 2026-09-15 and+ # 7,486,845,334 on 2026-09-18, 35 KB apart, because the second run+ # inherited the first instead of re-downloading 5 GiB.+ #+ # So #11270 removed 39 pins and freed nothing. A one-time prefix change+ # is what collects it: the next run on main starts from an empty pip+ # directory and saves only what the trimmed set actually downloads.+ # Costs one cold install. Renaming this job rather than bumping the+ # shared `v2` segment on purpose -- v3 would invalidate all 13 pip+ # families at once AND fall outside cache-janitor.yml's `pip-v2-` glob,+ # which would leave the new entries unpruneable.+ name: notebooks-colab-cpu+ # Everything the seed step READS, or the key cannot represent what the+ # job installs. The freeze is the pin set. The workflow comes too+ # because the seed step rewrites those pins in place. And the mapping+ # is where the rewrites, skips and spoofs actually live -- it was+ # missing here, so every edit to it (#11270 among them) changed the+ # install while the key stayed put, the restore hit exactly, and+ # pip-cache-save skipped on `cache-hit == 'true'`. A stale entry cannot+ # serve wrong CONTENT, since pip's cache is addressed by URL and hash,+ # but it can and did pin the entry's SIZE to a pin set that no longer+ # exists.## api-introspect above keys on the workflow alone because it pins inline.# This job does not, and keying it on the workflow alone would rebuild# 709 downloads for an unrelated edit to any other job in this file.key-files: |unsloth/scripts/data/colab_pip_freeze.gpu.txt+ unsloth/scripts/data/colab_to_cpu_pin.jsonunsloth/.github/workflows/notebooks-ci.yml- name: Seed Colab-shaped venv from pip-freeze (CPU-mapped)diff --git a/tests/notebooks/test_smoke_install_contract.py b/tests/notebooks/test_smoke_install_contract.pyindex cd54433f6d6..73756c6c673 100644--- a/tests/notebooks/test_smoke_install_contract.py+++ b/tests/notebooks/test_smoke_install_contract.py@@ -212,6 +212,58 @@ def test_the_known_unbuildable_pins_are_skipped():)+# --- the cache key has to represent what the job installs ----------------------------+++def _restore_step() -> dict:+ steps = [s for s in _job()["steps"] if "pip-cache-restore" in str(s.get("uses", ""))]+ assert len(steps) == 1, f"{JOB} should restore the pip cache exactly once, got {len(steps)}"+ return steps[0]["with"]+++def test_every_file_the_seed_step_reads_is_a_cache_key_input():+ """Otherwise an edit changes the install while the key stays put.++ #11270 dropped 39 pins from colab_to_cpu_pin.json and freed nothing, because the+ mapping was not a key input: the key hash did not move, the restore hit exactly,+ and pip-cache-save is gated on `cache-hit != 'true'`, so the entry holding the+ removed wheels was never rewritten. A stale entry cannot serve wrong CONTENT --+ pip's cache is addressed by URL and hash -- but it pins the entry's SIZE to a pin+ set that no longer exists.++ The rule is mechanical: whatever the shell opens, the key must hash.+ """+ files = set(_restore_step()["key-files"].split())+ # Only checked-in files under the job's checkout prefix. The seed step also+ # opens /tmp scratch and the converted _smoke.py, which are its OUTPUTS: they+ # are derived from the inputs below and cannot be edited into the repo.+ opened = set(re.findall(r"""open\(\s*["'](unsloth/[^"']+)["']""", _shell(_job())))+ assert opened, "found no repo files being read by the seed step; the pattern has drifted"+ missing = sorted(opened - files)+ assert not missing, (+ f"the seed step reads {missing} but they are not in key-files {sorted(files)}, so "+ f"editing them changes what the job installs without minting a new cache key"+ )+++def test_the_mapping_is_a_cache_key_input():+ """Named explicitly, so deleting the rule above cannot quietly drop the one file+ that caused the bug."""+ assert "unsloth/scripts/data/colab_to_cpu_pin.json" in _restore_step()["key-files"].split()+++def test_the_cache_key_inputs_exist():+ """A glob that matches nothing makes hashFiles return empty, which pip-cache-restore+ fails on by design -- but it fails in CI, not here, and only on the next run."""+ for rel in _restore_step()["key-files"].split():+ # key-files resolve from GITHUB_WORKSPACE and this job checks out under+ # `unsloth/`, which is the repo root from this test's point of view.+ assert rel.startswith("unsloth/"), f"{rel} is not prefixed for this job's checkout layout"+ assert (+ REPO / rel[len("unsloth/") :]+ ).exists(), f"key-files names {rel}, which does not exist"++# --- what the skip list costs and what it must not spend -----------------------------