Add slot pinning and eviction measurements to M0 findings
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
+29
-1
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
"""THROWAWAY M0 measurement spike for Boxmaker. Not harness code. Stdlib only.
|
||||
|
||||
Usage: python3 m0.py <check> [...] (checks: slots throughput convo tools pin progress rewind findtool rewind2)
|
||||
Usage: python3 m0.py <check> [...] (checks: slots throughput convo tools pin progress rewind findtool rewind2 evict alternate)
|
||||
Raw results are appended to out/<check>.jsonl; findings go in docs/inference-contract.md.
|
||||
"""
|
||||
import json, os, random, sys, time, urllib.request
|
||||
@@ -307,6 +307,34 @@ def check_rewind2():
|
||||
log("rewind2", {"requests": recs})
|
||||
|
||||
|
||||
def check_evict():
|
||||
"""(d2) certain eviction: a different prompt is pinned onto the session's own slot. Is the session restored?"""
|
||||
recs, kw = [], {"chat_template_kwargs": {"enable_thinking": False}}
|
||||
a = [{"role": "system", "content": SYSTEM}, {"role": "user", "content": "Session A. " + filler(30000, "EA") + "\nReply: alpha"}]
|
||||
r = chat(a, None, 0, 16, **kw); recs.append(tline("A turn1 slot0 (30k)", r)); a.append(assistant_msg(r))
|
||||
for i in (1, 2, 3):
|
||||
c = [{"role": "user", "content": "Intruder %d. %s\nReply: gamma" % (i, filler(8000, "EI%d" % i))}]
|
||||
r = chat(c, None, 0, 16, **kw); recs.append(tline("intruder %d pinned to slot0 (8k)" % i, r))
|
||||
a.append({"role": "user", "content": "Again."})
|
||||
r = chat(a, None, 0, 16, **kw); recs.append(tline("A turn2 slot0 (after 3 intruders)", r)); a.append(assistant_msg(r))
|
||||
a.append({"role": "user", "content": "Again."})
|
||||
r = chat(a, None, 1, 16, **kw); recs.append(tline("A turn3 moved to slot1", r))
|
||||
log("evict", {"requests": recs})
|
||||
|
||||
|
||||
def check_alternate():
|
||||
"""(d3) two harness sessions sharing one baseline prefix take turns on one slot, as Mattermost threads would."""
|
||||
recs, kw = [], {"chat_template_kwargs": {"enable_thinking": False}}
|
||||
base = SYSTEM + " Shared baseline follows. " + filler(2500, "BASE")
|
||||
sess = {n: [{"role": "system", "content": base}, {"role": "user", "content": "Thread %s. %s\nReply: ok" % (n, filler(10000, "AL" + n))}] for n in "AB"}
|
||||
for rnd in (1, 2, 3):
|
||||
for n in "AB":
|
||||
if rnd > 1:
|
||||
sess[n].append({"role": "user", "content": "Round %d. %s\nReply: ok" % (rnd, filler(300, "ALr%d%s" % (rnd, n)))})
|
||||
r = chat(sess[n], TOOLS, 0, 16, **kw); recs.append(tline("thread %s round %d slot0" % (n, rnd), r)); sess[n].append(assistant_msg(r))
|
||||
log("alternate", {"requests": recs})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.makedirs(OUT, exist_ok=True)
|
||||
for name in sys.argv[1:] or ["slots"]:
|
||||
|
||||
Reference in New Issue
Block a user