fix(setup): the Inkling expert caps are rounded up, so a plan that holds every expert in the card never leaves the last ones on the host

setup wrote --vram-experts-gb / --ram-experts-gb with "%.2f" of the plan's GiB, rounded to nearest. A plan that fills the card with every expert
sits exactly on the experts' bytes, so any rounding down (or a table that is a little low) cuts the last expert off: rc0 on an RTX 5090, UD-Q4_K_XL,
wrote --vram-experts-gb 14.42 (the table's 15.48 GB; the file's experts are 15.80 GB) and the engine loaded 3034 experts on the card and 38 on the
host, the hybrid path (hyb=1).

Measured on the 5090 (strata-inkling, same binary, drafter off, one request): with the 0.2.20 flags (--vram-experts-gb 15.48) all 3072 experts
resident, prefill 4264 tok/s on a 4096-token prompt, decode 136; with rc0's flags 38 on the host, prefill 3968 (-6.9%), decode 131.6-132.0 (-3.3%);
with the cap written by this commit (14.76 GiB) all 3072 resident again, prefill 4257, decode 131.7-132.0. Greedy tokens are identical in the three
(the host experts are not what changed the fingerprint GRID saw).

- setup.inkling_expert_flags: both caps are rounded UP to the 0.01 GiB the flag carries; a plan with every expert in the card (full_vram) gets 0.05
  GiB of slack (about 11 experts).
- test_inkling_fit_free: no figure is rounded below itself; UD-Q4_K_XL on a 32 GB card gets a cap of at least its real 15.80 GB + 0.05 and less than
  5% more.
This commit is contained in:
Niko1221 committed 2026-11-23 18:25:48 +01:00
1 parent 617aa3f607
commit 6bdebbedf5
2 files changed
+25 -4

No files matched your search

+6 -2
View File
@@ -10461,8 +10461,12 @@ def inkling_pc(gpu, ram) -> tuple:
def inkling_expert_flags(placed) -> list:
"""--vram-experts-gb / --ram-experts-gb for a planner placement. The planner counts GB (10^9 bytes); strata-inkling reads the two
flags as GiB (2^30 bytes): written as they were, the engine's cap sat 7.4% above the plan (#6792)."""
return ["--vram-experts-gb", f"{placed['vram_gb'] / inkling_fit.GIB_TO_GB:.2f}",
"--ram-experts-gb", f"{placed['ram_gb'] / inkling_fit.GIB_TO_GB:.2f}"]
# Rounded UP to the 0.01 GiB the flag carries: an exact figure rounded down cuts the last expert off (UD-Q4_K_XL: 15.48 GB written as 14.42 GiB left
# 38 of 3072 experts on the host, the hybrid path, 6% slower), and a plan that holds every expert in the card gets 0.05 GiB (about 11 experts) of slack.
slack = 0.05 if placed.get("full_vram") else 0.0
up = lambda gb, extra=0.0: math.ceil((gb / inkling_fit.GIB_TO_GB + extra) * 100 - 1e-6) / 100 # noqa: E731
return ["--vram-experts-gb", f"{up(placed['vram_gb'], slack):.2f}",
"--ram-experts-gb", f"{up(placed['ram_gb']):.2f}"]
def inkling_plan_extra(gpu) -> dict:
@@ -55,8 +55,25 @@ class FreeMemoryPlan(unittest.TestCase):
got = S.inkling_expert_flags(placed)
self.assertEqual(got[0], "--vram-experts-gb")
self.assertEqual(got[2], "--ram-experts-gb")
self.assertAlmostEqual(float(got[1]), 7.75 / 1.073741824, places=2) # 7.22 GiB, not 7.75
self.assertAlmostEqual(float(got[3]), 0.85 / 1.073741824, places=2)
self.assertAlmostEqual(float(got[1]), 7.75 / 1.073741824, delta=0.011) # 7.22 GiB, not 7.75 (rounded up to the flag's 0.01)
self.assertAlmostEqual(float(got[3]), 0.85 / 1.073741824, delta=0.011)
self.assertGreaterEqual(float(got[1]), 7.75 / 1.073741824)
self.assertGreaterEqual(float(got[3]), 0.85 / 1.073741824)
def test_a_flag_never_cuts_an_expert_off_a_plan_that_holds_them_all(self):
"""UD-Q4_K_XL on a 32 GB card: the experts are 15.80 GB (3072 of them, 4.48 MB each in the NVFP4 layers). The cap written for the plan must
hold every one: the 14.42 GiB of the old table (15.48 GB) left 38 experts on the host and put the engine on the hybrid path (RTX 5090:
prefill -5.8%, decode -2.6%)."""
placed = F.place("UD-Q4_K_XL", 31.0, 64, False, 32768, False, dspark=False, backend="cuda", ram_free_gib=56.0)
self.assertTrue(placed["full_vram"], placed)
cap_gb = float(S.inkling_expert_flags(placed)[1]) * 1.073741824
self.assertGreaterEqual(cap_gb, 15.80 + 0.05) # the real bytes of the experts, and slack
self.assertLess(cap_gb, 15.80 * 1.05)
for gb in (0.0, 1.234, 8.0, 14.7119): # no figure is ever rounded below itself
p = {"vram_gb": gb, "ram_gb": gb / 3, "full_vram": False}
f = S.inkling_expert_flags(p)
self.assertGreaterEqual(float(f[1]) * 1.073741824 + 1e-9, gb)
self.assertGreaterEqual(float(f[3]) * 1.073741824 + 1e-9, gb / 3)
class MaxContext(unittest.TestCase):