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: a free-form --context past the menu got a raw StopIteration

Jakub Luwierski00db760854d6
diff --git a/setup.py b/setup.py
index bca08616e..d218ee122 100644
--- a/setup.py
+++ b/setup.py
@@ -1591,7 +1591,11 @@ def write_run_script(model, cfg_path, port):
# ------------------------------------------------------------------------------------------------ the rope config
def covering_factor(ctx: int, trained: int = 262144) -> float:
"""The smallest extension factor on the safe side that covers a chosen context."""
- return next(f for f in (1.5, 2.0) if trained * f >= ctx)
+ for f in (1.5, 2.0, 3.0, 4.0):
+ if trained * f >= ctx:
+ return f
+ raise ValueError(f"a {ctx} token context is {ctx / trained:.1f}x the trained 262144 - past anything this "
+ "setup picks a factor for: pass --rope-scale explicitly if you know what you are asking for")
def resolve_rope(ctx: int, scaling, scale, trained: int = 262144):
@@ -1910,14 +1914,14 @@ def main() -> int:
f"({MODELS[model]['arena_gb']:.0f} GB of experts + the context + room for the rest): using 128K")
ctx = 131072
scaling = a.rope_scaling
- if ctx > 262144 and scaling is None:
- # the automatic path the docs promise: one question when interactive (yarn preselected), the
- # silent default with --yes - llama.cpp's extension method, recall-tested here at 512K
+ if ctx > 262144 and scaling is None and not a.yes:
+ # the interactive path: one question, yarn preselected (llama.cpp's extension method, recall-tested
+ # here at 512K). With --yes nothing prints: resolve_rope takes yarn below and the ok() line says so.
say()
say(f" A {ctx // 1024}K context runs the model past its trained 262,144 positions: the rotary angles")
say(" get rescaled (llama.cpp's RoPE extension). yarn keeps the trained angles on the high-frequency")
say(" pairs and corrects the magnitudes; linear shrinks every angle. Override any time with")
- say(" --rope-scaling; with --yes the setup takes yarn without asking.")
+ say(" --rope-scaling.")
scaling = ask("RoPE extension method?", ["yarn", "linear"], "yarn", a.yes)
try:
scaling, rope_scale = resolve_rope(ctx, scaling, a.rope_scale)
diff --git a/tools/test_setup_rope.py b/tools/test_setup_rope.py
index 3d4d8b114..c81c3fddc 100644
--- a/tools/test_setup_rope.py
+++ b/tools/test_setup_rope.py
@@ -24,6 +24,14 @@ class CoveringFactor(unittest.TestCase):
def test_the_first_gap_takes_the_bigger_factor(self):
self.assertEqual(setup.covering_factor(393217), 2.0) # one token past 1.5's reach
+ def test_a_free_form_context_past_the_menu_gets_the_next_factor(self):
+ self.assertEqual(setup.covering_factor(600000), 3.0) # --context is not limited to the menu
+
+ def test_a_context_past_the_whole_ladder_is_a_clean_refusal(self):
+ with self.assertRaises(ValueError) as cm:
+ setup.covering_factor(1048577) # 262144 * 4 is the last rung
+ self.assertIn("--rope-scale", str(cm.exception))
+
class ResolveRope(unittest.TestCase):
# ---- the automatic flow the docs promise (an omitted flag, --yes or the interactive default)