Wheel speed factor is the squared ratio of medians, floor 0.02
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5e73ccfb4a
commit
6aeff7afd4
3 files changed
+16
-8
No files matched your search
@@ -11,7 +11,7 @@ organizes the rules.
|
||||
It routes by a models table: which workers you have, what each is good at, what it costs. A research worker
|
||||
rebuilds that table when it gets old, and every judged delegation feeds the next research. The lead does not
|
||||
choose the worker: `sisi pick CLASS` spins a wheel over the workers of that class (a capability tier: each model is
|
||||
in exactly one class, so the wheel never mixes tiers; weighted by table order and by speed),
|
||||
in exactly one class, so the wheel never mixes tiers; weighted by table order and by the square of the speed ratio),
|
||||
and a delegation to a worker the wheel did not give is refused. One pick, one delegation. A host that names its models
|
||||
shortly (Claude Code's `Agent` tool says `sonnet`) may give one whole segment of the picked model id, so name a worker
|
||||
by its full model id (`claude-sonnet-5-5`); anywhere else the name must match whole.
|
||||
|
||||
+2
-2
@@ -161,7 +161,7 @@ def speeds():
|
||||
|
||||
def choose(text, cls, skip=(), review=None, rand=None, today=None, speed=None):
|
||||
"""One worker of this class, by a wheel weighted by table order (the first of n has weight n, the last 1)
|
||||
times its speed: the fastest candidate's median minutes over its own, at least 0.25 (1 with no timed jobs)."""
|
||||
times its speed: the fastest candidate's median minutes over its own, squared, at least 0.02 (1 with no timed jobs)."""
|
||||
table_rows, today = rows(text), today or time.strftime("%Y-%m-%d")
|
||||
bad = next((maker(r) for r in table_rows if short(r[0]) == short(review)), None) if review else None
|
||||
left = [r for r in table_rows if r[2].strip().lower() == cls and not out(r, skip, bad, today)]
|
||||
@@ -172,7 +172,7 @@ def choose(text, cls, skip=(), review=None, rand=None, today=None, speed=None):
|
||||
rand = random.random
|
||||
med = {short(r[0]): median(speed[short(r[0])]) for r in left if (speed or {}).get(short(r[0]))}
|
||||
fast = min(med.values(), default=1)
|
||||
weights = [w * max(0.25, fast / med[short(r[0])]) if short(r[0]) in med else w for w, r in zip(range(len(left), 0, -1), left)]
|
||||
weights = [w * max(0.02, (fast / med[short(r[0])]) ** 2) if short(r[0]) in med else w for w, r in zip(range(len(left), 0, -1), left)]
|
||||
x = rand() * sum(weights)
|
||||
for weight, r in zip(weights, left):
|
||||
x -= weight
|
||||
|
||||
+13
-5
@@ -578,12 +578,20 @@ class Core(unittest.TestCase):
|
||||
name = lambda r: r[0]
|
||||
spins = lambda speed: [name(models.choose(table, "ordinary", rand=lambda: i / 1000, speed=speed)) for i in range(1000)]
|
||||
self.assertEqual(spins(None).count("fast"), 333) # table order alone: weights 2 and 1
|
||||
self.assertEqual(spins({"slow": [60] * 3, "fast": [10, 10]}).count("fast"), 666) # slow is floored at 0.25: 0.5 against 1
|
||||
self.assertEqual(spins({"slow": [60, 61, 62], "fast": [10]}).count("fast"), 666)
|
||||
self.assertEqual(spins({"slow": [600] * 3, "fast": [10, 10]}).count("fast"), 961) # slow is floored at 0.02: 0.04 against 1
|
||||
self.assertEqual(spins({"slow": [60, 61, 62], "fast": [10]}).count("fast"), 948) # the speed ratio squared: 2 * (10/61)**2 against 1
|
||||
self.assertEqual(spins({"fast": [10]}).count("fast"), 333) # slow has no timed jobs: factor 1, table order
|
||||
self.assertEqual(spins({"slow": [20], "fast": [10]}).count("fast"), 500) # factor 0.5: weights 1 and 1
|
||||
self.assertEqual(name(models.choose(table, "ordinary", rand=lambda: 0.33, speed={"slow": [60], "fast": [10]})), "slow")
|
||||
self.assertEqual(name(models.choose(table, "ordinary", rand=lambda: 0.34, speed={"slow": [60], "fast": [10]})), "fast")
|
||||
self.assertEqual(spins({"slow": [20], "fast": [10]}).count("fast"), 666) # factor 0.25: weights 0.5 and 1
|
||||
self.assertEqual(name(models.choose(table, "ordinary", rand=lambda: 0.05, speed={"slow": [60], "fast": [10]})), "slow")
|
||||
self.assertEqual(name(models.choose(table, "ordinary", rand=lambda: 0.06, speed={"slow": [60], "fast": [10]})), "fast")
|
||||
|
||||
def test_a_much_slower_worker_first_in_the_table_rarely_wins(self):
|
||||
sys.path.insert(0, REPO)
|
||||
from sisi import models
|
||||
table = HEADER + "| slow | `slow \"<brief>\"` | ordinary | flat | x | |\n| fast | `fast \"<brief>\"` | ordinary | flat | x | |\n"
|
||||
rng = random.Random(7)
|
||||
wins = [models.choose(table, "ordinary", rand=rng.random, speed={"slow": [45], "fast": [9]})[0] for _ in range(2000)]
|
||||
self.assertLess(wins.count("slow"), 200) # 2 * (9/45)**2 = 0.08 against 1: about 7%; it was a third
|
||||
|
||||
def test_pick_and_models_show_the_minutes(self):
|
||||
self.table(WORKERS)
|
||||
|
||||
Reference in new issue
Block a user