diff --git a/install-flash-local.sh b/install-flash-local.sh index 77510050..c24ea0d4 100755 --- a/install-flash-local.sh +++ b/install-flash-local.sh @@ -306,7 +306,7 @@ PY } TABLE_MOUNTS="" lane_table(){ # $1 copy: make the copies whole first; mounts: only name the copies already there - local rc=0 + local rc=0 named if [ "$1" = copy ]; then python3 "$HERE/ple-table.py" "$HF_CACHE" "$MODEL" "$MODEL_REV" --home "$HOME" "${TABLE_DIR_ARG[@]}" copy \ || die "the n-gram table could not be put on the home directory's disk (the lines above say why)" @@ -315,8 +315,19 @@ lane_table(){ # $1 copy: make the copies whole first; mounts: only name the cop case "$rc" in 0) ;; 2) TABLE_MOUNTS="" ;; # no checkpoint in the cache yet - *) TABLE_MOUNTS="" - echo "NOTE: the n-gram table's copies are not all there: the lane reads the table from the cache's disk until its next Load (or ./switch-model.sh flash-local) makes them" ;; + *) # Copies the unit in place mounts, and that went since (deleted from the cockpit's Library, or by hand): it keeps + # naming them. Its start says what it lacks, and its Load copies them again. Rendered without them, the unit + # lacked nothing: the lane read its table from the cache's disk with no word of it, five times slower from a USB + # SSD, and the Load of a lane already at boot, which only starts a unit that lacks nothing, never made them again + # (found with discussion 78, 2026-11-30). + named="$(python3 "$HERE/ple-table.py" "$HF_CACHE" "$MODEL" "$MODEL_REV" --home "$HOME" "${TABLE_DIR_ARG[@]}" named 2>/dev/null || true)" + if [ -n "$named" ] && grep -qsF -- "$named" "$INSTALLED"; then + TABLE_MOUNTS="$named" + echo "NOTE: the n-gram table's copies this lane reads are not all there any more: it does not start until its next Load (or ./switch-model.sh flash-local) copies them again, about $FLASH_LOCAL_TABLE_GB GB" + else + TABLE_MOUNTS="" + echo "NOTE: the n-gram table's copies are not all there: the lane reads the table from the cache's disk until its next Load (or ./switch-model.sh flash-local) makes them" + fi ;; esac } diff --git a/lanes.sh b/lanes.sh index b2cfe8ce..e037f65f 100644 --- a/lanes.sh +++ b/lanes.sh @@ -280,11 +280,12 @@ unit_path_needs(){ # $1 the path as the unit names it, $2 the cache the unit mo # What a lane's unit (or launcher) reads that this box does not have: one line each, "image " (by its digest or # its local build's tag, as docker names it), "checkpoint @" (whole, as ckpt_cached reads it, in the # cache the unit mounts), "draft @" (the 27B's DFlash2 draft, draft_in_cache, and the Nemotron lanes' -# vLLM drafter), "path " (a model the unit names by its path: a GGUF part, a snapshot folder), "unreadable -# " (a unit this user cannot read), "unknown ..." (this cannot conclude: docker did not answer, the -# cache cannot be read; unit_put keeps the unit in place on such a line, never the reverse). Nothing when it has it all. +# vLLM drafter), "path " (a model the unit names by its path: a GGUF part, a snapshot folder), "table +# (...)" (the FP4-Local lane's copies of its n-gram table), "unreadable " (a unit this user cannot read), "unknown +# ..." (this cannot conclude: docker did not answer, the cache cannot be read; unit_put keeps the unit in place on such a +# line, never the reverse). Nothing when it has it all. unit_needs(){ # $1 a unit or a launcher (a file: read more than once) - local hf img repo rev f seen=" " hf_known=1 + local hf img repo rev f seen=" " hf_known=1 want copies=0 gone=0 dir="" # a unit this user cannot read (root's 0600, as the image lane's were before a fix) is not taken for whole: its # new unit goes in place as before v1.52.0 (Vibe's blind review of v1.52.0, Mistral Large 4) [ -r "$1" ] || { echo "unreadable $1"; return 0; } @@ -357,6 +358,18 @@ unit_needs(){ # $1 a unit or a launcher (a file: read more than once) done < <({ grep -oE '/[^ \"=]*/hub/models--[^ \"/]+/snapshots/[0-9a-f]{40}/[^ \"]+' "$1" || true; } { grep -oE '"[^"]*/hub/models--[^"]+/snapshots/[0-9a-f]{40}/[^"]+"' "$1" \ | sed -e 's/^"//' -e 's/"$//' || true; } | sort -u) + # The copies of its n-gram table the Qwen3.8 Flash-Next FP4-Local lane's unit mounts over the cache's own files, each + # there with its original's size, as its start reads them (flash-local-files.sh) and as the cockpit does + # (lane_startable). Deleted from the cockpit's Library, they are its Load's to copy again: an update that did not see + # them missing copied 32 GB back onto the disk they had just left (2026-11-30). One line for them all, and none for a + # copy whose original is not there: the checkpoint's own line says that. + while IFS= read -r f; do + copies=$((copies + 1)); dir="${f%%:*}"; dir="${dir%/*}" + want="$(stat -L -c %s "$hf${f#*:/root/.cache/huggingface}" 2>/dev/null || true)"; f="${f%%:*}" + if [ ! -f "$f" ] || [ ! -s "$f" ] || { [ -n "$want" ] && [ "$(stat -c %s "$f")" != "$want" ]; }; then gone=$((gone + 1)); fi + done < <({ grep -oE -- '-v [^ :]+:/root/\.cache/huggingface/hub/[^ :]+/blobs/[0-9a-f]{64}:ro' "$1" || true; } \ + | sed -e 's/^-v //' -e 's/:ro$//') + [ "$gone" -eq 0 ] || echo "table $dir ($gone of the $copies copies of its n-gram table)" fi # a file the unit bind-mounts by its own source (--mount type=bind,source=...): the vLLM lanes' chat template # and api key, mounted that way on purpose so that a missing source fails the start where -v made a diff --git a/ple-table.py b/ple-table.py index 0a86527c..5dcd890d 100644 --- a/ple-table.py +++ b/ple-table.py @@ -15,6 +15,7 @@ over the cache's own, file by file. The cache itself is never touched. ple-table.py HF_CACHE REPO REV --home HOME [--dir DIR] plan what goes where, in bytes ple-table.py HF_CACHE REPO REV --home HOME [--dir DIR] copy make the copies whole ple-table.py HF_CACHE REPO REV --home HOME [--dir DIR] mounts the unit's -v arguments, one line + ple-table.py HF_CACHE REPO REV --home HOME [--dir DIR] named the same line, the copies there or not ple-table.py HF_CACHE REPO REV --home HOME [--dir DIR] check the folder refused or not, no checkpoint needed ple-table.py HF_CACHE REPO REV --home HOME [--dir DIR] --need-gb N room the copies' room on their disk, before any download @@ -186,7 +187,7 @@ def main() -> None: ap.add_argument("--home", required=True) ap.add_argument("--dir", default="") ap.add_argument("--need-gb", type=int, default=0) - ap.add_argument("action", choices=("plan", "copy", "mounts", "check", "room")) + ap.add_argument("action", choices=("plan", "copy", "mounts", "named", "check", "room")) args = ap.parse_args() repo_dir = pathlib.Path(args.hf_cache) / "hub" / ("models--" + args.repo.replace("/", "--")) if args.action == "check": @@ -212,11 +213,11 @@ def main() -> None: missing = sum(b.stat().st_size for _, b in files if not whole_copy(folder / b.name, b)) print(f"copies: {len(files)} files, {total} bytes, {missing} to copy into {folder}") return - if args.action == "mounts": + if args.action in ("mounts", "named"): if folder is None: return absent = [b.name for _, b in files if not whole_copy(folder / b.name, b)] - if absent: + if absent and args.action == "mounts": print(f"{len(absent)} copies are not in {folder}: run the copy first", file=sys.stderr) sys.exit(1) mount = f"{CONTAINER_HUB}/{repo_dir.name}/blobs" diff --git a/tests/test_flash_local_stage.py b/tests/test_flash_local_stage.py index 8997aca0..be36ea25 100644 --- a/tests/test_flash_local_stage.py +++ b/tests/test_flash_local_stage.py @@ -706,6 +706,78 @@ class TheEffortARequestThatNamesNoneGets(unittest.TestCase): self.assertEqual((rc, self.choice.read_text()), (0, "xhigh\n"), out) +class CopiesDeletedAreTheLoadsToMakeAgain(unittest.TestCase): + """The cockpit's Library deletes the lane's copies of its n-gram table (2026-11-30, discussion 78). --units-only, which + every update runs, rendered the unit without them: the lane read its table from the cache's disk with no word of it, + five times slower from a USB SSD, and the Load of a lane already at boot, which only starts a unit that lacks + nothing, never made them again; an update with the room copied 32 GB back instead. The unit keeps naming the copies + it read, lanes.sh's unit_needs says they are missing, and the lane's Load (its --stage) makes them again.""" + + run_lines = TheEffortARequestThatNamesNoneGets.run_lines + + def setUp(self): + self.box = Box() + self.cfg = self.box.home / ".config" / "qwen38" + self.folder = self.box.t / "copies" + rc, out = self.box.stage(FLASH_LOCAL_PLE_DIR=str(self.folder)) + self.assertEqual(rc, 0, out) + self.unit = self.box.units / "qwen38-flash-local.service" + shutil.copy(self.box.out, self.unit) # its first Load put it in place + + def tearDown(self): + shutil.rmtree(self.box.t, ignore_errors=True) + + def units_only(self): + """The table's mounts and the unit, by --units-only's own lines.""" + rc, out = self.run_lines("units", f'lane_table mounts\nrender_unit "{self.box.out}"', INSTALLED=str(self.unit), + FLASH_LOCAL_TABLE_GB=PINS["FLASH_LOCAL_TABLE_GB"]) + self.assertEqual(rc, 0, out) + return out + + def needs(self): + r = subprocess.run(["bash", "-c", f'set -euo pipefail; CONFIG_DIR="{self.cfg}"; . "{REPO}/lanes.sh"; unit_needs "{self.unit}"'], + capture_output=True, text=True, timeout=60, + env={"PATH": f"{self.box.t}/bin:/usr/bin:/bin", "HOME": str(self.box.home)}) + self.assertEqual(r.returncode, 0, r.stderr) + return [ln for ln in r.stdout.splitlines() if ln.startswith("table ")] + + def test_the_unit_keeps_naming_them_until_its_load_makes_them_again(self): + (self.box.t / "bin").mkdir() + (self.box.t / "bin" / "docker").write_text("#!/bin/bash\nexit 0\n") # its image is here + (self.box.t / "bin" / "docker").chmod(0o755) + want = [str(self.folder / s) for s in self.box.table] + self.assertEqual(self.needs(), []) + for gone in (self.box.table[:1], self.box.table): # one of the two, then both + with self.subTest(gone=len(gone)): + for s in gone: + (self.folder / s).unlink(missing_ok=True) + out = self.units_only() + self.assertEqual(self.box.mounts(), want, out) + self.assertIn("it does not start until its next Load", out) + # (the harness names its image img) + self.assertEqual(self.box.out.read_text().replace("\n img \\", f"\n {PINS['FLASH_LOCAL_IMAGE']} \\"), + self.unit.read_text(), "the update changed the unit in place") + self.assertEqual(self.needs(), + [f"table {self.folder} ({len(gone)} of the 2 copies of its n-gram table)"]) + rc, out = self.box.stage() # its Load: they are there again, the unit the same + self.assertEqual(rc, 0, out) + self.assertEqual(sorted(p.name for p in self.folder.iterdir() if not p.name.startswith(".")), sorted(self.box.table)) + self.assertEqual((self.box.mounts(), self.needs()), (want, [])) + + def test_a_unit_that_never_named_them_is_rendered_as_before(self): + self.unit.write_text(self.unit.read_text().replace(str(self.folder), str(self.box.t / "elsewhere"))) + for s in self.box.table: + (self.folder / s).unlink() + out = self.units_only() + self.assertEqual(self.box.mounts(), [], out) + self.assertIn("the lane reads the table from the cache's disk until its next Load", out) + + def test_a_copy_whose_original_is_not_in_the_cache_is_not_its_lack(self): + # the checkpoint deleted, its copies kept: unit_needs says the checkpoint, not its copies + shutil.rmtree(self.box.hf / "hub" / HUB) + self.assertEqual(self.needs(), []) + + class TheLoadSetsTheClientsForTheWindow(unittest.TestCase): """A Load of the FP4-Local lane gives opencode (and through its config pi and claude-local) the pair of the window its unit runs (FLASH_LOCAL_CONTEXT=1m, v1.45.2). It added the provider when it was missing and never touched one already diff --git a/tests/test_ple_table.py b/tests/test_ple_table.py index 3258a3e2..f0f9d6ad 100644 --- a/tests/test_ple_table.py +++ b/tests/test_ple_table.py @@ -247,6 +247,19 @@ class TableFiles(unittest.TestCase): self.assertEqual(r.returncode, 1) self.assertEqual(r.stdout, "") + def test_named_gives_the_same_line_while_the_copies_are_not_there(self): + # what the installer keeps in a unit whose copies went (deleted from the cockpit's Library, 2026-11-30) + folder = self.d / "copies" + self.assertEqual(self.run_it("copy", "--dir", str(folder)).returncode, 0) + line = self.run_it("mounts", "--dir", str(folder)).stdout + self.assertTrue(line.strip()) + for sha in self.cache.table: + (folder / sha).unlink() + self.assertEqual(self.run_it("mounts", "--dir", str(folder)).returncode, 1) + r = self.run_it("named", "--dir", str(folder)) + self.assertEqual((r.returncode, r.stdout), (0, line), r.stderr) + self.assertEqual(self.run_it("named", "--dir", "none").stdout, "") + def test_an_empty_or_cut_copy_is_no_copy_to_mount(self): # mounts took any file for a copy: an empty one, which the unit's check refuses at every # start, went into the unit (found in review, 2026-10-20) diff --git a/tests/test_unit_pending.py b/tests/test_unit_pending.py index 73ee4ac4..1b902ad5 100644 --- a/tests/test_unit_pending.py +++ b/tests/test_unit_pending.py @@ -161,6 +161,30 @@ class UnitNeeds(unittest.TestCase): tmpl.write_text("{{ messages }}\n") self.assertEqual(self.b.needs(text), []) + def test_the_copies_of_the_table_the_fp4_local_lane_mounts(self): + # deleted from the cockpit's Library, they were no lack of the unit: install.sh then updated the lane whole, and + # copied 32 GB back onto the disk they had just left (2026-11-30). One line for them all. + hub = "hub/models--nvidia--Qwen3.8-Flash-Next-FP4-Local" + self.b.ckpt("nvidia/Qwen3.8-Flash-Next-FP4-Local", REV1) + (self.b.hf / hub / "blobs").mkdir() + copies = self.b.d / "flash-local-ple" + copies.mkdir() + names = [c * 64 for c in "ab"] + for n in names: + (self.b.hf / hub / "blobs" / n).write_bytes(b"table") + (copies / n).write_bytes(b"table") + text = (f"ExecStart=/bin/bash -c 'exec /usr/bin/docker run -v {self.b.hf}:/root/.cache/huggingface \\\n " + + " ".join(f"-v {copies}/{n}:/root/.cache/huggingface/{hub}/blobs/{n}:ro" for n in names) + + f" \\\n {OLD_IMG} \\\n vllm serve nvidia/Qwen3.8-Flash-Next-FP4-Local --revision {REV1} \\\n --port 30000'\n") + self.assertEqual(self.b.needs(text), []) + (copies / names[0]).write_bytes(b"tab") # cut short + self.assertEqual(self.b.needs(text), [f"table {copies} (1 of the 2 copies of its n-gram table)"]) + for n in names: + (copies / n).unlink() + self.assertEqual(self.b.needs(text), [f"table {copies} (2 of the 2 copies of its n-gram table)"]) + # nothing of it is read of a unit that names none + self.assertEqual(self.b.needs(self.b.text()), []) + def test_a_text_encoder_the_unit_names_by_its_path(self): # the image-h3 lane's unit loads MiniMax-H3's text_encoder by its folder at the pinned revision # (qwen38-image-h3.service.template's --text-encoder-path): a pin that moved and was never fetched is a