Skip to content

Kyojin: open-source engine that runs 100 GB-class open models (GLM-5.3, Qwen3.8, DeepSeek V4.1) on one desktop machine. AMD Strix Halo, NVIDIA RTX and Apple Mac. OpenAI API, built on ExLlamaV3.

Qwen: stricter deep draft tier (reach 0.95 to start, 0.85 to keep)

YanissAmz455e0ff90c30
diff --git a/tools/qwen/spec_policy.py b/tools/qwen/spec_policy.py
index 627ea80..5598b4e 100644
--- a/tools/qwen/spec_policy.py
+++ b/tools/qwen/spec_policy.py
@@ -231,9 +231,11 @@ class TierRule(ProductRule):
Why (adapt, 07/10): one pair (thf, thv) serves two jobs. Raising thf to 0.8 to avoid unprofitable 5+ row rounds also cut the
2..4 row rounds short, which cost 1-4 % where depth 2-4 acceptance is good (128K, chat). Verify rows cost the same at every
context (~10.5 ms per row incl. its draft step); a row beyond the 4th pays only when its chance of being accepted is above
- ~0.5, and the drafter's reach overstates it, so the deep tier asks for reach >= 0.9 to start and >= 0.5 to keep."""
+ ~0.5, and the drafter's reach overstates it, so the deep tier asks for reach >= 0.95 to start and >= 0.85 to keep.
+ Measured on the served model: 0.9 / 0.7 lost about 1 % at 32K to deep rounds that did not pay; 0.95 / 0.85 matches the
+ former 4-row rule there and keeps the gain on chat, prose, code and at 128K."""
name = "tier"
- def __init__(self, thf=0.6, thv=0.3, maxd=7, thfd=0.9, thvd=0.7, dsplit=3):
+ def __init__(self, thf=0.6, thv=0.3, maxd=7, thfd=0.95, thvd=0.85, dsplit=3):
super().__init__(thf, thv, maxd); self.thfd, self.thvd, self.dsplit = thfd, thvd, dsplit
def step(self, i, p):
q = self.q(i, p); k = i + 1
@@ -317,7 +319,7 @@ def rule_from_env(thf, thv, maxd):
kind = os.environ.get("QWSPEC_RULE", "tier")
if kind == "product": r = ProductRule(thf, thv, maxd)
elif kind == "cost": r = CostRule(thf, thv, maxd, _envf("QWSPEC_GAMMA", 1.0), _envf("QWSPEC_SCALE", 1.0))
- elif kind == "tier": r = TierRule(thf, thv, maxd, _envf("QWSPEC_THFD", 0.9), _envf("QWSPEC_THVD", 0.7), _envf("QWSPEC_DSPLIT", 3))
+ elif kind == "tier": r = TierRule(thf, thv, maxd, _envf("QWSPEC_THFD", 0.95), _envf("QWSPEC_THVD", 0.85), _envf("QWSPEC_DSPLIT", 3))
elif kind == "table":
cyc = os.environ.get("QWSPEC_CYCLE"); r = TableRule(maxd, [float(x) for x in cyc.split(",")] if cyc else None, _envf("QWSPEC_DECAY", 0.75), _envf("QWSPEC_PRIOR", 0.75))
elif kind == "online": r = OnlineRule(thf, thv, maxd, _envf("QWSPEC_GAMMA", 1.0), _envf("QWSPEC_ALPHA", 0.15))
diff --git a/tools/qwen/test_spec_rule.py b/tools/qwen/test_spec_rule.py
index 608ea61..af79894 100644
--- a/tools/qwen/test_spec_rule.py
+++ b/tools/qwen/test_spec_rule.py
@@ -122,13 +122,13 @@ class T(unittest.TestCase):
self.assertEqual(early(r, [0.99, 0.99, 0.99, 0.5, 0.9]), (3, 4)) # depth 4 drafted, reach 0.48 < thvd: dropped
self.assertEqual(early(r, [0.99, 0.99, 0.99, 0.6, 0.9]), (4, 4)) # kept (0.58 >= 0.5), reach < thfd: stop
os.environ["QWSPEC_RULE"] = "tier"
- try: self.assertEqual((sp.rule_from_env(0.6, 0.3, 7).name, sp.rule_from_env(0.6, 0.3, 7).thfd), ("tier", 0.9))
+ try: self.assertEqual((sp.rule_from_env(0.6, 0.3, 7).name, sp.rule_from_env(0.6, 0.3, 7).thfd), ("tier", 0.95))
finally: del os.environ["QWSPEC_RULE"]
def test_env_defaults(self):
for k in ("QWSPEC_THF", "QWSPEC_THV", "QWSPEC_MAXD", "QWSPEC_RULE"): os.environ.pop(k, None)
self.assertEqual(sp.env_defaults(7), (0.6, 0.3, 7))
- r = sp.rule_from_env(0.6, 0.3, 7); self.assertEqual((r.name, r.thf, r.thv, r.maxd, r.thfd, r.thvd), ("tier", 0.6, 0.3, 7, 0.9, 0.7))
+ r = sp.rule_from_env(0.6, 0.3, 7); self.assertEqual((r.name, r.thf, r.thv, r.maxd, r.thfd, r.thvd), ("tier", 0.6, 0.3, 7, 0.95, 0.85))
os.environ["QWSPEC_RULE"] = "product"
try: r = sp.rule_from_env(0.6, 0.3, 3); self.assertEqual((r.name, r.thf, r.thv, r.maxd), ("product", 0.6, 0.3, 3))
finally: del os.environ["QWSPEC_RULE"]