Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

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

Niko12214f41b51c6bd4
diff --git a/setup.py b/setup.py
index 6b8fb56d6..fa5bc4c36 100644
--- a/setup.py
+++ b/setup.py
@@ -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:
diff --git a/tools/test_setup_risk.py b/tools/test_setup_risk.py
index 6ba79d0f0..0cce52696 100644
--- a/tools/test_setup_risk.py
+++ b/tools/test_setup_risk.py
@@ -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))