diff --git a/.github/script/ci/test_devkit_bench.py b/.github/script/ci/test_devkit_bench.py index 8f0b8dd52..a537545e7 100644 --- a/.github/script/ci/test_devkit_bench.py +++ b/.github/script/ci/test_devkit_bench.py @@ -450,6 +450,20 @@ def test_refresh_benches_the_whole_assigned_set(self): self.assertEqual(res["dropped"], []) self.assertIn("embed-gemma:300m", res["skipped"]) + def test_smallest_is_by_footprint(self): + # A draft package lists a small download but runs in its base model's + # memory: the footprint (GB) orders it, the size only without one. + catalog = select_models.changes.load_catalog(json.dumps({"models": { + "draft": {"e4b": {"size": 2.7e8, "footprint": 8.7, "details": {"family": "draft"}}}, + "tiny": {"1b": {"size": 6e8, "footprint": 0.65, "details": {"family": "tiny"}}}, + "nofoot": {"2b": {"size": 2e9, "details": {"family": "nofoot"}}}, + }})) + self.assertEqual(select_models.ordered(["draft:e4b", "tiny:1b", "nofoot:2b"], catalog), + ["tiny:1b", "nofoot:2b", "draft:e4b"]) + self.assertEqual(select_models.size_of("draft:e4b", catalog), 8.7e9) + self.assertEqual(select_models.size_of("nofoot:2b", catalog), 2e9) + self.assertEqual(select_models.size_of("nosuch:1b", catalog), 0.0) + def test_real_maps_load(self): engines = select_models.changes.DevkitEngines.parse( (REPO / "flm-dev-kit/FLM_DLL/engines.json").read_text(encoding="utf-8")) @@ -461,6 +475,10 @@ def test_real_maps_load(self): res = select_models.select(mode="pr", catalog=catalog, engines=engines, assignment=assignment, families=engines.all_families()) self.assertLessEqual(len(res["models"]), select_models.PR_CAP) + # Shared code samples the engines' smallest models, by what they run + # in: no 8.7 GB dflash draft ahead of the sub-1 GB models. + footprints = [float(catalog[m["model"]].get("footprint") or 0) for m in res["models"]] + self.assertLess(max(footprints), 2.0, res["models"]) def run(**kw): diff --git a/.github/script/devkit-bench/select_models.py b/.github/script/devkit-bench/select_models.py index 48cad430a..dd0d1fd76 100644 --- a/.github/script/devkit-bench/select_models.py +++ b/.github/script/devkit-bench/select_models.py @@ -73,10 +73,20 @@ def benchable(mid: str, catalog: dict[str, dict]) -> bool: def size_of(mid: str, catalog: dict[str, dict]) -> float: - try: - return float(catalog.get(mid, {}).get("size") or 0) - except (TypeError, ValueError): - return 0.0 + """What "smallest first" orders by, in bytes: the model's footprint (GB, + the memory it runs in), else its download size. The download size alone + misleads for a model that reuses another's package: the dflash drafts + list 270 MB of their own files but run in the 8.7 GB of + nemotron3.5-bolt:e4b.""" + entry = catalog.get(mid, {}) + for key, scale in (("footprint", 1e9), ("size", 1.0)): + try: + value = float(entry.get(key) or 0) * scale + except (TypeError, ValueError): + value = 0.0 + if value > 0: + return value + return 0.0 def ordered(models: Iterable[str], catalog: dict[str, dict]) -> list[str]: