Prepare guarded 131K and million-token Strata speed and needle comparison
This commit is contained in:
1 parent
0090c213de
commit
d36ca7c46a
4 files changed
+267
No files matched your search
@@ -0,0 +1,91 @@
|
||||
# Vorbereiteter Strata-IQ3-Kontextvergleich
|
||||
|
||||
Status: vorbereitet, NICHT gestartet. Start ausschließlich nach Nutzerwort „Bingo“.
|
||||
Produktionsprofile, Kontextgröße, GPU-Verteilung und Dienste bleiben bis dahin unverändert.
|
||||
|
||||
## Umfang
|
||||
|
||||
Aktuell 131072 Kontexttokens; Vergleich mit 1000000 Tokens und experimentellem
|
||||
YaRN, Faktor 4. Qwen3.8-Flash-Next: nativ 262144, Herstellererweiterung bis 1000000.
|
||||
Deck erlaubt regulär höchstens 262144: der Millionentest läuft deshalb isoliert,
|
||||
nicht als Änderung des Produktionsprofils. Kein weiteres Modell/Quant wird geladen.
|
||||
|
||||
Je Kontextgröße:
|
||||
- frischer Worker: Ladezeit bis /health bereit, anschließend kurze Anfrage (~256 Tokens)
|
||||
- kleiner Prompt (~4096 Tokens)
|
||||
- voller 131K-Testtext (~122880 Tokens), im Millionentest identisch wiederholt
|
||||
- zusätzlich beim Millionentest voller Millionentext (~991808 Tokens)
|
||||
|
||||
Jeweils bis 256 Outputtokens, temperature 0, reasoning_effort none.
|
||||
Zahl steht genau einmal unter SONNENANKER ungefähr bei 50% des Tokenkontexts.
|
||||
Antwort muss die Zahl zuerst exakt in eigener Zeile nennen, danach synthetischen
|
||||
Text erzeugen, damit auch Outputgeschwindigkeit eine ausreichende Messbasis hat.
|
||||
Eine einzelne Zahl allein wäre für zuverlässige Decode-Geschwindigkeit zu kurz.
|
||||
Das ist ein Retrievaltest, kein allgemeiner Intelligenzbenchmark.
|
||||
|
||||
Datensätze deterministisch, Distraktoren variieren. Frische Systemkennung vor
|
||||
jeder Messung verhindert Shared-Prefix-Reuse; tatsächlichen Cache-Anteil aus usage
|
||||
mitberichten. Gezählt mit dem tatsächlich laufenden Tokenizer, tatsächliche
|
||||
Promptgröße anschließend aus usage, keine Zeichen/Token-Schätzung im Bericht.
|
||||
8192 Tokens Reserve für Ausgabe/Sicherheitsabstand; exakt bis zum letzten Token
|
||||
füllen wäre kein sinnvoll beantwortbarer Test. Position wird separat erfasst.
|
||||
Fresh worker bedeutet kein vorhandener KV-Cache; OS-Dateicaches werden nicht gelöscht.
|
||||
|
||||
## Messwerte
|
||||
|
||||
Backend prompt_per_second, predicted_per_second und alle timings, usage inkl.
|
||||
cached_tokens, wall time, TTFT zum ersten sichtbaren Token, Ladezeit separat.
|
||||
RAM/cgroup und VRAM jede Sekunde. Backend-Timings fehlen => als fehlend markieren,
|
||||
keine erfundene Inputgeschwindigkeit aus der Gesamtdauer ableiten.
|
||||
|
||||
Aktive Strategie: INT8-KV, kv-resident 32768, Gesamt-KV in RAM/Streaming.
|
||||
Mehr Kontext verdrängt nicht automatisch Modellgewichte aus VRAM. Einstellungen
|
||||
für GPUs/Layer/Expertencache/Prefill bleiben in beiden Testinstanzen identisch;
|
||||
nur Kontext und notwendige YaRN-Skalierung unterscheiden sich. Die bekannte
|
||||
131K-Performancequalifikation wird im isolierten Template auch bei 1M beibehalten,
|
||||
damit nicht gleichzeitig Tuning und Kontext geändert werden.
|
||||
|
||||
## Ausführung nach Bingo
|
||||
|
||||
Host: /opt/athena-deck-dev/context-prepared-20261013
|
||||
Ergebnisse: /data/experiments/strata-context-20261013
|
||||
|
||||
1. Keine aktive Nutzeranfrage; regulär den Deck-LLM entladen. Deck/Host nicht stoppen.
|
||||
2. `python3 /opt/athena-deck-dev/context-prepared-20261013/launch.py --go`
|
||||
Launcher prüft Endpunktleerlauf und dass Deck keinen LLM geladen meldet.
|
||||
Benchmark prüft zusätzlich GPU-Prozesse und stoppt keine fremden Prozesse.
|
||||
3. Nur EIN Testworker zu einer Zeit, beide Kontextgrößen nacheinander.
|
||||
Kein paralleles Produktionschatten: dieselben beiden GPUs werden benötigt.
|
||||
4. Nach Ende/Fehler über regulären Deck-Endpunkt vorheriges IQ3 laden; bevor dies
|
||||
geschieht neue Nutzerentscheidung prüfen. Wiederherstellung erst dann behaupten.
|
||||
|
||||
Testcontainer nutzt aktuelles Deck-Image, vorhandene Laufzeit/Gewichte read-only,
|
||||
eigenes Ergebnisverzeichnis, kein Netz außerhalb seiner Loopback-Schnittstelle,
|
||||
UID 65534, kein Docker-Socket, keine Privilegierung. Maximal 40 GiB RAM, kein Swap
|
||||
(48-GiB-Host braucht Reserve für OS/Deck); OOM ist ein belegter Kapazitätsfehler,
|
||||
kein Intelligenzfehler. Ein Vollkontextlauf kann deutlich länger als eine kurze
|
||||
Geschwindigkeitsmessung dauern. Laufzeit/RAM-Zuverlässigkeit bei 1M ist noch offen.
|
||||
|
||||
API-Key des Testworkers wird frisch erzeugt, nur temporär in 0600-Konfiguration
|
||||
gehalten und nach Ende gelöscht. Template enthält keinen Produktions-API-Key.
|
||||
Nur synthetische Fixtures/Antworten, keine Produktionslogs oder Nutzereingaben.
|
||||
|
||||
## Native Installation/Restore
|
||||
|
||||
Keine Produktänderung oder Abhängigkeit: vorhandene gepinnte Strata-Laufzeit,
|
||||
Gewichte und Python-stdlib. Bei nativem Betrieb benchmark.py direkt mit --go,
|
||||
--base-config einer passenden nicht geheimen Startvorlage und --output eigenem
|
||||
Ergebnisordner ausführen; sämtliche exe/cwd/tokenizer/args-Pfade auf native Pfade
|
||||
abbilden. Launcher ist ausschließlich eine Hilfe für den heutigen Testcontainer.
|
||||
Keine Gewichte/Keys/Host-Konfigurationen in Git, kein vollständiger Restore-Test.
|
||||
|
||||
## Verifikation ohne Inferenz
|
||||
|
||||
Python-Syntax, drei Tests für deterministische Fixtures/Mittelposition/Antwortreserve
|
||||
und Dry-run auf Athena erfolgreich. Ohne --go: keine Inferenz und keine Dienste.
|
||||
Es gibt noch keine neuen Geschwindigkeits- oder Needle-Ergebnisse.
|
||||
|
||||
Quellen:
|
||||
- https://huggingface.co/Qwen/Qwen3.8-Flash-Next
|
||||
- https://github.com/Niko1221/Strata/blob/main/docs/DETAILS.md
|
||||
Installierte Strata-Version: 0.1.43.1, a0116b2782a5b82622358c04a06496485d12b2d6.
|
||||
@@ -0,0 +1,147 @@
|
||||
"""Prepared synthetic benchmark. No operation before explicit --go.
|
||||
Run inside an isolated container after regular Deck LLM unload, never concurrently.
|
||||
"""
|
||||
import argparse,copy,json,os,pathlib,random,re,secrets,signal,socket,subprocess,threading,time,urllib.request
|
||||
P=pathlib.Path
|
||||
CONTEXTS=(131072,1000000)
|
||||
OUTPUT=256
|
||||
MARGIN=8192
|
||||
NEEDLE='781493628057'
|
||||
SYSTEM='Synthetischer Test. Finde den Wert des Datensatzes SONNENANKER. Antworte zuerst nur mit der Zahl in einer eigenen Zeile. Schreibe danach mindestens 400 Wörter über robuste Datenverarbeitung. Keine Werkzeuge.'
|
||||
|
||||
def corpus(n):
|
||||
r=random.Random(131072)
|
||||
return [f'Datensatz {i:06d}: Standort {r.randrange(10000):04d}, Messwert {r.randrange(100000000000,999999999999)}, Status archiviert.\n' for i in range(n)]
|
||||
|
||||
def prompt(rows):
|
||||
mid=len(rows)//2
|
||||
return ''.join(rows[:mid])+f'Datensatz SONNENANKER: geheimer Prüfwert {NEEDLE}.\n'+''.join(rows[mid:])+'\nNenne den geheimen Prüfwert von SONNENANKER und führe die Ausgabeanweisung aus.'
|
||||
|
||||
def choose_prompt(target,count):
|
||||
# Exact deployed tokenizer count, never characters-as-tokens.
|
||||
rows=corpus(max(100,int(target/12)+1000))
|
||||
lo,hi=0,len(rows)
|
||||
while count(prompt(rows[:hi]))<target:
|
||||
hi*=2;rows=corpus(hi)
|
||||
while lo<hi:
|
||||
mid=(lo+hi+1)//2
|
||||
if count(prompt(rows[:mid]))<=target:lo=mid
|
||||
else:hi=mid-1
|
||||
text=prompt(rows[:lo]);actual=count(text)
|
||||
prefix=''.join(rows[:lo//2])
|
||||
position=count(prefix)
|
||||
return {'text':text,'counted_tokens':actual,'needle_token_position_estimate':position,
|
||||
'needle_position_fraction':position/actual if actual else None,'target_tokens':target}
|
||||
|
||||
def measure(base,key,model,system,text):
|
||||
body={'model':model,'messages':[{'role':'system','content':system},{'role':'user','content':text}],
|
||||
'max_tokens':OUTPUT,'temperature':0,'reasoning_effort':'none','stream':True,'stream_options':{'include_usage':True}}
|
||||
req=urllib.request.Request(base+'/v1/chat/completions',data=json.dumps(body).encode(),headers={'Authorization':'Bearer '+key,'Content-Type':'application/json'})
|
||||
started=time.monotonic();first=None;content='';usage={};timings={}
|
||||
with urllib.request.urlopen(req,timeout=14400) as response:
|
||||
for line in response:
|
||||
if not line.startswith(b'data:'):continue
|
||||
raw=line[5:].strip()
|
||||
if raw==b'[DONE]':break
|
||||
value=json.loads(raw)
|
||||
if 'error' in value:raise RuntimeError('synthetic backend stream error')
|
||||
usage=value.get('usage') or usage;timings=value.get('timings') or timings
|
||||
for choice in value.get('choices',[]):
|
||||
delta=choice.get('delta',{});token=delta.get('content') or ''
|
||||
if token and first is None:first=time.monotonic()
|
||||
content+=token
|
||||
total=time.monotonic()-started
|
||||
first_line=content.strip().splitlines()[0] if content.strip() else ''
|
||||
return {'request_seconds':total,'ttft_seconds':first-started if first else None,
|
||||
'usage':usage,'backend_timings':timings,'needle_exact':first_line.strip()==NEEDLE,
|
||||
'output_tokens_per_second':timings.get('predicted_per_second'),
|
||||
'input_tokens_per_second':timings.get('prompt_per_second'),
|
||||
'synthetic_output':content}
|
||||
|
||||
class MemorySampler:
|
||||
def __init__(self):self.stop_event=threading.Event();self.samples=[]
|
||||
def run(self):
|
||||
while not self.stop_event.is_set():
|
||||
row={'monotonic':time.monotonic()}
|
||||
try:
|
||||
row['gpu_mib']=subprocess.check_output(['nvidia-smi','--query-gpu=index,memory.used,memory.total','--format=csv,noheader,nounits'],text=True).strip().splitlines()
|
||||
mem=dict(re.findall(r'^(MemAvailable|SwapFree):\s+(\d+)',P('/proc/meminfo').read_text(),re.M));row['host_memory_kib']={k:int(v) for k,v in mem.items()}
|
||||
cg=P('/sys/fs/cgroup/memory.current');row['cgroup_memory_bytes']=int(cg.read_text()) if cg.exists() else None
|
||||
except (OSError,subprocess.SubprocessError):row['sampling_failed']=True
|
||||
self.samples.append(row);self.stop_event.wait(1)
|
||||
|
||||
def run(a):
|
||||
root=P(a.output);root.mkdir(parents=True,exist_ok=True)
|
||||
source=P('/var/lib/deck/strata-runtime/source')
|
||||
basecfg=json.loads(P(a.base_config).read_text())
|
||||
results=[];shared_fixtures={}
|
||||
def save(phase,**extra):
|
||||
(root/'status.json').write_text(json.dumps({'phase':phase,'completed_measurements':len(results),**extra}))
|
||||
(root/'results.json').write_text(json.dumps(results,indent=2))
|
||||
# Host-wide GPU inventory is the guard: never evict production workers here.
|
||||
names=subprocess.check_output(['nvidia-smi','--query-compute-apps=process_name','--format=csv,noheader'],text=True).strip()
|
||||
if names and 'No running processes found' not in names:raise RuntimeError('GPU processes present: regular Deck unload required; no test started')
|
||||
for context in CONTEXTS:
|
||||
cfg=copy.deepcopy(basecfg);key=secrets.token_urlsafe(32)
|
||||
with socket.socket() as sock:sock.bind(('127.0.0.1',0));port=sock.getsockname()[1]
|
||||
cfg.update(api_key=key,host='127.0.0.1',port=port,model_name='synthetic-context-test',open_browser=False,fit_max_tokens=True,log=str(root/f'engine-{context}.log'))
|
||||
cfg.pop('vision',None);args=cfg['args'];args[:]=[v for v in args if v!='--vision']
|
||||
for flag in ('--rope-scaling','--rope-scale'):
|
||||
if flag in args:i=args.index(flag);del args[i:i+2]
|
||||
i=args.index('--max-context');args[i+1]=str(context)
|
||||
if context>262144:args+=['--rope-scaling','yarn','--rope-scale','4']
|
||||
# Preserve GPU order, layer split, expert/cache policy and measured tuning.
|
||||
config=root/f'worker-{context}.json';config.write_text(json.dumps(cfg));config.chmod(0o600)
|
||||
process=None;sampler=MemorySampler();thread=threading.Thread(target=sampler.run,daemon=True);thread.start()
|
||||
env=dict(os.environ,**cfg.get('env',{}),PYTHONUNBUFFERED='1')
|
||||
base=f'http://127.0.0.1:{port}'
|
||||
def request(path,body=None):
|
||||
req=urllib.request.Request(base+path,data=json.dumps(body).encode() if body else None,headers={'Authorization':'Bearer '+key,'Content-Type':'application/json'})
|
||||
with urllib.request.urlopen(req,timeout=120) as r:return json.load(r)
|
||||
try:
|
||||
save('loading',context=context);started=time.monotonic()
|
||||
with (root/f'server-{context}.log').open('w') as log:
|
||||
process=subprocess.Popen([str(source/'.venv/bin/python'),str(source/'serve/server.py'),'--engine','strata','--config',str(config),'--host','127.0.0.1','--port',str(port),'--fit-max-tokens'],cwd=source,env=env,stdout=log,stderr=subprocess.STDOUT,start_new_session=True)
|
||||
deadline=started+600
|
||||
while time.monotonic()<deadline:
|
||||
if process.poll() is not None:raise RuntimeError('test worker exited during loading')
|
||||
try:
|
||||
h=request('/health')
|
||||
if h.get('status')=='ok' and h.get('loaded',True):break
|
||||
except (OSError,ValueError):pass
|
||||
time.sleep(1)
|
||||
else:raise TimeoutError('test worker load timeout')
|
||||
load=time.monotonic()-started
|
||||
cases=[('short',256),('small',4096),('full-131k',131072-MARGIN)]
|
||||
if context>131072:cases.append(('full-max',context-MARGIN))
|
||||
for name,target in cases:
|
||||
save('tokenizing',context=context,case=name)
|
||||
# Fresh first system token sequence defeats shared-prefix caching.
|
||||
system='Messkennung '+secrets.token_hex(16)+'. '+SYSTEM
|
||||
def count(text):return request('/v1/messages/count_tokens',{'model':'synthetic-context-test','system':system,'messages':[{'role':'user','content':text}]})['input_tokens']
|
||||
if name in shared_fixtures:
|
||||
case=dict(shared_fixtures[name]);case['counted_tokens']=count(case['text'])
|
||||
else:
|
||||
case=choose_prompt(target,count);shared_fixtures[name]=dict(case)
|
||||
(root/f'fixture-{context}-{name}.json').write_text(json.dumps({'system':system,**case}))
|
||||
save('measuring',context=context,case=name,counted_tokens=case['counted_tokens'])
|
||||
row=measure(base,key,'synthetic-context-test',system,case['text'])
|
||||
row.update(context=context,case=name,load_seconds=load if name=='short' else None,**{k:v for k,v in case.items() if k!='text'})
|
||||
results.append(row);save('measured',context=context,case=name)
|
||||
except Exception as e:
|
||||
save('failed',context=context,error_type=type(e).__name__)
|
||||
raise
|
||||
finally:
|
||||
if process and process.poll() is None:
|
||||
os.killpg(process.pid,signal.SIGTERM)
|
||||
try:process.wait(30)
|
||||
except subprocess.TimeoutExpired:os.killpg(process.pid,signal.SIGKILL);process.wait()
|
||||
sampler.stop_event.set();thread.join(3)
|
||||
(root/f'memory-{context}.json').write_text(json.dumps(sampler.samples))
|
||||
config.unlink(missing_ok=True)
|
||||
save('complete')
|
||||
|
||||
if __name__=='__main__':
|
||||
p=argparse.ArgumentParser();p.add_argument('--go',action='store_true');p.add_argument('--base-config',default='/var/lib/deck/strata-worker/worker.json');p.add_argument('--output',default='/experiment');a=p.parse_args()
|
||||
if not a.go:print(json.dumps({'state':'prepared_only','contexts':CONTEXTS,'output_tokens':OUTPUT,'inference_started':False}));raise SystemExit(0)
|
||||
run(a)
|
||||
@@ -0,0 +1,16 @@
|
||||
"""Athena host launcher. Explicit --go, regularly unloaded Deck required."""
|
||||
import argparse,json,pathlib,subprocess,urllib.request
|
||||
p=argparse.ArgumentParser();p.add_argument('--go',action='store_true');a=p.parse_args()
|
||||
if not a.go:print('Prepared only. No services changed.');raise SystemExit(0)
|
||||
stage=pathlib.Path('/opt/athena-deck-dev/context-prepared-20261013');output=pathlib.Path('/data/experiments/strata-context-20261013')
|
||||
c=json.loads(subprocess.check_output(['docker','inspect','athena-voxcpm2-web']))[0]
|
||||
f=next(pathlib.Path(m['Source']) for m in c['Mounts'] if m['Destination']=='/data');token=json.loads((f/'deck-connection.json').read_text())['token']
|
||||
status=json.load(urllib.request.urlopen(urllib.request.Request('http://127.0.0.1:8108/api/v1/status',headers={'Authorization':'Bearer '+token}),timeout=15))
|
||||
if status['endpoint']['active_requests'] or status['endpoint']['counts']['llm']['loaded']:raise SystemExit('Regularly unload the Deck LLM first; no test started.')
|
||||
output.mkdir(parents=True,exist_ok=True);subprocess.run(['chown','65534:65534',str(output)],check=True)
|
||||
c=json.loads(subprocess.check_output(['docker','inspect','athena-deck-dev']))[0]
|
||||
args=['docker','run','--rm','--name','athena-strata-context-test','--gpus','all','--user','65534:65534','--read-only','--cap-drop','ALL','--security-opt','no-new-privileges:true','--memory','40g','--memory-swap','40g','--cpus','6','--network','none','--tmpfs','/tmp:rw,nosuid,nodev,size=512m','--entrypoint','python3']
|
||||
for m in c['Mounts']:
|
||||
if m['Type']=='bind' and (m['Destination']=='/var/lib/deck' or 'strata' in m['Destination']):args+=['--mount',f"type=bind,src={m['Source']},dst={m['Destination']},readonly"]
|
||||
args+=['--mount',f'type=bind,src={stage},dst=/test,readonly','--mount',f'type=bind,src={output},dst=/experiment',c['Config']['Image'],'/test/benchmark.py','--go','--base-config','/test/base-template.json']
|
||||
raise SystemExit(subprocess.run(args).returncode)
|
||||
@@ -0,0 +1,13 @@
|
||||
import importlib.util,pathlib,unittest
|
||||
p=pathlib.Path(__file__).with_name('benchmark.py');spec=importlib.util.spec_from_file_location('bench',p);b=importlib.util.module_from_spec(spec);spec.loader.exec_module(b)
|
||||
class PreparationTests(unittest.TestCase):
|
||||
def test_exact_count_and_middle_needle(self):
|
||||
case=b.choose_prompt(20000,lambda s:len(s))
|
||||
self.assertLessEqual(case['counted_tokens'],20000)
|
||||
self.assertGreater(case['counted_tokens'],19800)
|
||||
self.assertEqual(case['text'].count(b.NEEDLE),1)
|
||||
self.assertTrue(.45<case['needle_position_fraction']<.55)
|
||||
def test_corpus_deterministic(self):self.assertEqual(b.corpus(30),b.corpus(50)[:30])
|
||||
def test_output_has_space(self):
|
||||
for ctx in b.CONTEXTS:self.assertLess(ctx-b.MARGIN+b.OUTPUT,ctx)
|
||||
if __name__=='__main__':unittest.main()
|
||||
Reference in new issue
Block a user