okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-ds-out ac306afb2 into f-own-intaff3a132f

main
3.5 KiB58 linesraw
1"""The one fit label of a model on this computer (owner, 2026-11-08): the model's files, WITHOUT the n-gram / PLE / Engram lookup table file (it stays on the SSD and
2is not counted), against the graphics memory plus the RAM.  They fit: "fits".  They do not: "may run slower".
3
4    size  = the download size minus the lookup table's file (`files_gb`): the owner's literal rule, the "Needs (RAM + VRAM)" column of the Terminal list
5    room  = RAM + the card's memory (the largest card that counts; a chip that shares the RAM only its own carve-out)
6
7No reserve is taken off either side.  Nothing here refuses anything; a model that "may run slower" can still be started, and a computer with no card or a Mac with
8little memory gets the same two words.
9"""
10
11from __future__ import annotations
12
13FITS = "fits"
14SLOWER = "may run slower"
15
16# The lookup table's file, by family (bytes from the pinned shard lists in setup.py; the Hub's LFS pointers):
17#   qwen / swift / coder / unsloth (all but the three big files): the n-gram table, IQ4_NL, 28,800,138,432 bytes, a shard of its own
18#   unsloth UD-Q5_K_XL, UD-Q6_K_XL, Q8_0: the Q8_0 table, shard 3, 54,400,261,312 bytes
19#   nvfp4: the FP8 table `ple-fp8.gguf`, 51,200,246,176 bytes
20#   nvfp4 NVFP4-QAD: its 102.2 GB download is NVIDIA's checkpoint, which this PC converts into the pack that runs; the files that run are the converted pack, the same
21#     size as the other NVFP4 sets (128.0 - 51.2 = 76.8 GB), so that figure is used (owner's rule: the model files that run, minus the table)
22#   gyro: the table is inside the one GGUF; the catalog states the rest (its `ram_gb`: 27.6 / 35 GB), the table is the difference
23#   qwen36 (its own path) has none.  A family this module does not know counts its whole download.
24_GB = 1e9
25_TABLE_BYTES = {"qwen": 28_800_138_432, "swift": 28_800_138_432, "coder": 28_800_138_432, "unsloth": 28_800_138_432, "nvfp4": 51_200_246_176}
26_BIG_UNSLOTH = ("UD-Q5_K_XL", "UD-Q6_K_XL", "Q8_0")
27_BIG_TABLE_BYTES = 54_400_261_312
28_PACK_GB = {("nvfp4", "NVFP4-QAD"): 76.8}        # sets whose download is not the files that run: the size of what runs
29
30
31def table_gb(family: str | None, model: str | None, d: dict) -> float:
32    """The size of the lookup table's file, in GB, of one catalog entry `d` (download_gb, ram_gb, mem_total)."""
33    if d.get("mem_total") or family == "gyro":
34        return max(0.0, float(d["download_gb"]) - float(d["ram_gb"]))
35    if family == "unsloth" and model in _BIG_UNSLOTH:
36        return _BIG_TABLE_BYTES / _GB
37    return _TABLE_BYTES.get(str(family), 0) / _GB
38
39
40def files_gb(family: str | None, model: str | None, d: dict) -> float:
41    """The model's files without the lookup table, in GB (one decimal): the size the label and the "Needs" column use."""
42    if (family, model) in _PACK_GB:
43        return _PACK_GB[(family, model)]
44    return round(float(d["download_gb"]) - table_gb(family, model, d), 1)
45
46
47def card_room_gb(cards: list[dict] | None) -> float:
48    """The graphics memory that counts for one model: the largest card, an integrated chip only for its own carve-out (its shared memory is the RAM)."""
49    best = 0.0
50    for c in cards or []:
51        gb = float(c.get("dedicated_gb") or 0.0) if c.get("uma") else float(c.get("vram_gb") or 0.0)
52        best = max(best, gb)
53    return best
54
55
56def label(size_gb: float, ram_gb: float | None, vram_gb: float | None) -> str:
57    """"fits" when the files are no bigger than the RAM and the card's memory together, else "may run slower"."""
58    return FITS if float(size_gb) <= float(ram_gb or 0.0) + float(vram_gb or 0.0) else SLOWER