setup: the 200K step is never the recommended context (#608)

ram_ctx() skips 204800: where 200K fits and 256K does not, the rule stays at 128K. A test covers every RAM size.
This commit is contained in:
Niko1221 committed 2026-10-05 15:58:38 +02:00
1 parent 3982b2250a
commit 4f41b51c6b
2 files changed
+11 -2

No files matched your search

+4 -2
View File
@@ -2677,8 +2677,10 @@ def ctx_ram_need(model, ctx, low_ram=False):
def ram_ctx(model, ram, low_ram=False) -> int:
"""#406: the longest context the RAM rule recommends: 128K, or longer where the estimate fits this PC's RAM. It
is part of the recommended default (the smaller of it and the GPU's rule); a longer choice is kept, with a note."""
return max(c for c in CONTEXTS if c <= 131072 or (ctx_ram_need(model, c, low_ram) or 0) <= ram)
is part of the recommended default (the smaller of it and the GPU's rule); a longer choice is kept, with a note.
The 200K menu step is never the recommendation (#608)."""
# 204800 (#608) is a menu step between 128K and 256K, never the recommendation: where 256K does not fit, 128K stays
return max(c for c in CONTEXTS if c <= 131072 or (c != 204800 and (ctx_ram_need(model, c, low_ram) or 0) <= ram))
def settings_path() -> Path:
+7
View File
@@ -89,6 +89,13 @@ class Context(unittest.TestCase):
self.assertEqual(setup.ram_ctx("IQ3_XXS", 95.8), 524288) # 43 + 7.2 + 24 GB fits 96
self.assertEqual(setup.ram_ctx("IQ3_S", 76.5), 131072)
self.assertEqual(setup.ram_ctx("IQ3_S", 78.5), 262144)
# #608: where the 200K estimate fits and the 256K one does not, the rule stays at 128K (200K is a menu step)
self.assertLessEqual(setup.ctx_ram_need("IQ3_S", 204800), 78.5)
self.assertGreater(setup.ctx_ram_need("IQ3_S", 262144), 77.5)
self.assertEqual(setup.ram_ctx("IQ3_S", 77.5), 131072)
for ram in range(16, 200):
for model in ("IQ3_S", "IQ3_XXS", "Q2_0"):
self.assertNotEqual(setup.ram_ctx(model, float(ram)), 204800)
self.assertEqual(setup.ram_ctx("Q2_0", 31.9), 524288) # other sizes: no RAM rule
self.assertEqual(setup.ram_ctx("IQ3_XXS", 31.9, low_ram=True), 524288) # the KV cache is in VRAM there
self.assertIsNone(setup.ctx_ram_need("IQ3_XXS", 262144, low_ram=True))