launch --plan: a part that is already on disk is not listed as a download, and a draft layer or picture reader found in the data folder is not counted
This commit is contained in:
1 parent
79cb59c574
commit
dcbaa992d2
2 files changed
+21
-12
No files matched your search
@@ -1049,24 +1049,20 @@ class Runner:
|
||||
from strata_control.discovery import MMPROJ_GB, MTP_FETCH_GB
|
||||
s = self.s
|
||||
st = self.model_state()
|
||||
parts = [{"kind": p.kind, "label": p.label, "gb": round(p.gb, 1)} for p in st.parts]
|
||||
fresh = any(p.kind == "weights" for p in st.parts) and not st.own_files
|
||||
parts = [{"kind": p.kind, "label": p.label, "gb": round(p.gb, 1)} for p in st.parts if p.gb >= 0.05] # a part already on disk is not a download
|
||||
row = self.row()
|
||||
helpers = s.family in ("qwen", "swift", "coder", "unsloth")
|
||||
wants_pictures = s.vision not in (None, "off") and row is not None and bool(row.images)
|
||||
have = {p["kind"] for p in parts}
|
||||
if fresh and helpers:
|
||||
if s.mtp != "off":
|
||||
parts.append({"kind": "mtp", "label": "the draft layer", "gb": MTP_FETCH_GB})
|
||||
if wants_pictures:
|
||||
parts.append({"kind": "mmproj", "label": "the picture reader", "gb": MMPROJ_GB})
|
||||
elif st.own_files and helpers:
|
||||
# the person's files come with no draft layer or picture reader: setup fetches them next to the prepared data, unless they are there
|
||||
if helpers and (st.own_files or not st.installed):
|
||||
# a model that is not set up yet (or the person's own files) comes without the draft layer and the picture reader: setup fetches them
|
||||
# next to the prepared data, unless they are there already
|
||||
have = {p["kind"] for p in parts}
|
||||
try:
|
||||
data = Path(st.folder) if st.folder else (self.existing_data_dir() or self.catalog.data_dir())
|
||||
data = Path(st.folder) if st.folder else (Path(s.data_dir) if s.data_dir else (self.existing_data_dir() or self.catalog.data_dir()))
|
||||
if s.mtp != "off" and "mtp" not in have and not (data / "mtp" / "rt" / "experts.bin").is_file():
|
||||
parts.append({"kind": "mtp", "label": "the draft layer", "gb": MTP_FETCH_GB})
|
||||
if wants_pictures and "mmproj" not in have and not list((data / "models").glob("mmproj*.gguf")):
|
||||
has_reader = list((data / "models").glob("mmproj*.gguf")) or list((data / "Models").glob("mmproj*.gguf"))
|
||||
if wants_pictures and "mmproj" not in have and not has_reader:
|
||||
parts.append({"kind": "mmproj", "label": "the picture reader", "gb": MMPROJ_GB})
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
@@ -201,6 +201,19 @@ class PlanWords(Base):
|
||||
out = self.plan_text("--model-path", str(folder), "--vision", "off")
|
||||
self.assertIn("About 5.2 GB to download: the draft layer (5.2 GB). Your model files are used where they are.", out)
|
||||
|
||||
def test_a_model_whose_files_are_all_on_disk_does_not_list_a_zero_download(self):
|
||||
from strata_cli.launch.modelstate import ModelState, Part
|
||||
data = self.base / "d"
|
||||
(data / "mtp" / "rt").mkdir(parents=True)
|
||||
(data / "mtp" / "rt" / "experts.bin").write_bytes(b"x")
|
||||
whole = ModelState(installed=False, parts=[Part("weights", "the model", 0.0)], on_disk_gb=66.4, total_gb=66.4)
|
||||
with mock.patch.object(Runner, "model_state", return_value=whole):
|
||||
out = self.plan_text("--model", "q2_0", "--data-dir", str(data), "--vision", "off")
|
||||
self.assertIn("download Nothing to download: the model is already on this computer.", out)
|
||||
out = self.plan_text("--model", "q2_0", "--data-dir", str(self.base / "other"), "--vision", "off")
|
||||
self.assertIn("About 5.2 GB to download: the draft layer (5.2 GB). 66 GB of the model is already in its folder.", out)
|
||||
self.assertNotIn("0.0 GB", out)
|
||||
|
||||
def test_json_plan_carries_the_numbers(self):
|
||||
code, out, err = run_cli(["launch", "--plan", "--output", "json", "--model", "q2_0", "--mtp", "off", "--vision", "off"])
|
||||
self.assertEqual(code, 0, err)
|
||||
|
||||
Reference in new issue
Block a user