Record isolated Q4 speech-codec comparison and reject speed claim

This commit is contained in:
Mikei386 committed 2026-10-22 15:34:20 +02:00
1 parent 8f7917d55d
commit 7bedeb06ca
12 files changed
+1088

No files matched your search

+11
View File
@@ -1,3 +1,14 @@
## TTS Q4codec comparison ·22 October2026
Native0.4.2 loads the pinned Q4codec with the same Q4talker and Anna reference,
but ABBA trials under concurrent Strata load show no speed gain:17.76s speech
takes mean22.519s with Q8codec versus23.189s with Q4codec. Candidate rejected;
original Q8codec,2/2threads, shared CPU plan and all production workers/settings
unchanged. Additional public candidate and remote synthetic audio removed;
no image/runtime/profile/Hermes change. Two local synthetic listening samples
retained outside Git, no subjective quality claim or actual phone test.
[Measurements, sources, cleanup and native reproduction](experiments/tts-codec-q4-2026-10-22/README.md).
## TTS generation-thread comparison ·22 October2026
Two controlled trials each with2/3/4generation threads and2codec threads:
@@ -0,0 +1,111 @@
# Qwen Q4 audio-codec comparison ·22 October2026
**Rejected as a speed improvement.** Same Anna reference and Q4 talker,
Q8codec mean22.519s versus Q4codec23.189s for17.76s speech under simultaneous
bounded Strata load. Original production workers and settings never changed.
Q4 is therefore not added to the production component recipe and no image
update is needed. Final endpoint running, Strata/TTS/STT loaded,0active requests.
## Public candidate and compatibility
Same repository/revision as the existing assets:
`Serveurperso/Qwen3-TTS-GGUF@b7ee2e8c7459c3bea99da23e3d178125a7d1713c`.
| Codec file | Bytes | SHA-256 |
| --- | ---: | --- |
|qwen-tokenizer-12hz-Q8_0.gguf|291150624|1883beeed99348fc35e23dd225e9082f93f6f8c109330a33d935baa8acdbfd94|
|qwen-tokenizer-12hz-Q4_K_M.gguf|254974752|cf3788b4d50aaa665fb6e57c170396aae03a3555fea52d2b5d0cda902d658039|
The Q4 file is downloaded from its pinned public URL and checksum-verified.
GGUF headers show identical tensor names/shapes;62decoder tensor types and
48encoder tensor types change. Decoder weight bytes fall201270724→177677764;
151135684bytes of F32/F16 decoder weights remain unchanged. That unchanged
portion is75.1% of the original decoder's **stored bytes**, not75.1% of its
parameter count or runtime work. Full codec file size falls12.4%.
The existing native CPU0.4.2/ABI5 runtime successfully loads and synthesizes
with both codecs. No library patch, new package, image, Hermes change, profile
change, production weight replacement or new persistent service was required.
This confirms the tested compatibility, not universal codec qualification.
## Controlled comparison
Existing Ryzen5 5600, TTS CPUs2–5/8–11(two exclusive physical cores plus two
shared with Strata),2generation/2codec threads,2stream frames, Nice10,
CPU flash attention off, same Q4talker, seed42, greedy, speaker-only Anna,
same application speech preprocessing/sentence splitter and max1024tokens
per sentence. Strata IQ3dual remains loaded with unchanged CPU/GPU/context
settings. All synthetic LLM requests use512output tokens, temperature0 and
reasoning none. No real user conversation or incoming call is used as input.
| Arm | Speech | Synthesis | RTF | First PCM | Calculated extra startup reserve |
| --- | ---: | ---: | ---: | ---: | ---: |
|Q8 A|17.76s|22.650s|1.275|0.392s|4.608s|
|Q4 A|17.76s|23.015s|1.296|0.444s|4.963s|
|Q4 B|17.76s|23.362s|1.315|0.540s|5.207s|
|Q8 B|17.76s|22.389s|1.261|0.386s|4.394s|
Two runs per codec in ABBA order. Q4's observed mean is3.0% slower; this small
sample is evidence of **no demonstrated speed gain**, not a universal3% penalty.
LLM generation covers88.6–91.5% of speech synthesis; gaps remain between bounded
requests. Peak native RSS is approximately69MiB lower with Q4. All memory-event
counters remain unchanged, no measured external-request overlap or monitoring
failure. Neither codec reaches realtime.
The comparison uses a separate short-lived native worker inside the existing
Deck container. The production Q8 worker stays resident and idle; the test
adds a second model footprint. Initial admission requires7GiB host available
RAM and6GiB cgroup headroom. The test worker has an8GiB virtual-address limit
and60second cooperative synthesis timer, with bounded protocol waits and
targeted cleanup of only the identified test process. These are not a separate
hard RSS cgroup. `health.low_memory` would flag headroom below1.5GiB; it did not
occur. Production PIDs remain Qwen855546/Strata855651 for every measured arm.
The CPU-policy file is checked unchanged after each run.
Each native instance loads/caches the same existing Anna reference in memory
and runs the same short warmup first. No reference copy is made. Measured times
exclude model loading/warmup and WAV writing; they measure native callback
arrival rather than the normal HTTP speech endpoint or actual phone playback.
Both arms use the same path. Scalar native profiles show almost all elapsed
time is within native synthesis; they do not distinguish talker, code predictor,
codec computation and CPU scheduling waits.
## Audio and cleanup
Both A-run WAVs are valid24kHz mono PCM16 with426240samples/17.76s and no clipped
samples. Their aligned waveform correlation is0.98939. These are technical
checks, **not subjective listening, a speaker-identity score or proof of equal
quality**. Local synthetic listening samples are kept outside Git under
`outputs/tts-codec-q4-20261022/`; the original Anna reference is never exported.
After all four measurements the test processes exit. The exact six files in
the isolated state experiment folder(public Q4GGUF, worker script and four
synthetic WAVs) are removed after checking no matching test process is active:
258389921bytes released. The now-empty state experiment folder is removed.
Only reproducible scripts/technical results remain in the separate maintenance
directory `/opt/athena-deck-dev/tts-codec-q4-20261022` and this report; two local
synthetic WAVs remain available for listening. No scheduler hook or monitor is
left running. Production continues with its original Q8codec and Anna.
## Reproduction and native restore
`prepare.py` downloads only the pinned public Q4candidate and copies the test
worker. `inspect_codecs.py` reads only the two public GGUF headers. `bench.py`
consumes an existing API key as stdin JSON, discovers only the managed Deck
process descendants, refuses active requests and runs one requested arm.
No API key is passed in arguments or stored in results. Adapt its Athena paths
explicitly if reproducing; the Docker adapter is only for today's experiment.
For native Debian/systemd use the already documented0.4.2CPU environment and
application source on PYTHONPATH, run `worker.py` directly with the actual
model/codec/reference paths and validated CPU topology as stdin configuration,
then issue the same warmup/test protocol. Observe the same RAM admission and
ensure cleanup affects only that experiment worker. No additional production
installer, backup or restore dependency is introduced because this candidate
is rejected and removed. Original voices/models/configuration remain covered
by their existing encrypted-backup recipes; full native host restoration is
still the separately documented open qualification task.
Reproduce only in idle time, complete the bounded runs and remove the candidate
afterwards. No rollback of production is necessary: no production setting was
changed. The existing component recipe intentionally remains pinned to Q8.
@@ -0,0 +1,16 @@
{
"q8-a": {
"seconds": 17.76,
"rms": 0.035333489515344645,
"peak": 0.284149169921875,
"clipped_fraction": 0.0
},
"q4-a": {
"seconds": 17.76,
"rms": 0.035293632471161504,
"peak": 0.287322998046875,
"clipped_fraction": 0.0
},
"waveform_correlation": 0.989390464809971,
"not_a_subjective_voice_quality_assessment": true
}
@@ -0,0 +1,190 @@
"""Isolated codec A/B with bounded synthetic Strata load; no production changes."""
import concurrent.futures, json, os, queue, 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]
assert arm in ('q8-a', 'q4-a', 'q4-b', 'q8-b')
headers = {'Authorization':'Bearer '+key, 'Content-Type':'application/json'}
state_root = Path('/opt/athena-deck-dev/runtime/state')
experiment = state_root/'experiments/tts-codec-q4-20261022'
container_root = Path('/var/lib/deck/experiments/tts-codec-q4-20261022')
text = ('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.')
def status():
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 idle():
for _ in range(2):
assert status()['active_requests'] == 0, 'Real request active; test deferred'
time.sleep(1)
def workers():
root = int(subprocess.check_output(['docker','inspect','--format','{{.State.Pid}}','athena-deck-dev']))
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 = [x.decode() for x in Path(f'/proc/{pid}/cmdline').read_bytes().split(b'\0') if x]
if not cmd:
continue
if '/app/qwen_native_worker.py' in cmd:
result['qwen'] = (pid, cmd)
elif cmd[0].endswith('/engine/strata'):
result['strata'] = (pid, cmd)
except (OSError, ValueError):
pass
return root, result
idle()
deck_pid, before = workers()
assert set(before) == {'qwen','strata'}
cmd = before['qwen'][1]
assert cmd[5] == 'Q4' and cmd[7:] == ['2','2']
assert cmd[3].startswith('/var/lib/deck/') and Path(cmd[3]).name == 'model.gguf'
plan_bytes = (state_root/'cpu-partition.json').read_bytes()
plan = json.loads(plan_bytes)
assert plan['qwen_tts'] == [2,3,4,5,8,9,10,11]
assert plan['qwen_cpu_flash_attention'] is False
cg = Path('/sys/fs/cgroup')/Path(f'/proc/{deck_pid}/cgroup').read_text().strip().split(':',2)[2].lstrip('/')
def headroom():
available = next(int(s.split()[1])*1024 for s in Path('/proc/meminfo').read_text().splitlines() if s.startswith('MemAvailable:'))
return available, int((cg/'memory.max').read_text())-int((cg/'memory.current').read_text())
available, cgroup_free = headroom()
assert available >= 7*1024**3 and cgroup_free >= 6*1024**3, 'Insufficient headroom for isolated test'
events_before = (cg/'memory.events').read_text()
codec = cmd[3] if arm.startswith('q8') else str(container_root/'qwen-tokenizer-12hz-Q4_K_M.gguf')
script = str(container_root/'worker.py')
child = subprocess.Popen(['docker','exec','-i','-u','65534:65534','-w','/app','athena-deck-dev',cmd[0],script],
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL,
text=True, bufsize=1)
messages = queue.Queue()
inside_pid = None
def read_worker():
try:
for line in child.stdout:
messages.put(json.loads(line))
finally:
messages.put(None)
reader = threading.Thread(target=read_worker, daemon=True)
reader.start()
def read_event(expected, timeout=90):
value = messages.get(timeout=timeout)
if value is None:
raise RuntimeError('Isolated codec worker exited')
if value.get('event') != expected:
raise RuntimeError('Unexpected benchmark protocol event: '+json.dumps(value))
return value
def send(value):
child.stdin.write(json.dumps(value)+'\n')
child.stdin.flush()
stop = threading.Event()
ready = threading.Event()
rounds = []
health = {}
def load():
deadline = time.monotonic()+90
for number in range(8):
if stop.is_set():
return
assert time.monotonic() < deadline, 'Synthetic LLM load limit'
body = 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(number+1)+'.')],
max_tokens=512, reasoning_effort='none', temperature=0,
stream=True, stream_options=dict(include_usage=True))
request = urllib.request.Request('http://127.0.0.1:8120/v1/chat/completions',
data=json.dumps(body).encode(), headers=headers)
start, first, tokens = time.monotonic(), None, 0
try:
with urllib.request.urlopen(request, timeout=120) as response:
for line in response:
if not line.startswith(b'data: ') or line.strip() == b'data: [DONE]':
continue
data = json.loads(line[6:])
tokens = (data.get('usage') or {}).get('completion_tokens',tokens)
if first is None and any(c.get('delta',{}).get('content') for c in data.get('choices',[])):
first = time.monotonic()
ready.set()
rounds.append(dict(start=start, first=first, end=time.monotonic(), completion_tokens=tokens))
except Exception:
health['load_failed'] = True
ready.set()
raise
assert stop.is_set(), 'Synthetic load ended before speech'
def monitor():
while not stop.wait(.5):
try:
if status()['active_requests'] > 1:
health['external_request_overlap'] = True
if min(headroom()) < 1536*1024**2:
health['low_memory'] = True
except Exception:
health['monitor_failed'] = True
try:
send(dict(model=cmd[2], codec=codec, voice=cmd[4], cpus=plan['qwen_tts']))
loaded = read_event('ready')
inside_pid = loaded['pid']
print(json.dumps(dict(arm=arm, phase='isolated_worker_ready', load_seconds=loaded['load_seconds'])), flush=True)
send(dict(action='speak', label='warmup', text='Die Sprachausgabe ist bereit.'))
read_event('started')
warmup = read_event('result')
idle()
monitor_thread = threading.Thread(target=monitor, daemon=True)
monitor_thread.start()
try:
with concurrent.futures.ThreadPoolExecutor(max_workers=1) as executor:
future = executor.submit(load)
try:
assert ready.wait(100) and not health.get('load_failed'), 'Strata did not start'
send(dict(action='speak', label=arm, text=text))
read_event('started')
speech = read_event('result', timeout=75)
finally:
stop.set()
future.result()
finally:
stop.set()
monitor_thread.join(12)
overlap = sum(max(0,min(r['end'],speech['ended'])-max(r['first'] or r['end'],speech['started'])) for r in rounds)
after = workers()[1]
assert {k:v[0] for k,v in before.items()} == {k:v[0] for k,v in after.items()}, 'Production worker changed'
assert (state_root/'cpu-partition.json').read_bytes() == plan_bytes
result = dict(arm=arm, codec_quant='Q8_0' if arm.startswith('q8') else 'Q4_K_M',
generation_threads=2, codec_threads=2, native_runtime='0.4.2',
tts={k:v for k,v in speech.items() if k not in ('event','started','ended')},
llm_rounds=[dict(seconds=r['end']-r['start'],completion_tokens=r['completion_tokens']) for r in rounds],
llm_coverage=overlap/speech['seconds'], health=health,
production_workers_unchanged=True, cpu_policy_unchanged=True,
memory_events_unchanged=(cg/'memory.events').read_text()==events_before)
(stage/(arm+'.json')).write_text(json.dumps(result, indent=2)+'\n')
print(json.dumps(result), flush=True)
finally:
stop.set()
try:
if child.poll() is None:
send(dict(action='exit'))
child.stdin.close()
child.wait(timeout=20)
except (BrokenPipeError, subprocess.TimeoutExpired):
if inside_pid is not None:
# Verify this exact experiment script before terminating only it.
terminate = "import os,signal;from pathlib import Path;p="+str(inside_pid)+";assert "+repr(script.encode())+" in Path(f'/proc/{p}/cmdline').read_bytes().split(b'\\0');os.kill(p,signal.SIGTERM)"
subprocess.run(['docker','exec','-u','65534:65534','athena-deck-dev',cmd[0],'-c',terminate],
check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=15)
child.wait(timeout=15)
@@ -0,0 +1,37 @@
{
"q8": {
"file_bytes": 291150624,
"weight_bytes_by_group_and_ggml_type": {
"decoder": {
"0": 34902148,
"1": 116233536,
"8": 50135040
},
"encoder": {
"1": 27345792,
"0": 35765632,
"8": 26738688
}
}
},
"q4": {
"file_bytes": 254974752,
"weight_bytes_by_group_and_ggml_type": {
"decoder": {
"0": 34902148,
"1": 116233536,
"12": 26542080
},
"encoder": {
"1": 27345792,
"0": 35765632,
"12": 14155776
}
}
},
"changed_tensor_types_by_group": {
"decoder": 62,
"encoder": 48
},
"same_tensor_names_and_shapes": true
}
@@ -0,0 +1,52 @@
"""Read only public GGUF headers to locate quantization differences."""
import collections, json, math, struct, sys
from pathlib import Path
root = Path('/opt/athena-deck-dev/runtime/state')
pid = int(sys.argv[1])
cmd = [x.decode() for x in Path(f'/proc/{pid}/cmdline').read_bytes().split(b'\0') if x]
assert cmd[1] == '/app/qwen_native_worker.py'
original = root/Path(cmd[3]).relative_to('/var/lib/deck')
candidate = root/'experiments/tts-codec-q4-20261022/qwen-tokenizer-12hz-Q4_K_M.gguf'
def inspect(path):
with path.open('rb') as source:
def number(fmt):
return struct.unpack('<'+fmt, source.read(struct.calcsize('<'+fmt)))[0]
def string():
return source.read(number('Q')).decode()
def skip(kind):
if kind == 8:
source.seek(number('Q'), 1)
elif kind == 9:
element, length = number('I'), number('Q')
for _ in range(length):
skip(element)
else:
source.seek({0:1,1:1,2:2,3:2,4:4,5:4,6:4,7:1,10:8,11:8,12:8}[kind],1)
assert source.read(4) == b'GGUF'
assert number('I') == 3
tensors, entries = number('Q'), number('Q')
for _ in range(entries):
string()
skip(number('I'))
groups = collections.defaultdict(lambda:collections.Counter())
layout = {}
for _ in range(tensors):
name = string()
dims = [number('Q') for _ in range(number('I'))]
kind, offset = number('I'), number('Q')
group = 'decoder' if name.startswith('tok_dec.') else 'encoder' if name.startswith('tok_enc.') else 'other'
layout[name] = (dims,kind)
block, size = {0:(1,4),1:(1,2),8:(32,34),12:(256,144),13:(256,176),14:(256,210)}[kind]
groups[group][str(kind)] += math.prod(dims)//block*size
return dict(file_bytes=path.stat().st_size, weight_bytes_by_group_and_ggml_type=dict(groups)),layout
old, a = inspect(original)
new, b = inspect(candidate)
assert set(a) == set(b) and all(a[k][0] == b[k][0] for k in a)
changed = collections.Counter('decoder' if k.startswith('tok_dec.') else 'encoder' if k.startswith('tok_enc.') else 'other'
for k in a if a[k][1] != b[k][1])
result = dict(q8=old,q4=new,changed_tensor_types_by_group=dict(changed),same_tensor_names_and_shapes=True)
Path(__file__).with_name('codec-headers.json').write_text(json.dumps(result,indent=2)+'\n')
print(json.dumps(result),flush=True)
@@ -0,0 +1,28 @@
"""Fetch only the pinned public codec into the isolated Athena experiment."""
import hashlib, json, os, shutil, urllib.request
from pathlib import Path
root = Path('/opt/athena-deck-dev/runtime/state/experiments/tts-codec-q4-20261022')
root.mkdir(parents=True, exist_ok=True, mode=0o700)
os.chown(root, 65534, 65534)
name = 'qwen-tokenizer-12hz-Q4_K_M.gguf'
revision = 'b7ee2e8c7459c3bea99da23e3d178125a7d1713c'
expected = 'cf3788b4d50aaa665fb6e57c170396aae03a3555fea52d2b5d0cda902d658039'
url = f'https://huggingface.co/Serveurperso/Qwen3-TTS-GGUF/resolve/{revision}/{name}'
path = root/name
if not path.exists():
part = path.with_suffix('.part')
with urllib.request.urlopen(url, timeout=120) as response, part.open('wb') as output:
shutil.copyfileobj(response, output, 1024*1024)
part.replace(path)
assert path.stat().st_size == 254974752
digest = hashlib.file_digest(path.open('rb'), 'sha256').hexdigest()
assert digest == expected, 'Public codec checksum mismatch'
path.chmod(0o600)
os.chown(path, 65534, 65534)
worker = root/'worker.py'
shutil.copyfile(Path(__file__).with_name('worker.py'), worker)
worker.chmod(0o600)
os.chown(worker, 65534, 65534)
print(json.dumps(dict(codec=name, size=path.stat().st_size, sha256=digest,
production_model_unchanged=True)), flush=True)
@@ -0,0 +1,134 @@
{
"arm": "q4-a",
"codec_quant": "Q4_K_M",
"generation_threads": 2,
"codec_threads": 2,
"native_runtime": "0.4.2",
"tts": {
"seconds": 23.01479159601149,
"first_pcm_seconds": 0.4439523710170761,
"audio_seconds": 17.76,
"bytes": 852480,
"rtf": 1.2958779051808271,
"packets": 114,
"longest_packet_gap_seconds": 0.5669041429937351,
"required_buffer_after_first_pcm_seconds": 4.962997545972467,
"native_profiles": [
{
"callback_count": 55,
"callback_copy_ms_total": 2.371923008468002,
"callback_queue_ms_total": 0.8105640299618244,
"before_thread_start_ms": 0.03279201337136328,
"producer_thread_start_ms": 0.07859800825826824,
"make_params_ms": 0.07115298649296165,
"before_lock_ms": 0.15349799650721252,
"lock_wait_ms": 0.0009409850463271141,
"native_enter_ms": 0.15513101243413985,
"after_thread_start_ms": 0.16672300989739597,
"first_callback_enter_ms": 443.1619410170242,
"first_callback_perf_counter_ns": 186476682743459,
"first_callback_n_samples": 1920,
"first_callback_audio_s": 0.08,
"first_callback_copy_ms": 0.0455650151707232,
"first_callback_queue_ms": 0.020799023332074285,
"first_callback_return_ms": 443.2401370140724,
"last_consumer_get_ms": 11021.490062994417,
"first_yield_perf_counter_ns": 186476682841573,
"first_yield_ms": 443.25910301995464,
"first_callback_to_yield_ms": 0.09716200293041766,
"native_synthesize_ms": 11021.287663985277,
"native_return_ms": 11021.445218997542,
"producer_done_ms": 11021.456640999531,
"consumer_done_ms": 11021.490775019629,
"producer_alive_after_close": false,
"stream_closed_ms": 11021.499941998627
},
{
"callback_count": 30,
"callback_copy_ms_total": 1.3264619337860495,
"callback_queue_ms_total": 0.44399211765266955,
"before_thread_start_ms": 0.02134000533260405,
"producer_thread_start_ms": 0.07669298793189228,
"make_params_ms": 0.08160300785675645,
"before_lock_ms": 0.16392700490541756,
"lock_wait_ms": 0.001333013642579317,
"native_enter_ms": 0.16640100511722267,
"after_thread_start_ms": 0.18678000196814537,
"first_callback_enter_ms": 458.6531980021391,
"first_callback_perf_counter_ns": 186487719765927,
"first_callback_n_samples": 1920,
"first_callback_audio_s": 0.08,
"first_callback_copy_ms": 0.04844000795856118,
"first_callback_queue_ms": 0.014506978914141655,
"first_callback_return_ms": 458.72271800180897,
"last_consumer_get_ms": 6318.771096994169,
"first_yield_perf_counter_ns": 186487719854332,
"first_yield_ms": 458.740892005153,
"first_callback_to_yield_ms": 0.08769400301389396,
"native_synthesize_ms": 6318.51804300095,
"native_return_ms": 6318.685726990225,
"producer_done_ms": 6318.693991983309,
"consumer_done_ms": 6318.771507998463,
"producer_alive_after_close": false,
"stream_closed_ms": 6318.776957981754
},
{
"callback_count": 29,
"callback_copy_ms_total": 1.2652520381379873,
"callback_queue_ms_total": 0.46739494428038597,
"before_thread_start_ms": 0.021561019821092486,
"producer_thread_start_ms": 0.07342800381593406,
"make_params_ms": 0.09418599074706435,
"before_lock_ms": 0.1710210053715855,
"lock_wait_ms": 0.0006110058166086674,
"native_enter_ms": 0.17204301548190415,
"after_thread_start_ms": 0.18274300964549184,
"first_callback_enter_ms": 566.7243460193276,
"first_callback_perf_counter_ns": 186494146646072,
"first_callback_n_samples": 1920,
"first_callback_audio_s": 0.08,
"first_callback_copy_ms": 0.03603799268603325,
"first_callback_queue_ms": 0.013125012628734112,
"first_callback_return_ms": 566.7792290041689,
"last_consumer_get_ms": 5673.754614021163,
"first_yield_perf_counter_ns": 186494146716915,
"first_yield_ms": 566.7945980094373,
"first_callback_to_yield_ms": 0.07025199010968208,
"native_synthesize_ms": 5673.535323003307,
"native_return_ms": 5673.70900901733,
"producer_done_ms": 5673.716453020461,
"consumer_done_ms": 5673.75506501412,
"producer_alive_after_close": false,
"stream_closed_ms": 5673.760525009129
}
],
"rss_kib": 3240400
},
"llm_rounds": [
{
"seconds": 5.435277824988589,
"completion_tokens": 512
},
{
"seconds": 5.6174904969811905,
"completion_tokens": 512
},
{
"seconds": 5.442486700980226,
"completion_tokens": 512
},
{
"seconds": 5.398165796010289,
"completion_tokens": 512
},
{
"seconds": 5.2087095890019555,
"completion_tokens": 512
}
],
"llm_coverage": 0.8887508799577248,
"health": {},
"production_workers_unchanged": true,
"cpu_policy_unchanged": true,
"memory_events_unchanged": true
}
@@ -0,0 +1,134 @@
{
"arm": "q4-b",
"codec_quant": "Q4_K_M",
"generation_threads": 2,
"codec_threads": 2,
"native_runtime": "0.4.2",
"tts": {
"seconds": 23.36240813002223,
"first_pcm_seconds": 0.5400156310060993,
"audio_seconds": 17.76,
"bytes": 852480,
"rtf": 1.3154509082219723,
"packets": 114,
"longest_packet_gap_seconds": 0.4687346539867576,
"required_buffer_after_first_pcm_seconds": 5.207059488999658,
"native_profiles": [
{
"callback_count": 55,
"callback_copy_ms_total": 2.339158992981538,
"callback_queue_ms_total": 0.8225820783991367,
"before_thread_start_ms": 0.03813198418356478,
"producer_thread_start_ms": 0.08259498281404376,
"make_params_ms": 0.07784500485286117,
"before_lock_ms": 0.16427799710072577,
"lock_wait_ms": 0.0009719806257635355,
"native_enter_ms": 0.1660209964029491,
"after_thread_start_ms": 0.17647098866291344,
"first_callback_enter_ms": 539.1116279934067,
"first_callback_perf_counter_ns": 186524832478870,
"first_callback_n_samples": 1920,
"first_callback_audio_s": 0.08,
"first_callback_copy_ms": 0.04027600516565144,
"first_callback_queue_ms": 0.015128985978662968,
"first_callback_return_ms": 539.1777920012828,
"last_consumer_get_ms": 11040.493331005564,
"first_yield_perf_counter_ns": 186524832566724,
"first_yield_ms": 539.1994429810438,
"first_callback_to_yield_ms": 0.0878149876371026,
"native_synthesize_ms": 11040.257779008243,
"native_return_ms": 11040.426725987345,
"producer_done_ms": 11040.441122982884,
"consumer_done_ms": 11040.494101995137,
"producer_alive_after_close": false,
"stream_closed_ms": 11040.506825986085
},
{
"callback_count": 30,
"callback_copy_ms_total": 1.4556099486071616,
"callback_queue_ms_total": 0.4840799665544182,
"before_thread_start_ms": 0.03315199865028262,
"producer_thread_start_ms": 0.11141897994093597,
"make_params_ms": 0.08241398609243333,
"before_lock_ms": 0.19807100761681795,
"lock_wait_ms": 0.0008610077202320099,
"native_enter_ms": 0.19956400501541793,
"after_thread_start_ms": 0.20982298883609474,
"first_callback_enter_ms": 468.4066489862744,
"first_callback_perf_counter_ns": 186535802331361,
"first_callback_n_samples": 1920,
"first_callback_audio_s": 0.08,
"first_callback_copy_ms": 0.04964301479049027,
"first_callback_queue_ms": 0.015197991160675883,
"first_callback_return_ms": 468.4782229887787,
"last_consumer_get_ms": 5948.3069269917905,
"first_yield_perf_counter_ns": 186535802422863,
"first_yield_ms": 468.49778000614606,
"first_callback_to_yield_ms": 0.09113101987168193,
"native_synthesize_ms": 5948.049584985711,
"native_return_ms": 5948.2505019987,
"producer_done_ms": 5948.258375981823,
"consumer_done_ms": 5948.307507991558,
"producer_alive_after_close": false,
"stream_closed_ms": 5948.313169006724
},
{
"callback_count": 29,
"callback_copy_ms_total": 1.28898597904481,
"callback_queue_ms_total": 0.463658943772316,
"before_thread_start_ms": 0.025267014279961586,
"producer_thread_start_ms": 0.07991900201886892,
"make_params_ms": 0.0769440084695816,
"before_lock_ms": 0.15942801837809384,
"lock_wait_ms": 0.0004410103429108858,
"native_enter_ms": 0.16036999295465648,
"after_thread_start_ms": 0.16919701010920107,
"first_callback_enter_ms": 428.6469370126724,
"first_callback_perf_counter_ns": 186541710915336,
"first_callback_n_samples": 1920,
"first_callback_audio_s": 0.08,
"first_callback_copy_ms": 0.03818201366811991,
"first_callback_queue_ms": 0.014196994015946984,
"first_callback_return_ms": 428.706228005467,
"last_consumer_get_ms": 6372.683791996678,
"first_yield_perf_counter_ns": 186541710993452,
"first_yield_ms": 428.72485300176777,
"first_callback_to_yield_ms": 0.07791598909534514,
"native_synthesize_ms": 6372.470211994369,
"native_return_ms": 6372.632365993923,
"producer_done_ms": 6372.639709006762,
"consumer_done_ms": 6372.68426301307,
"producer_alive_after_close": false,
"stream_closed_ms": 6372.691376018338
}
],
"rss_kib": 3240548
},
"llm_rounds": [
{
"seconds": 5.418540592014324,
"completion_tokens": 512
},
{
"seconds": 5.442677724990062,
"completion_tokens": 512
},
{
"seconds": 5.581628473999444,
"completion_tokens": 512
},
{
"seconds": 5.632642907992704,
"completion_tokens": 512
},
{
"seconds": 5.850693145010155,
"completion_tokens": 512
}
],
"llm_coverage": 0.8930389659277974,
"health": {},
"production_workers_unchanged": true,
"cpu_policy_unchanged": true,
"memory_events_unchanged": true
}
@@ -0,0 +1,130 @@
{
"arm": "q8-a",
"codec_quant": "Q8_0",
"generation_threads": 2,
"codec_threads": 2,
"native_runtime": "0.4.2",
"tts": {
"seconds": 22.65009748301236,
"first_pcm_seconds": 0.3922908730164636,
"audio_seconds": 17.76,
"bytes": 852480,
"rtf": 1.2753433267461913,
"packets": 114,
"longest_packet_gap_seconds": 0.46432272501988336,
"required_buffer_after_first_pcm_seconds": 4.607523116010707,
"native_profiles": [
{
"callback_count": 55,
"callback_copy_ms_total": 2.504239178961143,
"callback_queue_ms_total": 0.876700971275568,
"before_thread_start_ms": 0.03243100945837796,
"producer_thread_start_ms": 0.08333599544130266,
"make_params_ms": 0.0918220030143857,
"before_lock_ms": 0.179466005647555,
"lock_wait_ms": 0.0008810020517557859,
"native_enter_ms": 0.1811689871829003,
"after_thread_start_ms": 0.19074699957855046,
"first_callback_enter_ms": 391.39191998401657,
"first_callback_perf_counter_ns": 186424447916369,
"first_callback_n_samples": 1920,
"first_callback_audio_s": 0.08,
"first_callback_copy_ms": 0.054742995416745543,
"first_callback_queue_ms": 0.032100011594593525,
"first_callback_return_ms": 391.48959299200214,
"last_consumer_get_ms": 10278.64787899307,
"first_yield_perf_counter_ns": 186424448045461,
"first_yield_ms": 391.52075099991634,
"first_callback_to_yield_ms": 0.1288310158997774,
"native_synthesize_ms": 10278.393061016686,
"native_return_ms": 10278.577146003954,
"producer_done_ms": 10278.588977991603,
"consumer_done_ms": 10278.648339008214,
"producer_alive_after_close": false,
"stream_closed_ms": 10278.658427996561
},
{
"callback_count": 30,
"callback_copy_ms_total": 1.3478659093379974,
"callback_queue_ms_total": 0.4591688921209425,
"before_thread_start_ms": 0.02670002868399024,
"producer_thread_start_ms": 0.09460700675845146,
"make_params_ms": 0.04982299287803471,
"before_lock_ms": 0.1468250120524317,
"lock_wait_ms": 0.00033000833354890347,
"native_enter_ms": 0.14747600653208792,
"after_thread_start_ms": 0.15513101243413985,
"first_callback_enter_ms": 455.0847110222094,
"first_callback_perf_counter_ns": 186434790299598,
"first_callback_n_samples": 1920,
"first_callback_audio_s": 0.08,
"first_callback_copy_ms": 0.04577598883770406,
"first_callback_queue_ms": 0.014186982298269868,
"first_callback_return_ms": 455.1516360079404,
"last_consumer_get_ms": 6278.096371010179,
"first_yield_perf_counter_ns": 186434790382554,
"first_yield_ms": 455.16714500263333,
"first_callback_to_yield_ms": 0.08243398042395711,
"native_synthesize_ms": 6277.895073988475,
"native_return_ms": 6278.0440830101725,
"producer_done_ms": 6278.0513770121615,
"consumer_done_ms": 6278.096922003897,
"producer_alive_after_close": false,
"stream_closed_ms": 6278.103264019592
},
{
"callback_count": 29,
"callback_copy_ms_total": 1.2094160192646086,
"callback_queue_ms_total": 0.40766590973362327,
"before_thread_start_ms": 0.026720023015514016,
"producer_thread_start_ms": 0.07818601443432271,
"make_params_ms": 0.07713399827480316,
"before_lock_ms": 0.15766502474434674,
"lock_wait_ms": 0.0005309993866831064,
"native_enter_ms": 0.15860699932090938,
"after_thread_start_ms": 0.16748299822211266,
"first_callback_enter_ms": 464.0852900047321,
"first_callback_perf_counter_ns": 186441077439409,
"first_callback_n_samples": 1920,
"first_callback_audio_s": 0.08,
"first_callback_copy_ms": 0.036779005313292146,
"first_callback_queue_ms": 0.014487013686448336,
"first_callback_return_ms": 464.14316800655797,
"last_consumer_get_ms": 6092.494534997968,
"first_yield_perf_counter_ns": 186441077515712,
"first_yield_ms": 464.1609620011877,
"first_callback_to_yield_ms": 0.0756719964556396,
"native_synthesize_ms": 6092.286947008688,
"native_return_ms": 6092.447657021694,
"producer_done_ms": 6092.455211997731,
"consumer_done_ms": 6092.495367018273,
"producer_alive_after_close": false,
"stream_closed_ms": 6092.5021700095385
}
],
"rss_kib": 3311380
},
"llm_rounds": [
{
"seconds": 7.3819276909925975,
"completion_tokens": 512
},
{
"seconds": 5.416965029988205,
"completion_tokens": 512
},
{
"seconds": 5.640097852010513,
"completion_tokens": 512
},
{
"seconds": 5.566190547979204,
"completion_tokens": 512
}
],
"llm_coverage": 0.9145694832683093,
"health": {},
"production_workers_unchanged": true,
"cpu_policy_unchanged": true,
"memory_events_unchanged": true
}
@@ -0,0 +1,134 @@
{
"arm": "q8-b",
"codec_quant": "Q8_0",
"generation_threads": 2,
"codec_threads": 2,
"native_runtime": "0.4.2",
"tts": {
"seconds": 22.38855650500045,
"first_pcm_seconds": 0.38568678600131534,
"audio_seconds": 17.76,
"bytes": 852480,
"rtf": 1.260616920326602,
"packets": 114,
"longest_packet_gap_seconds": 0.4845587349846028,
"required_buffer_after_first_pcm_seconds": 4.394048310020008,
"native_profiles": [
{
"callback_count": 55,
"callback_copy_ms_total": 2.4174069985747337,
"callback_queue_ms_total": 0.7916030299384147,
"before_thread_start_ms": 0.03603700315579772,
"producer_thread_start_ms": 0.08380698272958398,
"make_params_ms": 0.08749400149099529,
"before_lock_ms": 0.17521798145025969,
"lock_wait_ms": 0.0013519893400371075,
"native_enter_ms": 0.17733199638314545,
"after_thread_start_ms": 0.18779200036078691,
"first_callback_enter_ms": 384.78989599389024,
"first_callback_perf_counter_ns": 186595409768917,
"first_callback_n_samples": 1920,
"first_callback_audio_s": 0.08,
"first_callback_copy_ms": 0.036788987927138805,
"first_callback_queue_ms": 0.013144017430022359,
"first_callback_return_ms": 384.8470829834696,
"last_consumer_get_ms": 10700.273139984347,
"first_yield_perf_counter_ns": 186595409844899,
"first_yield_ms": 384.8656269838102,
"first_callback_to_yield_ms": 0.0757309899199754,
"native_synthesize_ms": 10700.018552975962,
"native_return_ms": 10700.197868980467,
"producer_done_ms": 10700.207827001577,
"consumer_done_ms": 10700.273750990164,
"producer_alive_after_close": false,
"stream_closed_ms": 10700.283318990842
},
{
"callback_count": 30,
"callback_copy_ms_total": 1.279755961149931,
"callback_queue_ms_total": 0.4066608671564609,
"before_thread_start_ms": 0.020678999135270715,
"producer_thread_start_ms": 0.07835699943825603,
"make_params_ms": 0.055724987760186195,
"before_lock_ms": 0.1374970015604049,
"lock_wait_ms": 0.0005610054358839989,
"native_enter_ms": 0.13853900600224733,
"after_thread_start_ms": 0.14811701839789748,
"first_callback_enter_ms": 484.2843300139066,
"first_callback_perf_counter_ns": 186606209575585,
"first_callback_n_samples": 1920,
"first_callback_audio_s": 0.08,
"first_callback_copy_ms": 0.05384100950323045,
"first_callback_queue_ms": 0.01563900150358677,
"first_callback_return_ms": 484.3597820145078,
"last_consumer_get_ms": 6025.665466004284,
"first_yield_perf_counter_ns": 186606209670373,
"first_yield_ms": 484.37853701761924,
"first_callback_to_yield_ms": 0.09420700371265411,
"native_synthesize_ms": 6025.418303004699,
"native_return_ms": 6025.558505993104,
"producer_done_ms": 6025.56756301783,
"consumer_done_ms": 6025.6660070153885,
"producer_alive_after_close": false,
"stream_closed_ms": 6025.672449002741
},
{
"callback_count": 29,
"callback_copy_ms_total": 1.1563950683921576,
"callback_queue_ms_total": 0.3838068514596671,
"before_thread_start_ms": 0.023042986867949367,
"producer_thread_start_ms": 0.07898799958638847,
"make_params_ms": 0.07917900802567601,
"before_lock_ms": 0.16134200268425047,
"lock_wait_ms": 0.0006110058166086674,
"native_enter_ms": 0.16245400183834136,
"after_thread_start_ms": 0.16986799892038107,
"first_callback_enter_ms": 465.0208140083123,
"first_callback_perf_counter_ns": 186612216013632,
"first_callback_n_samples": 1920,
"first_callback_audio_s": 0.08,
"first_callback_copy_ms": 0.04193797940388322,
"first_callback_queue_ms": 0.015978992450982332,
"first_callback_return_ms": 465.08691800408997,
"last_consumer_get_ms": 5661.710899992613,
"first_yield_perf_counter_ns": 186612216098371,
"first_yield_ms": 465.1050019892864,
"first_callback_to_yield_ms": 0.08418798097409308,
"native_synthesize_ms": 5661.482933006482,
"native_return_ms": 5661.647641012678,
"producer_done_ms": 5661.655525997048,
"consumer_done_ms": 5661.711580993142,
"producer_alive_after_close": false,
"stream_closed_ms": 5661.718554008985
}
],
"rss_kib": 3311216
},
"llm_rounds": [
{
"seconds": 5.6231131730019115,
"completion_tokens": 512
},
{
"seconds": 5.7630515019991435,
"completion_tokens": 512
},
{
"seconds": 5.485023336979793,
"completion_tokens": 512
},
{
"seconds": 5.337694576010108,
"completion_tokens": 512
},
{
"seconds": 5.172850881004706,
"completion_tokens": 512
}
],
"llm_coverage": 0.8860314044626315,
"health": {},
"production_workers_unchanged": true,
"cpu_policy_unchanged": true,
"memory_events_unchanged": true
}
@@ -0,0 +1,111 @@
"""Isolated native A/B worker; reuses Anna in memory, never copies her reference."""
import json, os, resource, sys, threading, time, wave
from pathlib import Path
from contextlib import closing
protocol = os.fdopen(os.dup(1), 'w', buffering=1)
os.dup2(2, 1)
def emit(value):
protocol.write(json.dumps(value)+'\n')
protocol.flush()
def failure(kind, value, trace):
locations = []
while trace is not None:
locations.append(Path(trace.tb_frame.f_code.co_filename).name+':'+str(trace.tb_lineno))
trace = trace.tb_next
emit(dict(event='error', error_type=kind.__name__, locations=locations))
sys.excepthook = failure
config = json.loads(sys.stdin.readline())
os.sched_setaffinity(0, config['cpus'])
os.nice(10)
resource.setrlimit(resource.RLIMIT_AS, (8*1024**3, 8*1024**3))
os.environ.update(CUDA_VISIBLE_DEVICES='', HF_HUB_OFFLINE='1',
HF_HUB_DISABLE_IMPLICIT_TOKEN='1', OMP_NUM_THREADS='2',
OPENBLAS_NUM_THREADS='1', QWENTTS_CPU_FLASH_ATTN='0')
sys.path.insert(0, '/app')
import numpy as np
import qwentts_cpp_cpu as q
from tts_worker import spoken_chunks
assert q.CPU_ONLY is True and q.QT_ABI_VERSION == 5
start = time.monotonic()
model = q.QwenTTS(config['model'], config['codec'], cpu_threads=2,
cpu_codec_threads=2, cpu_stream_frames=2,
clamp_fp16=False, use_fa=True)
with wave.open(config['voice'], 'rb') as reference:
assert reference.getframerate() == 24000
assert reference.getnchannels() == 1 and reference.getsampwidth() == 2
samples = np.frombuffer(reference.readframes(min(reference.getnframes(), 24000*120)),
dtype='<i2').astype(np.float32)/32768
voice = model.extract_voice_ref(samples).ref_spk_emb
del samples
emit(dict(event='ready', pid=os.getpid(), load_seconds=time.monotonic()-start,
cpus=sorted(os.sched_getaffinity(0))))
try:
for line in sys.stdin:
request = json.loads(line)
if request['action'] == 'exit':
break
label = request['label']
assert label in ('warmup', 'q8-a', 'q8-b', 'q4-a', 'q4-b')
cancel = threading.Event()
watchdog = threading.Timer(60, cancel.set)
watchdog.daemon = True
started = time.monotonic()
watchdog.start()
first = latest = None
total = count = 0
maxgap = deficit = 0.0
pcm = []
profiles = []
emit(dict(event='started', at=started))
try:
for text in spoken_chunks(dict(text=request['text'], language='German')):
with closing(model.stream(text=text, lang='german', ref_spk_emb=voice,
seed=42, do_sample=False, max_new_tokens=1024,
onset_silence_profile='off', cancel_event=cancel)) as stream:
for chunk, rate in stream:
if cancel.is_set():
raise TimeoutError('Synthetic synthesis exceeded 60seconds')
assert rate == 24000 and np.isfinite(chunk).all()
now = time.monotonic()
if first is None:
first = now
else:
maxgap = max(maxgap, now-latest)
deficit = max(deficit, now-first-total/48000)
block = np.rint(np.clip(chunk, -1, 1)*32767).astype('<i2').tobytes()
pcm.append(block)
total += len(block)
latest = now
count += 1
assert total < 32*1024**2
profile = model.last_stream_profile
assert not profile.get('producer_alive_after_close')
# Only scalar technical counters; no embeddings or reference data.
profiles.append({k:v for k,v in profile.items()
if type(v) in (int,float,bool) or v is None})
ended = time.monotonic()
assert total and first is not None
if label != 'warmup':
output = Path(__file__).with_name(label+'.wav')
with wave.open(str(output), 'wb') as audio:
audio.setnchannels(1)
audio.setsampwidth(2)
audio.setframerate(24000)
audio.writeframes(b''.join(pcm))
emit(dict(event='result', started=started, ended=ended,
seconds=ended-started, first_pcm_seconds=first-started,
audio_seconds=total/48000, bytes=total,
rtf=(ended-started)/(total/48000), packets=count,
longest_packet_gap_seconds=maxgap,
required_buffer_after_first_pcm_seconds=max(0,deficit),
native_profiles=profiles,
rss_kib=resource.getrusage(resource.RUSAGE_SELF).ru_maxrss))
finally:
watchdog.cancel()
finally:
model.close()