Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/script/ci/test_devkit_bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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):
Expand Down
18 changes: 14 additions & 4 deletions .github/script/devkit-bench/select_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down
Loading