setup: a free-form --context past the menu got a raw StopIteration
The triple-check pass found what the menu could not: --context is not limited to CONTEXTS, and the factor ladder (1.5, 2.0) ended at 512K, so `--context 600000` died with a bare traceback instead of a setup message. The ladder extends (3, 4) and a context past its top refuses cleanly, naming --rope-scale as the way out. The interactive explanation block also stays quiet under --yes, whose ok() line announces the choice already.
This commit is contained in:
1 parent
9b83998d9d
commit
00db760854
2 files changed
+17
-5
No files matched your search
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user