Allow explicit shared CPU cores for Qwen and record streaming comparison

This commit is contained in:
Mikei386 committed 2026-10-22 14:32:09 +02:00
1 parent ba4904ea78
commit 746009b676
12 files changed
+833 -20

No files matched your search

+9 -8
View File
@@ -5,11 +5,11 @@ from pathlib import Path
NAME='cpu-partition.json'
def validate(value):
if not isinstance(value,dict) or set(value)-{'version','strata','qwen_tts','qwen_generation_threads','qwen_codec_threads','qwen_cpu_flash_attention'} or not {'version','strata','qwen_tts'}<=set(value) or type(value['version']) is not int or value['version']!=1:raise ValueError('Ungültige CPU-Aufteilung.')
for role in ('strata','qwen_tts'):
ids=value[role]
if not isinstance(ids,list) or not ids or any(type(n) is not int or not 0<=n<64 for n in ids) or len(set(ids))!=len(ids):raise ValueError('CPU-Aufteilung benötigt eindeutige CPU-IDs von 0 bis 63.')
if set(value['strata']) & set(value['qwen_tts']):raise ValueError('Strata und Qwen-TTS dürfen keine CPU teilen.')
if not isinstance(value,dict) or set(value)-{'version','strata','qwen_tts','shared_cpus','qwen_generation_threads','qwen_codec_threads','qwen_cpu_flash_attention'} or not {'version','strata','qwen_tts'}<=set(value) or type(value['version']) is not int or value['version']!=1:raise ValueError('Ungültige CPU-Aufteilung.')
for role in ('strata','qwen_tts','shared_cpus'):
ids=value.get(role,[])
if not isinstance(ids,list) or (role!='shared_cpus' and not ids) or any(type(n) is not int or not 0<=n<64 for n in ids) or len(set(ids))!=len(ids):raise ValueError('CPU-Aufteilung benötigt eindeutige CPU-IDs von 0 bis 63.')
if set(value['strata']) & set(value['qwen_tts'])!=set(value.get('shared_cpus',[])):raise ValueError('Gemeinsame CPUs müssen vollständig und ausdrücklich als shared_cpus angegeben werden.')
for field in ('qwen_generation_threads','qwen_codec_threads'):
n=value.get(field,4)
if type(n) is not int or not 1<=n<=4:raise ValueError('Qwen-Threadzahlen müssen zwischen 1 und 4 liegen.')
@@ -24,11 +24,12 @@ def topology():
return result
def placement(value,cores):
"""Reject changed hardware and SMT siblings shared by the two workers."""
"""Allow only explicitly shared full physical cores, never split SMT pairs."""
validate(value)
if not (set(value['strata'])|set(value['qwen_tts']))<=set(cores):raise ValueError('CPU-Aufteilung passt nicht zu den verfügbaren CPUs; Hardwarezuordnung prüfen.')
a={cores[n] for n in value['strata']};b={cores[n] for n in value['qwen_tts']}
if a & b:raise ValueError('Strata und Qwen-TTS dürfen keine SMT-Threads desselben Kerns teilen.')
shared=set(value.get('shared_cpus',[]))
if a & b!={cores[n] for n in shared}:raise ValueError('Geteilte SMT-Threads müssen als vollständiger gemeinsamer Kern angegeben werden.')
for role,selected in (('strata',a),('qwen_tts',b)):
if {n for n,c in cores.items() if c in selected}!=set(value[role]):raise ValueError('CPU-Aufteilung muss alle verfügbaren SMT-Threads eines ausgewählten Kerns enthalten.')
physical=[]
@@ -37,7 +38,7 @@ def placement(value,cores):
if len(physical)<2:raise ValueError('Strata benötigt mindestens zwei zugeordnete echte Kerne.')
aux=sorted(set(value['strata'])-set(physical))
if not aux:raise ValueError('Diese Strata-Aufteilung benötigt zusätzliche SMT-Threads für Hilfsthreads.')
return dict(strata=sorted(value['strata']),qwen_tts=sorted(value['qwen_tts']),qwen_generation_threads=value.get('qwen_generation_threads',4),qwen_codec_threads=value.get('qwen_codec_threads',4),qwen_cpu_flash_attention=value.get('qwen_cpu_flash_attention',True),strata_arguments=['--host-core','first','--pool-cores',','.join(map(str,physical[1:])),'--pool-workers',str(len(physical)-1),'--aux-cpus',','.join(map(str,aux))])
return dict(strata=sorted(value['strata']),qwen_tts=sorted(value['qwen_tts']),shared_cpus=sorted(shared),qwen_generation_threads=value.get('qwen_generation_threads',4),qwen_codec_threads=value.get('qwen_codec_threads',4),qwen_cpu_flash_attention=value.get('qwen_cpu_flash_attention',True),strata_arguments=['--host-core','first','--pool-cores',','.join(map(str,physical[1:])),'--pool-workers',str(len(physical)-1),'--aux-cpus',','.join(map(str,aux))])
def load(state):
path=Path(state)/NAME
+31 -11
View File
@@ -1,14 +1,16 @@
# CPU-Zuordnung für Strata und Qwen-TTS
Die optionale Datei `DECK_STATE_DIR/cpu-partition.json` trennt die Linux-CPU-
Zuordnung beider Worker. Ohne diese Datei bleibt das bisherige Verhalten erhalten.
Auf Athena (Ryzen 5 5600, sechs echte Kerne, zwölf SMT-Threads) ist vorgesehen:
Die optionale Datei `DECK_STATE_DIR/cpu-partition.json` legt die Linux-CPU-
Zuordnung beider Worker fest. Ohne diese Datei bleibt das bisherige Verhalten erhalten.
Gemeinsame CPUs sind nur nach ausdrücklicher Angabe erlaubt. Auf Athena
(Ryzen 5 5600, sechs echte Kerne, zwölf SMT-Threads) verwendet die neue Variante:
```json
{
"version": 1,
"strata": [0, 1, 2, 3, 6, 7, 8, 9],
"qwen_tts": [4, 5, 10, 11],
"qwen_tts": [2, 3, 4, 5, 8, 9, 10, 11],
"shared_cpus": [2, 3, 8, 9],
"qwen_generation_threads": 2,
"qwen_codec_threads": 2,
"qwen_cpu_flash_attention": false
@@ -17,9 +19,20 @@ Auf Athena (Ryzen 5 5600, sechs echte Kerne, zwölf SMT-Threads) ist vorgesehen:
Die IDs sind **logische CPUs**, keine Anzahl echter Kerne. Die SMT-Paare dieses
Hosts lauten 0/6, 1/7, 2/8, 3/9, 4/10 und 5/11. Strata erhält vier echte Kerne,
Qwen-TTS zwei. Diese Host-Zuordnung nicht ungeprüft auf einen anderen Rechner
übertragen. Deck prüft verfügbare IDs, Überschneidungen und vollständige SMT-Paare
vor dem Start; eine ungültige Zuordnung wird nicht still ignoriert.
Qwen-TTS vier, davon zwei gemeinsam mit Strata:
| Bereich | Echte Kerne | Logische CPUs |
| --- | --- | --- |
| nur Strata | 0–1 | 0,1,6,7 |
| gemeinsam | 2–3 | 2,3,8,9 |
| nur Qwen-TTS | 4–5 | 4,5,10,11 |
Diese Host-Zuordnung nicht ungeprüft auf einen anderen Rechner übertragen.
`shared_cpus` muss genau der Schnittmenge beider CPU-Listen entsprechen. Ohne
dieses optionale Feld sind weiterhin keinerlei Überschneidungen erlaubt;
bestehende getrennte Konfigurationen bleiben gültig. Deck prüft verfügbare IDs
und vollständige SMT-Paare vor dem Start. Getrennte SMT-Threads desselben echten
Kerns können diese Prüfung nicht umgehen.
## Umsetzung und Grenzen
@@ -34,8 +47,8 @@ Die übrigen Sampling-, GPU-, Kontext- und Slot-Einstellungen bleiben erhalten.
Qwen erbt den gesamten TTS-CPU-Bereich ohne zusätzliche Bindung jedes einzelnen
Bibliotheksthreads. Threadzahlen und CPU-Flash-Attention sind ausdrücklich in
derselben Datei gespeichert; auf zwei echten Kernen werden zwei Generierungs-
und zwei Codec-Threads verwendet, CPU-Flash-Attention aus. Zwei Codec-Frames
derselben Datei gespeichert. Zwei Generierungs- und zwei Codec-Threads sowie
CPU-Flash-Attention aus bleiben für den Sharing-Vergleich unverändert. Zwei Codec-Frames
und Nice10 bleiben erhalten. Die vorherigen vier plus vier Threads waren im
Zweikern-Test deutlich langsamer. Eine andere optionale Einstellung wird nicht
aus einem versteckten Hook oder einer veränderten Bibliothek geladen.
@@ -45,7 +58,9 @@ Das sind Affinitätseinstellungen für diese beiden Worker, **keine exklusive
Host-Cpuset-Partition**. Betriebssystem, andere Dienste und Deck-Hilfsprozesse
können diese CPUs weiterhin verwenden. Native Bibliotheken könnten Affinität
selbst verändern; deshalb bei Laufzeitupdates alle Threadmasken unter echter
Last erneut prüfen. Die Strata-Optionen decken auch ihre eigens gepinnten
Last erneut prüfen. Auf gemeinsamen Kernen konkurriert Qwen mit Nice10 gegen
Strata mit Nice0; zusätzliche nutzbare CPUs garantieren keine zusätzliche
CPU-Zeit. Die Strata-Optionen decken auch ihre eigens gepinnten
Pool-, Host- und Hilfsthreads ab. Keine Bibliothek wurde dafür gepatcht.
## Installation, Neustart und Wiederherstellung
@@ -70,7 +85,12 @@ prüfen und die Zuordnung anpassen. Der vollständige native Neuaufbau bleibt
innerhalb der bestehenden [Installationsanforderungen](../deploy/NATIVE_INSTALL_REQUIREMENTS.md)
noch separat abzunehmen; diese Änderung behauptet keinen vollständigen Host-Restore.
Rückfall im Leerlauf: `cpu-partition.json` aus der aktiven Zustandswurzel entfernen
Rückfall von der gemeinsamen Variante: TTS-Liste wieder auf `[4,5,10,11]`
begrenzen, `shared_cpus` entfernen und andere Werte erhalten. Worker im Leerlauf
neu laden. Vor dem Rückfall auf eine Deck-Version ohne Sharing-Support zuerst
diese getrennte Konfiguration zurückspielen.
Vollständiger Rückfall im Leerlauf: `cpu-partition.json` aus der aktiven Zustandswurzel entfernen
und Worker regulär neu starten. Die Quota kann anschließend auf den vorherigen
Manifestwert8 zurückgesetzt werden. Ein Rückfall auf ein älteres Deck-Image
benötigt ebenfalls das Entfernen dieser Datei, da ältere Versionen sie nicht
+12 -1
View File
@@ -1,4 +1,15 @@
## Strata/TTS CPU allocation ·22 October2026
## TTS: two exclusive plus two shared cores ·22 October2026
Current saved masks:Strata0–3/6–9 unchanged; Qwen-TTS2–5/8–11.
Explicit shared CPUs2,3,8,9, leaving4,5,10,11exclusive to TTS relative to Strata.
CPU quota12/RAM59GiB, GPU/model/voice settings and TTS2/2thread policy unchanged.
Image8cf88a02e30444e8. Matched same-process streaming test:17.76s PCM in
23.74s exclusive versus21.96s shared, RTF1.337→1.236; calculated startup reserve
5.40→3.78s.35focused tests passed. Partial improvement, still below realtime;
no phone-playback guarantee. Earlier disjoint settings below are historical.
[Measurements, native reproduction and rollback](experiments/tts-shared-cpu-2026-10-22/README.md).
## Strata/TTS CPU allocation ·22 October2026 (earlier disjoint allocation)
Saved allocation:Strata0–3/6–9(four physical cores/eight SMT threads),
Qwen-TTS4–5/10–11(two physical cores/four SMT threads). Shared Deck quota12,
@@ -0,0 +1,93 @@
# Two exclusive plus two shared TTS cores ·22 October2026
Michael explicitly requested two physical cores exclusively available to TTS
relative to Strata, plus two physical cores shared by both workloads. Strata
retains its four-core CPU range. Saved Linux logical CPUs on Ryzen5 5600:
| Range | Physical cores | Logical CPUs |
| --- | --- | --- |
| Strata only |0–1|0,1,6,7|
| Shared |2–3|2,3,8,9|
| TTS only |4–5|4,5,10,11|
CPU quota12/RAM59GiB, Strata0.1.47 IQ3 dual-slot profile, GPU split/reserves,
Qwen0.6B Q4/codec/Anna,2generation+2codec threads, CPU-Flash-Attention off,
Nice10 and160ms codec blocks remain unchanged. No Hermes/VPN changes.
This is process/thread affinity, not a host-wide exclusive CPU partition.
## Persistent implementation
`cpu_partition.py` accepts the optional `shared_cpus` list only when it exactly
matches the overlap of the Strata and TTS lists. Runtime topology validation
still requires complete physical SMT pairs; sharing only opposite SMT siblings
is rejected. Missing `shared_cpus` retains the previous strict-disjoint behavior.
The existing validated encrypted settings backup carries the same file;
actual shared-file settings restoration was tested.35focused tests passed.
Active image:`athena-deck-standalone:8cf88a02e30444e8`. Only the CPU policy module
changed in the application; a code-only layer reused the existing runtime.
No model/runtime rebuild or new package/service. Activation checked ordinary
authenticated status twice for0active requests and preserved the exact prior
CPU file/install manifest for automatic rollback. The original dual profile
reloaded normally:HTTP200,46.282s including load. Both workload masks were
observed under load. TTS ran on shared CPUs8/9(and occasionally2/3), while
Strata stayed off4/5/10/11. Previous stopped maintenance container is removed
after acceptance; previous image remains available.
## Streaming results
The same synthetic German passage is sent to the normal PCM speech endpoint.
The measurement client counts/discards PCM and inspects no conversational user
content. Deck's normal synthetic-job output/history behavior is unchanged. Separate bounded
synthetic Strata requests continue until TTS completes. `llm_coverage` measures
overlap from each request's first content to its end; brief gaps remain between
requests. No actual Conduit call or phone playback was triggered.
| Condition | Audio | Total | RTF | First PCM | Required additional startup buffer |
| --- | ---: | ---: | ---: | ---: | ---: |
| Initial exclusive baseline,1024-token cap |17.76s|26.346s|1.483|0.563s|8.122s|
| Shared run1,1024-token cap |17.76s|21.975s|1.237|0.610s|3.765s|
| Shared run2,1024-token cap |17.76s|21.130s|1.190|0.569s|2.920s|
| Matched exclusive,512-token cap |17.76s|23.744s|1.337|0.767s|5.396s|
| Matched shared,512-token cap |17.76s|21.957s|1.236|0.537s|3.779s|
The initial before/after has a restart between conditions and varying LLM output
counts(566or1024); do not interpret its full difference as a causal speedup.
The additional matched pair uses the same loaded Strata and Qwen processes,
identical512-token limits(all five LLM requests reached512in each arm), and
changes only the live affinity of the owned Qwen threads. It narrows TTS to its
exclusive CPUs temporarily, then restores the requested shared CPU range in a
finally block. The saved production policy is never narrowed. LLM coverage
was91.0% versus90.0%; sampling is100ms and is not exact CPU-time attribution.
That matched pair reduces generation wall time by7.5% and calculated startup
buffer by1.62s. Longest packet gap is0.444s exclusive versus0.505s shared, so
not every jitter measure improves. Single ordered pair, no randomization or
quality scoring; no universal throughput or phone-playback guarantee.
**The new allocation helps modestly but remains slower than realtime.**
## Reproduction, native restore and rollback
`bench.py` records only technical counts/timings/masks, consumes the existing API
credential as stdin JSON, and stores results beside itself. Never pass/store the
credential in arguments, Git or logs. It refuses to start while normal API
requests are active. Current reproduction targets Athena's explicit profile IDs,
loopback ports and existing voice; those are qualification conditions, not
generic installation defaults. Synthetic output is bounded per request and
the load loop stops once the speech request ends. The committed script uses
the512-token matched limit; initial runs used1024.
For today's container it discovers the managed Deck PID with Docker. For a
native Debian/systemd Deck, supply `--deck-pid MAIN_PID` from that service;
worker discovery and affinity observation then require only Linux `/proc`.
Restore the updated Deck source including the CPU policy module and the saved
`cpu-partition.json`, validate the new host's topology, preserve file owner/
mode0600, and permit all configured CPUs in the parent service(1200%quota on
this host). No worker requires Docker. Full host/native restore qualification
remains the existing open installation task.
Rollback at idle:restore `qwen_tts:[4,5,10,11]`, remove `shared_cpus`, preserve
the other settings, and reload the workers. Restore that old file before an
older image that rejects the shared field. No model, profile or voice deletion.
Scoped maintenance directory:`/opt/athena-deck-dev/tts-shared-cpu-20261022`.
See[configuration and native installation](../../CPU_PARTITION.md).
@@ -0,0 +1,109 @@
{
"arm": "before",
"tts": {
"seconds": 26.345561609981814,
"first_pcm_seconds": 0.5629670549824368,
"audio_seconds": 17.76,
"rtf": 1.4834212618233003,
"bytes": 852480,
"packets": 119,
"longest_packet_gap_seconds": 0.42372539098141715,
"required_buffer_after_first_pcm_seconds": 8.121515240014997
},
"llm_rounds": [
{
"seconds": 11.776726370997494,
"completion_tokens": 1024
},
{
"seconds": 10.466018856997835,
"completion_tokens": 1024
},
{
"seconds": 9.945477088011103,
"completion_tokens": 1024
}
],
"llm_overlap_seconds": 25.03941150996252,
"llm_coverage": 0.9504223853962399,
"thread_affinities": {
"qwen_tts": [
{
"name": "python",
"cpus": "4-5,10-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": 304,
"1": 302,
"2": 302,
"3": 302,
"8": 32,
"6": 70,
"9": 13,
"7": 48
},
"qwen_tts": {
"5": 201,
"10": 209,
"11": 207,
"4": 208
}
}
}
@@ -0,0 +1,93 @@
"""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 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,117 @@
{
"arm": "matched-exclusive",
"tts": {
"seconds": 23.743657894985517,
"first_pcm_seconds": 0.7674097220005933,
"audio_seconds": 17.76,
"rtf": 1.3369176742672024,
"bytes": 852480,
"packets": 126,
"longest_packet_gap_seconds": 0.4438720670004841,
"required_buffer_after_first_pcm_seconds": 5.395635766985361
},
"llm_rounds": [
{
"seconds": 5.7061521190044004,
"completion_tokens": 512
},
{
"seconds": 5.374325632001273,
"completion_tokens": 512
},
{
"seconds": 5.474937899009092,
"completion_tokens": 512
},
{
"seconds": 5.4010014990053605,
"completion_tokens": 512
},
{
"seconds": 5.133676943019964,
"completion_tokens": 512
}
],
"llm_overlap_seconds": 21.610080538026523,
"llm_coverage": 0.9101411683744993,
"thread_affinities": {
"qwen_tts": [
{
"name": "python",
"cpus": "4-5,10-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": 254,
"2": 254,
"3": 254,
"6": 25,
"7": 83,
"8": 19,
"9": 8
},
"qwen_tts": {
"4": 209,
"10": 196,
"11": 208,
"5": 185
}
}
}
@@ -0,0 +1,121 @@
{
"arm": "matched-shared",
"tts": {
"seconds": 21.956582993996562,
"first_pcm_seconds": 0.536884569999529,
"audio_seconds": 17.76,
"rtf": 1.2362940874998063,
"bytes": 852480,
"packets": 126,
"longest_packet_gap_seconds": 0.5047344529884867,
"required_buffer_after_first_pcm_seconds": 3.778704298009398
},
"llm_rounds": [
{
"seconds": 5.1832967049849685,
"completion_tokens": 512
},
{
"seconds": 5.291258624987677,
"completion_tokens": 512
},
{
"seconds": 5.315704726002878,
"completion_tokens": 512
},
{
"seconds": 5.303939313016599,
"completion_tokens": 512
},
{
"seconds": 5.165245231008157,
"completion_tokens": 512
}
],
"llm_overlap_seconds": 19.75242526596412,
"llm_coverage": 0.8996128983897399,
"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": 244,
"1": 243,
"2": 243,
"3": 243,
"9": 7,
"6": 64,
"7": 18,
"8": 16
},
"qwen_tts": {
"5": 29,
"10": 138,
"11": 131,
"4": 166,
"8": 92,
"9": 143,
"3": 1,
"2": 2
}
}
}
@@ -0,0 +1,117 @@
{
"arm": "shared-1",
"tts": {
"seconds": 21.97487347997958,
"first_pcm_seconds": 0.6096372389874887,
"audio_seconds": 17.76,
"rtf": 1.2373239572060573,
"bytes": 852480,
"packets": 133,
"longest_packet_gap_seconds": 0.443657378986245,
"required_buffer_after_first_pcm_seconds": 3.7645343580120247
},
"llm_rounds": [
{
"seconds": 8.477586665016133,
"completion_tokens": 566
},
{
"seconds": 6.108662295999238,
"completion_tokens": 566
},
{
"seconds": 6.029036216990789,
"completion_tokens": 566
},
{
"seconds": 5.958051610010443,
"completion_tokens": 566
}
],
"llm_overlap_seconds": 20.280136793968268,
"llm_coverage": 0.9228784326082552,
"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": 246,
"1": 248,
"2": 248,
"3": 248,
"6": 43,
"8": 31,
"7": 42,
"9": 19
},
"qwen_tts": {
"9": 100,
"11": 87,
"10": 140,
"2": 1,
"5": 126,
"4": 129,
"8": 108,
"3": 1
}
}
}
@@ -0,0 +1,112 @@
{
"arm": "shared-2",
"tts": {
"seconds": 21.12998080998659,
"first_pcm_seconds": 0.5687970180006232,
"audio_seconds": 17.76,
"rtf": 1.1897511717334792,
"bytes": 852480,
"packets": 144,
"longest_packet_gap_seconds": 0.4439345129940193,
"required_buffer_after_first_pcm_seconds": 2.9201214499957864
},
"llm_rounds": [
{
"seconds": 6.088351852988126,
"completion_tokens": 566
},
{
"seconds": 6.236085355019895,
"completion_tokens": 566
},
{
"seconds": 10.668124029994942,
"completion_tokens": 1024
}
],
"llm_overlap_seconds": 19.980737588979537,
"llm_coverage": 0.9456107778165188,
"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": 210,
"1": 213,
"2": 213,
"3": 213,
"8": 13,
"7": 37,
"9": 1,
"6": 59
},
"qwen_tts": {
"9": 167,
"4": 125,
"5": 68,
"10": 100,
"8": 103,
"11": 110,
"3": 2
}
}
}
+8
View File
@@ -88,6 +88,14 @@ class RestoreTests(unittest.TestCase):
self.server.backup._apply_settings(legacy);self.assertFalse((self.root/'cpu-partition.json').exists())
bad=copy.deepcopy(doc);bad['settings']['cpu-partition.json']['qwen_tts'].append(0)
with self.assertRaises(ValueError):validate(bad)
def test_explicit_shared_cpu_partition_survives_backup_and_restore(self):
from test_cpu_partition import PLAN
plan={**PLAN,'qwen_tts':[2,3,4,5,8,9,10,11],'shared_cpus':[2,3,8,9]}
(self.root/'cpu-partition.json').write_text(json.dumps(plan))
doc=self.server.backup.snapshot(include_history=False);validate(doc)
restored=open_backup(seal(doc,'backup secure password'),'backup secure password')
(self.root/'cpu-partition.json').unlink();self.server.backup._apply_settings(restored)
self.assertEqual(json.loads((self.root/'cpu-partition.json').read_text()),plan)
def test_remix_runtime_recipe_and_restore(self):
from remix_runtime import VERSION
self.server.remix_runtime.status=Mock(return_value=dict(installed=True,version=VERSION,job=None))
+11
View File
@@ -15,6 +15,17 @@ class CPUPlacementTests(unittest.TestCase):
def test_reject_shared_physical_core_missing_sibling_and_changed_hardware(self):
for change,cores in ((dict(strata=[0,1,2,3,6,7,8],qwen_tts=[4,5,9,10,11]),CORES),(dict(qwen_tts=[4,5]),CORES),({}, {n:c for n,c in CORES.items() if n!=11})):
with self.subTest(change=change),self.assertRaises(ValueError):cpu.placement({**PLAN,**change},cores)
def test_explicit_two_shared_cores_leave_two_exclusive_for_each_worker(self):
shared={2,3,8,9};qwen=sorted(set(PLAN['qwen_tts'])|shared)
p=cpu.placement({**PLAN,'qwen_tts':qwen,'shared_cpus':sorted(shared)},CORES)
self.assertEqual(p['strata_arguments'],cpu.placement(PLAN,CORES)['strata_arguments'])
self.assertEqual(p['shared_cpus'],sorted(shared))
self.assertEqual({CORES[n] for n in set(p['qwen_tts'])-shared},{(0,4),(0,5)})
self.assertEqual({CORES[n] for n in set(p['strata'])-shared},{(0,0),(0,1)})
self.assertEqual((p['qwen_generation_threads'],p['qwen_codec_threads'],p['qwen_cpu_flash_attention']),(2,2,False))
def test_shared_cpus_must_match_overlap_and_include_whole_smt_pairs(self):
for changes in ({'shared_cpus':[2,3,8,9]}, {'qwen_tts':[2,3,4,5,8,9,10,11]}, {'qwen_tts':[2,3,4,5,8,9,10,11],'shared_cpus':[2,3]}, {'qwen_tts':[4,5,8,9,10,11],'shared_cpus':[8,9]}):
with self.subTest(changes=changes),self.assertRaises(ValueError):cpu.placement({**PLAN,**changes},CORES)
def test_reject_invalid_or_overlapping_ids(self):
for change in (dict(version=True),dict(strata=[True]),dict(strata=[0,0]),dict(qwen_tts=[64]),dict(qwen_tts=[3,4,5,10,11]),dict(extra='unknown'),dict(qwen_generation_threads=0),dict(qwen_codec_threads=True),dict(qwen_cpu_flash_attention=0)):
with self.subTest(change=change),self.assertRaises(ValueError):cpu.validate({**PLAN,**change})