Record Qwen CPU thread comparison and restore baseline settings
This commit is contained in:
1 parent
746009b676
commit
8f7917d55d
10 files changed
+1047
No files matched your search
@@ -1,3 +1,15 @@
|
||||
## TTS generation-thread comparison ·22 October2026
|
||||
|
||||
Two controlled trials each with2/3/4generation threads and2codec threads:
|
||||
17.76s speech takes mean22.865/22.338/23.584s under bounded simultaneous
|
||||
Strata load. No setting reaches realtime;3threads'2.3% mean difference is
|
||||
insufficient. Original2/2threads restored, requested two exclusive plus two
|
||||
shared physical cores preserved. Endpoint and Strata/TTS/STT ready at completion.
|
||||
No product code/image/container changes. Thread changes trigger a normal Strata
|
||||
reload because its current cache key includes the full CPU layout; preparation
|
||||
excluded from speech timing. No actual phone playback test.
|
||||
[Results, caveat and native reproduction](experiments/tts-cpu-threads-2026-10-22/README.md).
|
||||
|
||||
## TTS: two exclusive plus two shared cores ·22 October2026
|
||||
|
||||
Current saved masks:Strata0–3/6–9 unchanged; Qwen-TTS2–5/8–11.
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
# Qwen CPU generation-thread comparison ·22 October2026
|
||||
|
||||
Michael requested a comparison after the active user request completed. The
|
||||
authenticated endpoint reported zero active requests before the first run and
|
||||
before each thread change. No user request was deliberately interrupted.
|
||||
|
||||
**Result: no tested setting reaches realtime under concurrent Strata load.**
|
||||
Original2generation/2codec threads restored; Strata/TTS/STT loaded, endpoint
|
||||
running, zero active requests at final verification. The requested two physical
|
||||
TTS-only cores plus two shared cores remain unchanged.
|
||||
|
||||
## Conditions and results
|
||||
|
||||
Same synthetic German passage as the preceding shared-core experiment, producing
|
||||
17.76seconds of24kHz mono PCM16 in every run. Native CPU runtime0.4.2/ABI5,
|
||||
Qwen0.6B Q4/Anna,2codec threads,2stream frames, CPU flash attention off, Nice10.
|
||||
TTS CPUs2–5/8–11; Strata CPUs0–3/6–9, dual IQ3 profile, repeated512-output-token
|
||||
synthetic requests. CPU quota12/RAM59GiB, model/voice/GPU settings unchanged.
|
||||
|
||||
| Generation threads | Run A | Run B | Mean generation time | Mean RTF |
|
||||
| --- | ---: | ---: | ---: | ---: |
|
||||
|2|23.075s|22.656s|22.865s|1.287|
|
||||
|3|22.841s|21.836s|22.338s|1.258|
|
||||
|4|24.149s|23.020s|23.584s|1.328|
|
||||
|
||||
Three threads reduce mean wall time by2.3% relative to two; four increase it by
|
||||
3.1%. Two runs per condition, fixed order2A/3A/4A/4B/3B/2B, no statistical or
|
||||
voice-quality claim. The small difference does not justify a production change.
|
||||
Every run remains slower than playback. Measured longest packet gaps were
|
||||
0.524/0.624s(two),0.325/0.404s(three),0.344/0.344s(four); smaller individual
|
||||
gaps do not overcome the cumulative audio deficit. No Conduit call or phone
|
||||
playback was tested.
|
||||
|
||||
LLM overlap from first content to request end covers90.3–92.5% of speech
|
||||
generation; short gaps between bounded requests remain. Every LLM request
|
||||
generated512tokens. PCM is counted and discarded by the measurement client;
|
||||
Deck's ordinary synthetic job/history outputs are unchanged. No conversational
|
||||
user text, private audio or VPN data was inspected.
|
||||
|
||||
## Reload caveat and safe restoration
|
||||
|
||||
`StrataWorker.ensure` compares the entire CPU layout, including TTS-only thread
|
||||
fields. Consequently changing the saved generation-thread count causes the
|
||||
next Strata request to reload its existing model even though its CPU mask is
|
||||
unchanged. No application patch/image build/container restart was introduced
|
||||
to change this behavior. Starting with4A, a separate one-token request completes
|
||||
this reload before measurement. Recorded preparation takes49.744s/49.649s/
|
||||
60.836s for4/3/2threads respectively; these are excluded from the table.
|
||||
|
||||
In3A the first synthetic LLM request includes a56.839s reload. Speech waits for
|
||||
its first content token, so this load time is excluded from TTS timing. However,
|
||||
the process observer captured the prior Strata PID for this run: do not use3A's
|
||||
CPU samples/masks as evidence for the replacement process or compare its first
|
||||
request wall time as LLM throughput. Subsequent runs observe warmed workers.
|
||||
|
||||
`threads.py` is an Athena-specific maintenance helper, not an installed service.
|
||||
It validates the existing CPU plan, saves only that non-secret CPU configuration
|
||||
as `thread-baseline.json`, changes only the generation count atomically with
|
||||
owner65534/mode0600, and terminates only the identified idle Qwen worker.
|
||||
Deck's existing residency loop reloads it. `warm` uses the same neutral short
|
||||
phrase before measurement; `warm-llm` handles the reload caveat above. API
|
||||
credentials enter through stdin only, never arguments/files/output. API status
|
||||
and owned process metadata are the only live diagnostic data read.
|
||||
|
||||
Each operation refuses to begin during ordinary active requests. These checks
|
||||
are not an atomic maintenance lock; no concurrent user-request race was observed.
|
||||
`bench.py` additionally aborts synthesis after a packet arrives beyond60seconds;
|
||||
this is a measurement bound, not a hard realtime watchdog. No bound was reached.
|
||||
Its underlying request/socket limits still apply if no packet arrives.
|
||||
|
||||
Final saved CPU settings match the baseline and the resident Qwen command
|
||||
confirms2generation/2codec threads. Existing image8cf88a02e30444e8 and all
|
||||
published models/voice/profile settings remain in use. No automatic monitoring,
|
||||
container, persistent hook or new dependency was installed.
|
||||
|
||||
## Reproduction, native installation and rollback
|
||||
|
||||
Scoped maintenance directory:
|
||||
`/opt/athena-deck-dev/tts-cpu-threads-20261022`. Local scripts and sanitized JSON
|
||||
results are included here. Run only with explicit idle time and the existing API
|
||||
credential supplied as stdin JSON. `threads.py select 2|3|4`, then `warm-llm`,
|
||||
`warm`, then `bench.py LABEL`; restore `select 2` and warm both models afterwards.
|
||||
The helper's process discovery/paths target today's named Athena container.
|
||||
|
||||
The benchmark accepts `--deck-pid MAIN_PID` for native Debian/systemd worker
|
||||
discovery. Native qualification uses the same existing CPU policy, ownership,
|
||||
runtime and worker reload procedure described in[CPU_PARTITION.md](../../CPU_PARTITION.md);
|
||||
adapt state paths and physical CPU topology explicitly rather than copying
|
||||
Athena IDs or the container-specific maintenance helper. This experiment adds
|
||||
no production code, runtime package or installer dependency. Full native host
|
||||
restore remains the separately documented open qualification requirement.
|
||||
|
||||
Rollback from any trial: at idle restore the saved CPU policy, reload only the
|
||||
owned speech worker, complete Strata's normal reload, and verify both are ready.
|
||||
No model, voice, chat, job schedule, profile or credential deletion is needed.
|
||||
@@ -0,0 +1,94 @@
|
||||
"""Bounded synthetic load and PCM arrival timing; no user text/audio is read."""
|
||||
import concurrent.futures,json,subprocess,sys,threading,time,urllib.request
|
||||
from pathlib import Path
|
||||
key=json.load(sys.stdin)['key'];stage=Path(__file__).resolve().parent
|
||||
arm=sys.argv[1];base='http://127.0.0.1:8120/v1/'
|
||||
headers={'Authorization':'Bearer '+key,'Content-Type':'application/json'}
|
||||
def api(name,body):return urllib.request.urlopen(urllib.request.Request(base+name,data=json.dumps(body).encode(),headers=headers),timeout=180)
|
||||
def idle():
|
||||
req=urllib.request.Request('http://127.0.0.1:8108/api/v1/status',headers=headers)
|
||||
with urllib.request.urlopen(req,timeout=10) as r:
|
||||
if json.load(r)['endpoint']['active_requests']!=0:raise RuntimeError('Real request active; test deferred')
|
||||
def processes():
|
||||
root=int(sys.argv[sys.argv.index('--deck-pid')+1]) if '--deck-pid' in sys.argv else json.loads(subprocess.check_output(['docker','inspect','athena-deck-dev']))[0]['State']['Pid'];pending=[root];seen=set();out={}
|
||||
while pending:
|
||||
pid=pending.pop()
|
||||
if pid in seen:continue
|
||||
seen.add(pid)
|
||||
try:
|
||||
for child_list in Path(f'/proc/{pid}/task').glob('*/children'):
|
||||
try:pending.extend(int(n) for n in child_list.read_text().split())
|
||||
except OSError:pass
|
||||
cmd=Path(f'/proc/{pid}/cmdline').read_bytes().split(b'\0')
|
||||
role='qwen_tts' if any(a.endswith(b'/qwen_native_worker.py') for a in cmd) else 'strata' if cmd[0].endswith(b'/engine/strata') else None
|
||||
if role:out[role]=pid
|
||||
except (OSError,ValueError):pass
|
||||
return out
|
||||
def observe(pids):
|
||||
found={}
|
||||
for role,pid in pids.items():
|
||||
for f in Path(f'/proc/{pid}/task').glob('*/status'):
|
||||
try:
|
||||
d={s.split(':',1)[0]:s.split(':',1)[1].strip() for s in f.read_text().splitlines() if ':' in s}
|
||||
found.setdefault(role,set()).add((d['Name'],d['Cpus_allowed_list']))
|
||||
except (OSError,KeyError):pass
|
||||
return found
|
||||
idle();pids=processes()
|
||||
if set(pids)!={'strata','qwen_tts'}:raise RuntimeError('Expected both warm workers')
|
||||
masks={};running_cpus={};stop=threading.Event();stop_load=threading.Event();ready=threading.Event();state={};rounds=[]
|
||||
def monitor():
|
||||
while not stop.is_set():
|
||||
for role,values in observe(pids).items():masks.setdefault(role,set()).update(values)
|
||||
for role,pid in pids.items():
|
||||
for f in Path(f'/proc/{pid}/task').glob('*/stat'):
|
||||
try:
|
||||
fields=f.read_text().rsplit(')',1)[1].split()
|
||||
if fields[0]=='R':
|
||||
n=int(fields[36]);counts=running_cpus.setdefault(role,{})
|
||||
counts[n]=counts.get(n,0)+1
|
||||
except (OSError,ValueError,IndexError):pass
|
||||
stop.wait(.1)
|
||||
def llm():
|
||||
deadline=time.monotonic()+90
|
||||
for n in range(8):
|
||||
if stop_load.is_set():break
|
||||
if time.monotonic()>deadline:raise RuntimeError('Synthetic load deadline')
|
||||
start=time.monotonic();first=None;tokens=0
|
||||
try:
|
||||
with api('chat/completions',dict(model='flash-next-strata-iq3-dual',messages=[dict(role='user',content='Zähle alle ganzen Zahlen von eins bis fünfhundert vollständig in deutschen Wörtern auf. Lasse keine aus, benutze keine Abkürzung und keine Erklärung. Runde '+str(n+1)+'.')],max_tokens=512,reasoning_effort='none',temperature=0,stream=True,stream_options=dict(include_usage=True))) as r:
|
||||
for line in r:
|
||||
if not line.startswith(b'data: ') or line.strip()==b'data: [DONE]':continue
|
||||
d=json.loads(line[6:]);tokens=(d.get('usage') or {}).get('completion_tokens',tokens)
|
||||
if any(c.get('delta',{}).get('content') for c in d.get('choices',[])) and first is None:
|
||||
first=time.monotonic();ready.set()
|
||||
rounds.append(dict(start=start,end=time.monotonic(),first=first,completion_tokens=tokens))
|
||||
except Exception:
|
||||
state['load_failed']=True;ready.set();raise
|
||||
if not stop_load.is_set():raise RuntimeError('Synthetic load ended before TTS')
|
||||
def tts():
|
||||
if not ready.wait(100) or state.get('load_failed'):raise RuntimeError('LLM did not begin')
|
||||
start=time.monotonic();state['tts_start']=start;first=None;received=0;latest=None;maxgap=0;deficit=0;chunks=0
|
||||
with api('audio/speech',dict(model='qwen-06b-q4-anna-cpu',voice='default',response_format='pcm',input='Dies ist ein Test mit fest aufgeteilten Prozessorkernen. Während Strata eine Antwort berechnet, erzeugt Anna diese Sprachausgabe. Wir prüfen, ob die Sprache gleichmäßig und schneller als in Echtzeit ankommt.')) as r:
|
||||
while True:
|
||||
b=r.read1(16384)
|
||||
if not b:break
|
||||
now=time.monotonic()
|
||||
if now-start>60:raise TimeoutError('Synthetic speech exceeded the 60-second comparison limit')
|
||||
if first is None:first=now
|
||||
else:
|
||||
maxgap=max(maxgap,now-latest);deficit=max(deficit,now-first-received/48000)
|
||||
received+=len(b);latest=now;chunks+=1
|
||||
end=time.monotonic();state['tts_end']=end
|
||||
if received%2 or not received:raise RuntimeError('Invalid complete PCM stream')
|
||||
return dict(seconds=end-start,first_pcm_seconds=first-start,audio_seconds=received/48000,rtf=(end-start)/(received/48000),bytes=received,packets=chunks,longest_packet_gap_seconds=maxgap,required_buffer_after_first_pcm_seconds=max(0,deficit))
|
||||
thread=threading.Thread(target=monitor,daemon=True);thread.start()
|
||||
try:
|
||||
with concurrent.futures.ThreadPoolExecutor(max_workers=2) as pool:
|
||||
lf=pool.submit(llm)
|
||||
try:speech=tts()
|
||||
finally:stop_load.set()
|
||||
lf.result()
|
||||
overlap=sum(max(0,min(r['end'],state['tts_end'])-max(r['first'] or r['end'],state['tts_start'])) for r in rounds)
|
||||
result=dict(arm=arm,tts=speech,llm_rounds=[dict(seconds=r['end']-r['start'],completion_tokens=r['completion_tokens']) for r in rounds],llm_overlap_seconds=overlap,llm_coverage=overlap/speech['seconds'],thread_affinities={role:[dict(name=n,cpus=c) for n,c in sorted(values)] for role,values in masks.items()},running_cpu_samples=running_cpus)
|
||||
(stage/(arm+'.json')).write_text(json.dumps(result,indent=2));print(json.dumps(result),flush=True)
|
||||
finally:stop.set();thread.join(2)
|
||||
@@ -0,0 +1,121 @@
|
||||
{
|
||||
"arm": "threads-2-a",
|
||||
"tts": {
|
||||
"seconds": 23.0750151599932,
|
||||
"first_pcm_seconds": 0.5787081170128658,
|
||||
"audio_seconds": 17.76,
|
||||
"rtf": 1.2992688716212386,
|
||||
"bytes": 852480,
|
||||
"packets": 121,
|
||||
"longest_packet_gap_seconds": 0.524428564007394,
|
||||
"required_buffer_after_first_pcm_seconds": 4.915577151976759
|
||||
},
|
||||
"llm_rounds": [
|
||||
{
|
||||
"seconds": 6.766007895988878,
|
||||
"completion_tokens": 512
|
||||
},
|
||||
{
|
||||
"seconds": 5.529365111986408,
|
||||
"completion_tokens": 512
|
||||
},
|
||||
{
|
||||
"seconds": 5.819661432993598,
|
||||
"completion_tokens": 512
|
||||
},
|
||||
{
|
||||
"seconds": 5.34849965601461,
|
||||
"completion_tokens": 512
|
||||
},
|
||||
{
|
||||
"seconds": 5.1384107880003285,
|
||||
"completion_tokens": 512
|
||||
}
|
||||
],
|
||||
"llm_overlap_seconds": 20.90590340795461,
|
||||
"llm_coverage": 0.9059973856138854,
|
||||
"thread_affinities": {
|
||||
"qwen_tts": [
|
||||
{
|
||||
"name": "python",
|
||||
"cpus": "2-5,8-11"
|
||||
}
|
||||
],
|
||||
"strata": [
|
||||
{
|
||||
"name": "cuda-EvtHandlr",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "cuda00001400006",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-adapt",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-host",
|
||||
"cpus": "0"
|
||||
},
|
||||
{
|
||||
"name": "strata-io",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-lookahea",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-pool-0",
|
||||
"cpus": "1"
|
||||
},
|
||||
{
|
||||
"name": "strata-pool-1",
|
||||
"cpus": "2"
|
||||
},
|
||||
{
|
||||
"name": "strata-pool-2",
|
||||
"cpus": "3"
|
||||
},
|
||||
{
|
||||
"name": "strata-stage",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-stdin",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-watchdog",
|
||||
"cpus": "6-9"
|
||||
}
|
||||
]
|
||||
},
|
||||
"running_cpu_samples": {
|
||||
"strata": {
|
||||
"0": 262,
|
||||
"1": 269,
|
||||
"2": 269,
|
||||
"3": 269,
|
||||
"8": 25,
|
||||
"9": 18,
|
||||
"6": 49,
|
||||
"7": 41
|
||||
},
|
||||
"qwen_tts": {
|
||||
"11": 82,
|
||||
"4": 150,
|
||||
"9": 120,
|
||||
"8": 114,
|
||||
"10": 152,
|
||||
"5": 101,
|
||||
"3": 3,
|
||||
"2": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
{
|
||||
"arm": "threads-2-b",
|
||||
"tts": {
|
||||
"seconds": 22.65576401699218,
|
||||
"first_pcm_seconds": 0.6643998369982,
|
||||
"audio_seconds": 17.76,
|
||||
"rtf": 1.2756623883441542,
|
||||
"bytes": 852480,
|
||||
"packets": 125,
|
||||
"longest_packet_gap_seconds": 0.6243940130225383,
|
||||
"required_buffer_after_first_pcm_seconds": 4.330261326006148
|
||||
},
|
||||
"llm_rounds": [
|
||||
{
|
||||
"seconds": 7.9347631850105245,
|
||||
"completion_tokens": 512
|
||||
},
|
||||
{
|
||||
"seconds": 5.863870653993217,
|
||||
"completion_tokens": 512
|
||||
},
|
||||
{
|
||||
"seconds": 5.62041178700747,
|
||||
"completion_tokens": 512
|
||||
},
|
||||
{
|
||||
"seconds": 6.1116366679780185,
|
||||
"completion_tokens": 512
|
||||
}
|
||||
],
|
||||
"llm_overlap_seconds": 20.905338217009557,
|
||||
"llm_coverage": 0.9227381694711432,
|
||||
"thread_affinities": {
|
||||
"qwen_tts": [
|
||||
{
|
||||
"name": "python",
|
||||
"cpus": "2-5,8-11"
|
||||
}
|
||||
],
|
||||
"strata": [
|
||||
{
|
||||
"name": "cuda-EvtHandlr",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "cuda00001400006",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-adapt",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-host",
|
||||
"cpus": "0"
|
||||
},
|
||||
{
|
||||
"name": "strata-io",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-lookahea",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-pool-0",
|
||||
"cpus": "1"
|
||||
},
|
||||
{
|
||||
"name": "strata-pool-1",
|
||||
"cpus": "2"
|
||||
},
|
||||
{
|
||||
"name": "strata-pool-2",
|
||||
"cpus": "3"
|
||||
},
|
||||
{
|
||||
"name": "strata-stage",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-stdin",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-watchdog",
|
||||
"cpus": "6-9"
|
||||
}
|
||||
]
|
||||
},
|
||||
"running_cpu_samples": {
|
||||
"strata": {
|
||||
"0": 230,
|
||||
"1": 239,
|
||||
"2": 238,
|
||||
"3": 238,
|
||||
"6": 43,
|
||||
"7": 58,
|
||||
"8": 47,
|
||||
"9": 4
|
||||
},
|
||||
"qwen_tts": {
|
||||
"4": 148,
|
||||
"5": 113,
|
||||
"8": 118,
|
||||
"9": 110,
|
||||
"11": 91,
|
||||
"2": 2,
|
||||
"10": 142
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
{
|
||||
"arm": "threads-3-a",
|
||||
"tts": {
|
||||
"seconds": 22.841064057021867,
|
||||
"first_pcm_seconds": 0.6769041410007048,
|
||||
"audio_seconds": 17.76,
|
||||
"rtf": 1.2860959491566366,
|
||||
"bytes": 852480,
|
||||
"packets": 127,
|
||||
"longest_packet_gap_seconds": 0.3254679490055423,
|
||||
"required_buffer_after_first_pcm_seconds": 4.543391700008652
|
||||
},
|
||||
"llm_rounds": [
|
||||
{
|
||||
"seconds": 56.838724961999105,
|
||||
"completion_tokens": 512
|
||||
},
|
||||
{
|
||||
"seconds": 6.309865877003176,
|
||||
"completion_tokens": 512
|
||||
},
|
||||
{
|
||||
"seconds": 6.126680915011093,
|
||||
"completion_tokens": 512
|
||||
},
|
||||
{
|
||||
"seconds": 5.718947537010536,
|
||||
"completion_tokens": 512
|
||||
}
|
||||
],
|
||||
"llm_overlap_seconds": 21.033532802044647,
|
||||
"llm_coverage": 0.920864840163979,
|
||||
"thread_affinities": {
|
||||
"qwen_tts": [
|
||||
{
|
||||
"name": "python",
|
||||
"cpus": "2-5,8-11"
|
||||
}
|
||||
],
|
||||
"strata": [
|
||||
{
|
||||
"name": "cuda-EvtHandlr",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "cuda00001400006",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-host",
|
||||
"cpus": "0"
|
||||
},
|
||||
{
|
||||
"name": "strata-host",
|
||||
"cpus": "0-3,6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-io",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-lookahea",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-pool-0",
|
||||
"cpus": "1"
|
||||
},
|
||||
{
|
||||
"name": "strata-pool-1",
|
||||
"cpus": "2"
|
||||
},
|
||||
{
|
||||
"name": "strata-pool-2",
|
||||
"cpus": "3"
|
||||
},
|
||||
{
|
||||
"name": "strata-stage",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-stdin",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-watchdog",
|
||||
"cpus": "6-9"
|
||||
}
|
||||
]
|
||||
},
|
||||
"running_cpu_samples": {
|
||||
"strata": {
|
||||
"0": 2,
|
||||
"6": 1,
|
||||
"1": 1,
|
||||
"7": 10,
|
||||
"8": 5,
|
||||
"9": 17
|
||||
},
|
||||
"qwen_tts": {
|
||||
"4": 137,
|
||||
"8": 128,
|
||||
"11": 153,
|
||||
"5": 101,
|
||||
"10": 149,
|
||||
"9": 165,
|
||||
"2": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
{
|
||||
"arm": "threads-3-b",
|
||||
"tts": {
|
||||
"seconds": 21.83568733901484,
|
||||
"first_pcm_seconds": 0.5456246779940557,
|
||||
"audio_seconds": 17.76,
|
||||
"rtf": 1.2294868997193038,
|
||||
"bytes": 852480,
|
||||
"packets": 133,
|
||||
"longest_packet_gap_seconds": 0.4042738779971842,
|
||||
"required_buffer_after_first_pcm_seconds": 3.6491853360098325
|
||||
},
|
||||
"llm_rounds": [
|
||||
{
|
||||
"seconds": 7.373180713999318,
|
||||
"completion_tokens": 512
|
||||
},
|
||||
{
|
||||
"seconds": 5.606386097992072,
|
||||
"completion_tokens": 512
|
||||
},
|
||||
{
|
||||
"seconds": 5.501058378984453,
|
||||
"completion_tokens": 512
|
||||
},
|
||||
{
|
||||
"seconds": 5.991467923013261,
|
||||
"completion_tokens": 512
|
||||
}
|
||||
],
|
||||
"llm_overlap_seconds": 20.19227690398111,
|
||||
"llm_coverage": 0.9247374076428833,
|
||||
"thread_affinities": {
|
||||
"qwen_tts": [
|
||||
{
|
||||
"name": "python",
|
||||
"cpus": "2-5,8-11"
|
||||
}
|
||||
],
|
||||
"strata": [
|
||||
{
|
||||
"name": "cuda-EvtHandlr",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "cuda00001400006",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-adapt",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-host",
|
||||
"cpus": "0"
|
||||
},
|
||||
{
|
||||
"name": "strata-io",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-lookahea",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-pool-0",
|
||||
"cpus": "1"
|
||||
},
|
||||
{
|
||||
"name": "strata-pool-1",
|
||||
"cpus": "2"
|
||||
},
|
||||
{
|
||||
"name": "strata-pool-2",
|
||||
"cpus": "3"
|
||||
},
|
||||
{
|
||||
"name": "strata-stage",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-stdin",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-watchdog",
|
||||
"cpus": "6-9"
|
||||
}
|
||||
]
|
||||
},
|
||||
"running_cpu_samples": {
|
||||
"strata": {
|
||||
"0": 224,
|
||||
"1": 228,
|
||||
"2": 228,
|
||||
"3": 228,
|
||||
"7": 44,
|
||||
"6": 57,
|
||||
"9": 6,
|
||||
"8": 6
|
||||
},
|
||||
"qwen_tts": {
|
||||
"8": 135,
|
||||
"4": 167,
|
||||
"11": 113,
|
||||
"9": 89,
|
||||
"10": 90,
|
||||
"5": 162,
|
||||
"2": 1,
|
||||
"3": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
{
|
||||
"arm": "threads-4-a",
|
||||
"tts": {
|
||||
"seconds": 24.148600015992997,
|
||||
"first_pcm_seconds": 0.5206274729862344,
|
||||
"audio_seconds": 17.76,
|
||||
"rtf": 1.359718469368975,
|
||||
"bytes": 852480,
|
||||
"packets": 125,
|
||||
"longest_packet_gap_seconds": 0.34408119998988695,
|
||||
"required_buffer_after_first_pcm_seconds": 6.027059033007827
|
||||
},
|
||||
"llm_rounds": [
|
||||
{
|
||||
"seconds": 7.292344492976554,
|
||||
"completion_tokens": 512
|
||||
},
|
||||
{
|
||||
"seconds": 5.583131104998756,
|
||||
"completion_tokens": 512
|
||||
},
|
||||
{
|
||||
"seconds": 5.474821751005948,
|
||||
"completion_tokens": 512
|
||||
},
|
||||
{
|
||||
"seconds": 5.828784255019855,
|
||||
"completion_tokens": 512
|
||||
},
|
||||
{
|
||||
"seconds": 5.15120771099464,
|
||||
"completion_tokens": 512
|
||||
}
|
||||
],
|
||||
"llm_overlap_seconds": 21.96396186100901,
|
||||
"llm_coverage": 0.9095335483822186,
|
||||
"thread_affinities": {
|
||||
"qwen_tts": [
|
||||
{
|
||||
"name": "python",
|
||||
"cpus": "2-5,8-11"
|
||||
}
|
||||
],
|
||||
"strata": [
|
||||
{
|
||||
"name": "cuda-EvtHandlr",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "cuda00001400006",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-adapt",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-host",
|
||||
"cpus": "0"
|
||||
},
|
||||
{
|
||||
"name": "strata-io",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-lookahea",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-pool-0",
|
||||
"cpus": "1"
|
||||
},
|
||||
{
|
||||
"name": "strata-pool-1",
|
||||
"cpus": "2"
|
||||
},
|
||||
{
|
||||
"name": "strata-pool-2",
|
||||
"cpus": "3"
|
||||
},
|
||||
{
|
||||
"name": "strata-stage",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-stdin",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-watchdog",
|
||||
"cpus": "6-9"
|
||||
}
|
||||
]
|
||||
},
|
||||
"running_cpu_samples": {
|
||||
"strata": {
|
||||
"0": 276,
|
||||
"1": 275,
|
||||
"2": 275,
|
||||
"3": 275,
|
||||
"6": 86,
|
||||
"9": 12,
|
||||
"8": 18,
|
||||
"7": 24
|
||||
},
|
||||
"qwen_tts": {
|
||||
"5": 182,
|
||||
"10": 191,
|
||||
"8": 155,
|
||||
"4": 175,
|
||||
"11": 152,
|
||||
"9": 124,
|
||||
"3": 4
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
{
|
||||
"arm": "threads-4-b",
|
||||
"tts": {
|
||||
"seconds": 23.01969491300406,
|
||||
"first_pcm_seconds": 0.5638623720151372,
|
||||
"audio_seconds": 17.76,
|
||||
"rtf": 1.2961539928493275,
|
||||
"bytes": 852480,
|
||||
"packets": 122,
|
||||
"longest_packet_gap_seconds": 0.3441820479929447,
|
||||
"required_buffer_after_first_pcm_seconds": 4.83512169401045
|
||||
},
|
||||
"llm_rounds": [
|
||||
{
|
||||
"seconds": 5.277643159002764,
|
||||
"completion_tokens": 512
|
||||
},
|
||||
{
|
||||
"seconds": 5.312491507007508,
|
||||
"completion_tokens": 512
|
||||
},
|
||||
{
|
||||
"seconds": 5.295687785022892,
|
||||
"completion_tokens": 512
|
||||
},
|
||||
{
|
||||
"seconds": 5.303503804985667,
|
||||
"completion_tokens": 512
|
||||
},
|
||||
{
|
||||
"seconds": 5.726375209982507,
|
||||
"completion_tokens": 512
|
||||
}
|
||||
],
|
||||
"llm_overlap_seconds": 20.7788718190277,
|
||||
"llm_coverage": 0.9026562644533357,
|
||||
"thread_affinities": {
|
||||
"qwen_tts": [
|
||||
{
|
||||
"name": "python",
|
||||
"cpus": "2-5,8-11"
|
||||
}
|
||||
],
|
||||
"strata": [
|
||||
{
|
||||
"name": "cuda-EvtHandlr",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "cuda00001400006",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-adapt",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-host",
|
||||
"cpus": "0"
|
||||
},
|
||||
{
|
||||
"name": "strata-io",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-lookahea",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-pool-0",
|
||||
"cpus": "1"
|
||||
},
|
||||
{
|
||||
"name": "strata-pool-1",
|
||||
"cpus": "2"
|
||||
},
|
||||
{
|
||||
"name": "strata-pool-2",
|
||||
"cpus": "3"
|
||||
},
|
||||
{
|
||||
"name": "strata-stage",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-stdin",
|
||||
"cpus": "6-9"
|
||||
},
|
||||
{
|
||||
"name": "strata-watchdog",
|
||||
"cpus": "6-9"
|
||||
}
|
||||
]
|
||||
},
|
||||
"running_cpu_samples": {
|
||||
"strata": {
|
||||
"0": 250,
|
||||
"1": 248,
|
||||
"2": 248,
|
||||
"3": 248,
|
||||
"6": 85,
|
||||
"7": 26,
|
||||
"8": 16,
|
||||
"9": 1
|
||||
},
|
||||
"qwen_tts": {
|
||||
"10": 189,
|
||||
"9": 147,
|
||||
"5": 143,
|
||||
"4": 176,
|
||||
"8": 138,
|
||||
"11": 149,
|
||||
"2": 1,
|
||||
"3": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
"""Bounded Athena thread comparison; only CPU policy and idle Qwen are changed."""
|
||||
import json, os, signal, subprocess, sys, time, urllib.request
|
||||
from pathlib import Path
|
||||
|
||||
stage = Path(__file__).resolve().parent
|
||||
plan_path = Path('/opt/athena-deck-dev/runtime/state/cpu-partition.json')
|
||||
key = json.load(sys.stdin)['key']
|
||||
headers = {'Authorization': 'Bearer ' + key}
|
||||
|
||||
def endpoint():
|
||||
req = urllib.request.Request('http://127.0.0.1:8108/api/v1/status', headers=headers)
|
||||
with urllib.request.urlopen(req, timeout=10) as response:
|
||||
return json.load(response)['endpoint']
|
||||
|
||||
def workers():
|
||||
root = json.loads(subprocess.check_output(['docker', 'inspect', 'athena-deck-dev']))[0]['State']['Pid']
|
||||
pending, seen, result = [root], set(), {}
|
||||
while pending:
|
||||
pid = pending.pop()
|
||||
if pid in seen:
|
||||
continue
|
||||
seen.add(pid)
|
||||
try:
|
||||
for children in Path(f'/proc/{pid}/task').glob('*/children'):
|
||||
try:
|
||||
pending.extend(map(int, children.read_text().split()))
|
||||
except OSError:
|
||||
pass
|
||||
cmd = Path(f'/proc/{pid}/cmdline').read_bytes().split(b'\0')
|
||||
if b'/app/qwen_native_worker.py' in cmd:
|
||||
result['qwen'] = (pid, cmd)
|
||||
elif cmd[0].endswith(b'/engine/strata'):
|
||||
result['strata'] = (pid, cmd)
|
||||
except (OSError, ValueError):
|
||||
pass
|
||||
return result
|
||||
|
||||
def idle():
|
||||
for _ in range(2):
|
||||
if endpoint()['active_requests']:
|
||||
raise RuntimeError('Live request active; thread change deferred')
|
||||
time.sleep(1)
|
||||
|
||||
def save_plan(value):
|
||||
sys.path.insert(0, '/opt/athena-deck-dev/source')
|
||||
import cpu_partition
|
||||
cpu_partition.placement(value, cpu_partition.topology())
|
||||
temp = plan_path.with_suffix('.threads.tmp')
|
||||
temp.write_text(json.dumps(value, indent=2) + '\n')
|
||||
temp.chmod(0o600)
|
||||
os.chown(temp, 65534, 65534)
|
||||
temp.replace(plan_path)
|
||||
|
||||
def select(generation):
|
||||
assert generation in (2, 3, 4)
|
||||
idle()
|
||||
value = json.loads(plan_path.read_text())
|
||||
assert value['qwen_codec_threads'] == 2
|
||||
assert value['qwen_tts'] == [2, 3, 4, 5, 8, 9, 10, 11]
|
||||
assert value['shared_cpus'] == [2, 3, 8, 9]
|
||||
assert value['qwen_cpu_flash_attention'] is False
|
||||
policy = json.loads(plan_path.with_name('audio-policy.json').read_text())
|
||||
assert policy['tts']['mode'] in ('auto', 'warm')
|
||||
found = workers()
|
||||
assert set(found) == {'qwen', 'strata'} and endpoint()['counts']['tts']['loaded']
|
||||
old_pid, cmd = found['qwen']
|
||||
strata_pid = found['strata'][0]
|
||||
backup = stage / 'thread-baseline.json'
|
||||
if not backup.exists():
|
||||
assert value['qwen_generation_threads'] == 2
|
||||
backup.write_text(json.dumps(value, indent=2) + '\n')
|
||||
backup.chmod(0o600)
|
||||
value['qwen_generation_threads'] = generation
|
||||
if int(cmd[-3]) != generation:
|
||||
idle()
|
||||
save_plan(value)
|
||||
# Only the identified, idle Qwen worker is terminated. Deck's existing
|
||||
# automatic residency loop loads the same profile with the new policy.
|
||||
os.kill(old_pid, signal.SIGTERM)
|
||||
until = time.monotonic() + 110
|
||||
while time.monotonic() < until:
|
||||
now = workers()
|
||||
if now.get('strata', (None,))[0] != strata_pid:
|
||||
raise RuntimeError('Strata process changed unexpectedly')
|
||||
qwen = now.get('qwen')
|
||||
if qwen and int(qwen[1][-3]) == generation and endpoint()['counts']['tts']['loaded']:
|
||||
# Process registration precedes native loading; allow readiness.
|
||||
time.sleep(3)
|
||||
if workers().get('qwen', (None,))[0] != qwen[0]:
|
||||
continue
|
||||
result = dict(generation_threads=generation, codec_threads=2,
|
||||
qwen_pid=qwen[0], strata_pid=strata_pid,
|
||||
allowed_cpus=sorted(os.sched_getaffinity(qwen[0])),
|
||||
active_requests=endpoint()['active_requests'])
|
||||
print(json.dumps(result), flush=True)
|
||||
return
|
||||
time.sleep(1)
|
||||
raise RuntimeError('TTS did not reload within the bounded wait')
|
||||
|
||||
if sys.argv[1] == 'select':
|
||||
select(int(sys.argv[2]))
|
||||
elif sys.argv[1] == 'status':
|
||||
found = workers()
|
||||
print(json.dumps(dict(endpoint=endpoint(), plan=json.loads(plan_path.read_text()),
|
||||
pids={k:v[0] for k,v in found.items()},
|
||||
threads={k:[s.decode() for s in v[1][-3:-1]] for k,v in found.items() if k=='qwen'})), flush=True)
|
||||
elif sys.argv[1] == 'warm':
|
||||
idle()
|
||||
data = dict(model='qwen-06b-q4-anna-cpu', voice='default', response_format='pcm',
|
||||
input='Die Sprachausgabe ist bereit.')
|
||||
req = urllib.request.Request('http://127.0.0.1:8120/v1/audio/speech',
|
||||
data=json.dumps(data).encode(),
|
||||
headers=dict(headers, **{'Content-Type':'application/json'}))
|
||||
size = 0
|
||||
with urllib.request.urlopen(req, timeout=60) as response:
|
||||
while True:
|
||||
block = response.read(16384)
|
||||
if not block:
|
||||
break
|
||||
size += len(block)
|
||||
assert 0 < size < 4*1024**2 and size%2 == 0
|
||||
print(json.dumps(dict(warmup_audio_seconds=size/48000)), flush=True)
|
||||
elif sys.argv[1] == 'warm-llm':
|
||||
idle()
|
||||
data = dict(model='flash-next-strata-iq3-dual',
|
||||
messages=[dict(role='user', content='Antworte nur mit OK.')],
|
||||
max_tokens=1, reasoning_effort='none', temperature=0)
|
||||
req = urllib.request.Request('http://127.0.0.1:8120/v1/chat/completions',
|
||||
data=json.dumps(data).encode(),
|
||||
headers=dict(headers, **{'Content-Type':'application/json'}))
|
||||
start = time.monotonic()
|
||||
with urllib.request.urlopen(req, timeout=180) as response:
|
||||
result = json.load(response)
|
||||
print(json.dumps(dict(warmup_llm_seconds=time.monotonic()-start,
|
||||
completion_tokens=result.get('usage',{}).get('completion_tokens'))), flush=True)
|
||||
else:
|
||||
raise ValueError('Unknown action')
|
||||
Reference in new issue
Block a user