ling32 launcher: the NVIDIA 12 GB class takes chunk 2048 (class edge 11.5 GiB, by the card's own size, not the memory free)

L32-SMALL, RTX 5070 12 GB with the pool regrow: PCIe 5.0 prefill 4K / 16K / 32K 595 / 583 / 493 tok/s at chunk 256 against 915 / 1237 / 1134 at 2048, decode 38.8 against 39.4; PCIe 4.0 x4 (tier C)
187 / 335 / 350 against 284 / 669 / 777, decode 10.9 against 11.0.  A picture plus a 36K-token prompt at chunk 2048 loaded and answered with no out-of-memory (rc 0; the pool lent 640 slots, 2790 MiB, to the
prefill scratch and regrew them; peak 11.2 of 11.5 GiB).  The 8, 10 and 11 GB cards (2080 Ti, 1080 Ti, 3080 10G) stay at 256; only real 12 GB cards (3060 12G, 4070, 5070, 3080 12G) move.
ling32_fit.chunk_for / plan / advise take the card's own size (card_gib) where setup knows it, so a 12 GB card with the desktop holding a GiB or more still counts as 12 GB.  Tests: the class table and the card-size rule.
This commit is contained in:
Niko1221 committed 2026-12-03 02:48:59 +01:00
1 parent 137161c2b4
commit cd836c6264
4 files changed
+24 -17

No files matched your search

+3 -3
View File
@@ -10849,11 +10849,11 @@ def ling32_fetch_mtp(a, folder: Path, own: bool, model: Path | None = None, extr
def ling32_engine_args(a, vram_gib, ram_gib, unified, ctx, vision: bool = False, vision_device: str = "auto", gpu_cap_gib: float | None = None, mtp: bool = False,
backend: str = "cuda") -> tuple[list, dict]:
backend: str = "cuda", card_gib: float | None = None) -> tuple[list, dict]:
"""The engine arguments of a Ling-3.2-Air start and the plan they come from: the fast path (explicit, so a start never depends on a default that may move), the context and
chunk, then the person's tier choices as flags (ling32_fit.tier_args: nothing for `auto`: the engine plans by itself with the same rule). Returns (args, advise()'s dict)."""
adv = ling32_fit.advise(vram_gib, ram_gib, unified=unified, tier=getattr(a, "tier", None) or "auto", vram_budget_gib=getattr(a, "vram_budget_gib", None) or 0.0,
ram_budget_gib=getattr(a, "ram_budget_gib", None) or 0.0, turbo_ssd=bool(getattr(a, "turbo_ssd", False)), ctx=ctx, vision=vision, vision_device=vision_device, gpu_cap_gib=gpu_cap_gib, mtp=mtp, backend=backend)
ram_budget_gib=getattr(a, "ram_budget_gib", None) or 0.0, turbo_ssd=bool(getattr(a, "turbo_ssd", False)), ctx=ctx, vision=vision, vision_device=vision_device, gpu_cap_gib=gpu_cap_gib, mtp=mtp, backend=backend, card_gib=card_gib)
args = ["--ctx", str(ctx), "--chunk", str(adv["plan"]["chunk"]), *ling32_family.ENGINE_FLAGS.get(backend, ling32_family.ENGINE_FLAGS["cuda"])]
if backend == "metal": # no tiers on a Mac: the whole model is in memory
return args, adv
@@ -10983,7 +10983,7 @@ def install_ling32_air(a, family, gpu, hip, amd, cuda_tk, multi, port, ram, adop
pv = folder / ling32_family.VISION_FILE
if not ling32_have(a, pv):
left += (ling32_family.FILES[ling32_family.VISION_FILE][0] - (pv.with_name(pv.name + ".part").stat().st_size if pv.with_name(pv.name + ".part").is_file() else 0)) / 1e9
args_fit, adv = ling32_engine_args(a, vram_gib, ram_gib, unified, ctx, vision, plan_vision_device, mtp=mtp_plan, backend=backend)
args_fit, adv = ling32_engine_args(a, vram_gib, ram_gib, unified, ctx, vision, plan_vision_device, mtp=mtp_plan, backend=backend, card_gib=(gpu or {}).get("vram_gb"))
say()
p = adv["plan"]
if backend == "metal": # a Mac keeps the whole model in one memory pool, no tiers: no hard minimum, a clear warning below the recommendation
+13 -9
View File
@@ -313,13 +313,14 @@ def describe(p: dict) -> str:
#: The card classes by NOMINAL size. A card reports a little less than its name (a 16 GB card 15.9 GiB, a 24 GB card 23.5, a 32 GB card 31.4, a 48 GB card 47.5) and the launcher passes the memory free
#: after the desktop took its share, so each class starts well below its name: 14 GiB and up is a 16 GB card, 20 and up a 24 GB card, 27 and up a 32 GB card, 44 and up a 48 GB card. No card is made in between.
CLASS_12_GIB = 11.5 # a real 12 GB card (3060 12G, 4070, 5070, 3080 12G: 11.6 to 12.0 GiB); the 11 GB cards (2080 Ti, 1080 Ti) and the 10 GB 3080 stay below it
CLASS_16_GIB = 14.0
CLASS_24_GIB = 20.0
CLASS_32_GIB = 27.0
CLASS_48_GIB = 44.0
def chunk_for(vram_gib: float | None, unified: bool = False, backend: str | None = None) -> int:
def chunk_for(vram_gib: float | None, unified: bool = False, backend: str | None = None, card_gib: float | None = None) -> int:
"""The prompt chunk the launcher starts the engine with, by the card's nominal class. The activation buffers scale with it (0.6 GiB at 256, about 2 GiB at 2048), and on a card that runs the pool
layout every byte of them is a pool slot, so a card with little memory takes a small chunk: the 8 and 12 GB classes 256. But the layer-major span prefill runs sub-chunks of `--chunk` rows, so a
small chunk multiplies the per-sub-chunk work and starves the tensor-core tiles: L32-CUDA measured on an RTX 5090 (tier B, plain decode unaffected) a 4062-token prompt 33 % slower and a
@@ -327,15 +328,18 @@ def chunk_for(vram_gib: float | None, unified: bool = False, backend: str | None
(1525 with 2048) for 1 to 3 % better decode. L32-CUDA then measured 1024 / 2048 / 4096 on an RTX 3090 and 4090 (24 GB, ctx 131072, tier B pool, PCIe 4.0 x16): 2048 reads a 16K prompt 19 % /
24 % faster than 1024 and a 4K prompt 8 % faster for 0.7 / 2.6 % less decode, 4096 adds only 11 % more for 8 % less decode; a 120K prompt at 2048 ran through with no allocation failure (the lazy
KV gives pool slots back as it grows). The pool regrow (f-ling32-int 9d71124e4c: on NVIDIA wherever the chunk is 2048 or more, it gives the bigger chunk's scratch back to the pool after the prefill) took away the decode cost: on an RTX 3090
24 GB decode +3.4 % and prefill +13 / +15 % at 4K / 16K, on an RTX A4000 16 GB prefill +21 / +18 % with decode flat (L32-SMALL, greedy ids identical). So on NVIDIA: the 8 and 12 GB classes 256, the 16 GB
24 GB decode +3.4 % and prefill +13 / +15 % at 4K / 16K, on an RTX A4000 16 GB prefill +21 / +18 % with decode flat (L32-SMALL, greedy ids identical). L32-SMALL then measured the 12 GB class with the regrow: an RTX 5070 on PCIe 5.0 prefill 4K / 16K / 32K 595 / 583 / 493 tok/s at chunk 256 against 915 / 1237 / 1134 at 2048, decode 38.8 against 39.4; the same card on
PCIe 4.0 x4 (tier C) 187 / 335 / 350 against 284 / 669 / 777, decode 10.9 against 11.0. So on NVIDIA: the 8 / 10 / 11 GB classes 256, the 12 GB class (11.5 GiB and up) and the 16 GB
class and up the engine's own default 2048, from the 48 GB class the static layout keeps 1024 (a bigger chunk takes hot ranks). AMD keeps 1024 below its 32 GB class (no regrow on a Radeon yet), Intel Arc 1024 below 20 GiB."""
if unified or not vram_gib:
return 1024
if card_gib and float(card_gib) > vram_gib: # the class is the card's own size where it is known (the memory free after the desktop took its share must not move a 12 GB card to the 11 GB class)
vram_gib = float(card_gib)
if str(backend or "").lower() == "hip" and vram_gib < CLASS_32_GIB: # AMD: the pool regrow (it gives the bigger chunk's scratch back after the prefill) is NVIDIA-only until it has run on a Radeon (L32-CUDA): the 16 and 24 GB classes keep 1024 (the 32 GB class is the engine's own default, the R9700 measurement)
return 256 if vram_gib < CLASS_16_GIB else 1024
if str(backend or "").lower() == "sycl" and vram_gib < CLASS_24_GIB: # Intel Arc (L32-SYCL): 1024 on the 8 to 16 GiB cards (A750, B580); the 20 to 44 GiB class takes 2048 like everywhere
return 1024
if vram_gib < CLASS_16_GIB:
if vram_gib < CLASS_12_GIB:
return 256
return 2048 if vram_gib < CLASS_48_GIB else 1024
@@ -411,7 +415,7 @@ def mtp_status_line(spec: str | None, h2d_gbps: float | None, mode: str | None =
def plan(vram_gib: float | None, ram_gib: float, *, unified: bool = False, tier: str = "auto", vram_budget_gib: float = 0.0, ram_budget_gib: float = 0.0,
turbo_ssd: bool = False, ctx: int | None = None, chunk: int | None = None, prefetch: bool = True, vision: bool = False, vision_device: str = "auto",
gpu_cap_gib: float | None = None, ram_floor_gib: float | None = None, mtp: bool = False, spec_block: int | None = None, backend: str | None = None) -> dict:
gpu_cap_gib: float | None = None, ram_floor_gib: float | None = None, mtp: bool = False, spec_block: int | None = None, backend: str | None = None, card_gib: float | None = None) -> dict:
"""The tier plan for a PC. `mtp`: the sidecar is in the start (`mtp_bytes`: the file, its cache for `ctx`, the snapshot ring for `spec_block`, default 4), counted on the card in every tier. `gpu_cap_gib` (a Windows iGPU such as Strix Halo, L32-HIP's measurements; `probe_cap(engine)` gets it: `strata-ling32 --probe-cap`): the most one process can
allocate for the GPU in all (about 63 GiB on a 96 GiB carve-out; what DXGI and hipMemGetInfo say is wrong). The rule of the engine's `--tier auto` on such a GPU: the card budget is
`min(free, cap - 4 GiB)` (the engine keeps 4 GiB), the RAM tier is the available RAM less 8 GiB (the floor, `ram_floor_gib`) less 1.5 GiB, and the RAM tier is NOT counted against the
@@ -422,7 +426,7 @@ def plan(vram_gib: float | None, ram_gib: float, *, unified: bool = False, tier:
# `--mtp auto`: the engine loads the sidecar in tier A and in one memory pool, never in tier C, and in tier B only with a big card pool (4500 experts and more) over a link it measures at start (16 GB/s and more). The plan
# counts it where it is certain (A, unified) and leaves it out otherwise (the common PCIe 4.0 card does not load it), with one note.
args = dict(unified=unified, tier=tier, vram_budget_gib=vram_budget_gib, ram_budget_gib=ram_budget_gib, turbo_ssd=turbo_ssd, ctx=ctx, chunk=chunk, prefetch=prefetch,
vision=vision, vision_device=vision_device, gpu_cap_gib=gpu_cap_gib, ram_floor_gib=ram_floor_gib, spec_block=spec_block, backend=backend)
vision=vision, vision_device=vision_device, gpu_cap_gib=gpu_cap_gib, ram_floor_gib=ram_floor_gib, spec_block=spec_block, backend=backend, card_gib=card_gib)
base = plan(vram_gib, ram_gib, mtp=False, **args)
if base["ok"] and (base["mode"] == "A" or unified):
got = plan(vram_gib, ram_gib, mtp=True, **args)
@@ -451,7 +455,7 @@ def plan(vram_gib: float | None, ram_gib: float, *, unified: bool = False, tier:
vision_vram=ev + eh + mv, vision_host=0)
got["notes"].append("one memory pool: the part of the file that does not fit it is read from the SSD")
else:
ch = chunk or chunk_for(vram_gib, backend=backend)
ch = chunk or chunk_for(vram_gib, backend=backend, card_gib=card_gib)
ram_hw = float(ram_gib)
if gpu_cap_gib:
# the engine hands plan_tier these as HARDWARE (its own 600 MiB margin and 6 GiB headroom come on top): card = min(free, cap - 4 GiB), RAM = available - 8 GiB floor - 1.5 GiB
@@ -485,7 +489,7 @@ def plan(vram_gib: float | None, ram_gib: float, *, unified: bool = False, tier:
for big in [c for c in (top, 2048) if got["chunk"] < c <= top]: # the engine's own, else half of it: the largest that still keeps every expert on the card
again = plan(vram_gib, ram_gib, unified=unified, tier=tier, vram_budget_gib=vram_budget_gib, ram_budget_gib=ram_budget_gib, turbo_ssd=turbo_ssd, ctx=ctx, chunk=big,
prefetch=prefetch, vision=vision, vision_device=vision_device, gpu_cap_gib=gpu_cap_gib, ram_floor_gib=ram_floor_gib, mtp=mtp,
spec_block=spec_block, backend=backend)
spec_block=spec_block, backend=backend, card_gib=card_gib)
if again["ok"] and again["mode"] == "A":
return again
return got
@@ -556,12 +560,12 @@ def disk_gb(vision: bool = True) -> float:
def advise(vram_gib: float | None, ram_gib: float, *, unified: bool = False, disk_free_gb: float | None = None, ssd_gbps: float | None = None, tier: str = "auto",
vram_budget_gib: float = 0.0, ram_budget_gib: float = 0.0, turbo_ssd: bool = False, ctx: int | None = None, vision: bool = True, vision_device: str = "auto", backend: str = "cuda",
gpu_cap_gib: float | None = None, mtp: bool = False) -> dict:
gpu_cap_gib: float | None = None, mtp: bool = False, card_gib: float | None = None) -> dict:
"""What the launcher shows for a PC: the plan, the speed class, the engine flags the choices need and the warnings (never a refusal). `vision` (on by default, like the download
set): the picture encoder's memory is in the plan (GPU encoder: 829 MiB of weights + activations on a card of 24 GiB or more; CPU encoder: about 1 GiB of host memory) and the
Vision shard is in the disk need. Returns {"plan", "tier", "speed", "args", "warnings", "fits", "download_gb"}."""
p = plan(vram_gib, ram_gib, unified=unified, tier=tier, vram_budget_gib=vram_budget_gib, ram_budget_gib=ram_budget_gib, turbo_ssd=turbo_ssd, ctx=ctx, vision=vision,
vision_device=vision_device, gpu_cap_gib=gpu_cap_gib, mtp=mtp, backend=backend)
vision_device=vision_device, gpu_cap_gib=gpu_cap_gib, mtp=mtp, backend=backend, card_gib=card_gib)
warns: list[str] = list(p["notes"])
if not p["ok"]:
warns.append(p["error"])
+7 -4
View File
@@ -291,15 +291,18 @@ def test_engine_chunk_rule_and_the_launchers_use_of_it():
def test_the_launcher_chunk_by_card_size():
# L32-CUDA, RTX 5090 tier B: --chunk 256 made a 4062-token prefill 33 % slower and a 32K one 115 % slower than the engine's default; the small chunk stays where memory is the limit
assert [F.chunk_for(g) for g in (8, 11.6, 12, 13.9, 14, 15.0, 15.5, 15.9, 16, 19.9, 20, 22.4, 23.3, 24, 26.9, 27, 29.9, 30, 31.4, 32, 39.5, 43.9, 44, 47.5, 47.9, 48, 96)] == [
256, 256, 256, 256, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1024, 1024, 1024, 1024, 1024]
assert [F.chunk_for(g) for g in (8, 11.4, 11.5, 11.6, 12, 13.9, 14, 15.0, 15.5, 15.9, 16, 19.9, 20, 22.4, 23.3, 24, 26.9, 27, 29.9, 30, 31.4, 32, 39.5, 43.9, 44, 47.5, 47.9, 48, 96)] == [
256, 256, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 1024, 1024, 1024, 1024, 1024]
# the nominal classes: a 16 GB card reports 15.9 GiB (an RTX 5070 Ti), a 24 GB card 23.x, a 32 GB card 31.4, a 48 GB card 47.5; the free memory after the desktop is a little less still
for reported, nominal in ((15.9, 16), (15.5, 16), (14.4, 16), (23.5, 24), (22.4, 24), (20.5, 24), (31.4, 32), (29.0, 32), (47.5, 48), (45.0, 48)):
assert F.chunk_for(reported) == F.chunk_for(nominal), (reported, nominal)
assert F.chunk_for(23.5) == 2048 and F.chunk_for(15.9) == 2048 and F.chunk_for(12) == 256 # 24 GB: L32-CUDA's 3090 / 4090 sweep; 16 GB: MID2 + L32-SMALL's A4000 gate (prefill +18 to +21 % with the pool regrow, decode flat)
assert F.chunk_for(23.5) == 2048 and F.chunk_for(15.9) == 2048 and F.chunk_for(12) == 2048 and F.chunk_for(11.0) == 256 and F.chunk_for(9.8) == 256 # 24 GB: L32-CUDA's 3090 / 4090 sweep; 16 GB: MID2 + L32-SMALL's A4000 gate (prefill +18 to +21 % with the pool regrow, decode flat)
assert F.chunk_for(None) == 1024 and F.chunk_for(0) == 1024 and F.chunk_for(96, unified=True) == 1024
assert p(32, 128)["chunk"] == 2048 and p(24, 128)["chunk"] == 2048 and p(12, 128)["chunk"] == 256
assert p(32, 128)["chunk"] == 2048 and p(24, 128)["chunk"] == 2048 and p(12, 128)["chunk"] == 2048 and p(8, 128)["chunk"] == 256
# the card's own size decides the class where it is known: a 12 GB card with 1.2 GiB used by the desktop (10.8 GiB free) still takes 2048, an 11 GB or 10 GB card does not
assert F.chunk_for(10.8, card_gib=11.95) == 2048 and F.chunk_for(10.0, card_gib=10.7) == 256 and F.chunk_for(9.0, card_gib=9.8) == 256
assert F.plan(10.8, 64, card_gib=11.95)["chunk"] == 2048 and F.advise(10.8, 64, card_gib=11.95)["plan"]["chunk"] == 2048
# the bigger chunk costs pool slots (its activation buffers), a few percent on a 24 GB card
small, big = F.plan(24, 128, chunk=256, ctx=32768), F.plan(24, 128, chunk=1024, ctx=32768)
assert 0 < small["dyn_slots"] - big["dyn_slots"] < 0.1 * small["dyn_slots"]
@@ -582,7 +582,7 @@ class FamilyData(unittest.TestCase):
def test_intel_cards_get_the_chunk_of_their_class_and_no_cuda_tuning_flags(self):
# L32-SYCL: the 20 to 44 GiB class (the 32 GB B70) 2048 like everywhere, the 8 to 16 GiB cards (A750, B580) 1024 (the CUDA rule gives them 256: pool slots), no --tc / --graph / --mla-kernel
self.assertEqual([ling32_fit.chunk_for(g, backend="sycl") for g in (8, 12, 15.9, 19.9, 20, 31.16, 43.9, 44, 96)], [1024, 1024, 1024, 1024, 2048, 2048, 2048, 1024, 1024])
self.assertEqual([ling32_fit.chunk_for(g) for g in (8, 12, 15.9)], [256, 256, 2048]) # NVIDIA: the 16 GB class takes 2048 with the pool regrow
self.assertEqual([ling32_fit.chunk_for(g) for g in (8, 12, 15.9)], [256, 2048, 2048]) # NVIDIA: the 12 GB class (11.5 GiB and up) and the 16 GB class take 2048 with the pool regrow
self.assertEqual([ling32_fit.chunk_for(g, backend="hip") for g in (8, 15.9, 23.5, 26.9, 27, 31.9, 43.9, 47.5)], [256, 1024, 1024, 1024, 2048, 2048, 2048, 1024]) # AMD: no 2048 below the 32 GB class (no pool regrow on a Radeon yet)
self.assertEqual(ling32_fit.plan(23.5, 64.0, backend="hip")["chunk"], 1024)
self.assertEqual(ling32_fit.plan(23.5, 64.0)["chunk"], 2048)