Prepare CPU Parakeet Redux and interchangeable STT endpoint
This commit is contained in:
1 parent
d28dce4476
commit
81cc316ebe
15 files changed
+349
-14
No files matched your search
@@ -0,0 +1,106 @@
|
||||
# Parakeet Redux — preparation on Athena, 2026-10-13
|
||||
|
||||
**Prepared only. No transcription test, app activation/restart, endpoint publication,
|
||||
service launch or change to running Qwen/Strata/audio policies.**
|
||||
|
||||
## Files and runtime
|
||||
|
||||
Public model: `mudler/parakeet-cpp-gguf/redux-packed.gguf`, revision
|
||||
`741158ae71e64ef5c89385862c18f777d07a97a1`,213319296 bytes,SHA256
|
||||
`574614b9a4d9f72ab202877a7ad6a1f4bf819dd1d27b9d42dfe8cd429fcebdd5`.
|
||||
This is the packed ternary Redux conversion, NOT the expanded f16 or q8 model.
|
||||
Original model credit: Moondream and NVIDIA, CC-BY-4.0.
|
||||
|
||||
Runtime: official CPU-x64 parakeet.cpp v0.6.1 (commit
|
||||
`5c9b0fbbd8e611d88e47d7e1ebae9bca9b447e8f`), archive SHA256
|
||||
`cce60d122ab72e1068cd0d164e54a21655a0b83f1b9c21befc20124f5a972c10`.
|
||||
Native binaries; no extra container, compiler, Python ML packages or CUDA runtime.
|
||||
`prepare.py` pins URLs and verifies both digests, rejects unsafe archive paths/links,
|
||||
extracts only into the dedicated runtime root. CLI/server help executed successfully
|
||||
on Athena (help returns2 by design); no model loaded or inference performed.
|
||||
|
||||
Paths:
|
||||
- `/opt/athena-deck-dev/runtime/state/parakeet-runtime/v0.6.1`: CPU binaries/model/manifest.
|
||||
- `/opt/athena-deck-dev/parakeet-prepared-20261013`: staged Deck source/build/activation script.
|
||||
- `/opt/athena-deck-dev/runtime/state/parakeet-comparison-prepared`: Go-guarded test script,
|
||||
two explicitly listed previously generated synthetic WAVs and expected text.
|
||||
- Prepared image `athena-deck-standalone:parakeet-prepared-20261013`; not running.
|
||||
|
||||
The runtime and weights are inside the existing managed state mount. Only the new
|
||||
parakeet-runtime root is writable by Deck UID65534, so future catalogue registration
|
||||
can store its marker; pinned version files are readable/executable. Other paths unchanged.
|
||||
|
||||
## Go test, independently of the app update
|
||||
|
||||
Run only after the user asks to start the test:
|
||||
|
||||
```sh
|
||||
docker exec athena-deck-dev python3 \
|
||||
/var/lib/deck/parakeet-comparison-prepared/compare.py --go \
|
||||
--cases /var/lib/deck/parakeet-comparison-prepared/cases/cases.json \
|
||||
--output /var/lib/deck/parakeet-comparison-prepared/results
|
||||
```
|
||||
|
||||
Uses existing installed Qwen3-ASR0.6B-Q8 model/projector/active llama-server,
|
||||
and the prepared packed Redux model. Each backend launches temporarily on a random
|
||||
loopback port with2CPU threads; GPU visibility disabled. Backends run sequentially,
|
||||
then their own process groups are stopped. Production workers/config remain untouched.
|
||||
Checks startup and transcribes each identical synthetic file twice. Records startup,
|
||||
processing/audio duration,RTF and simple case/punctuation-normalized WER, plus the
|
||||
synthetic transcripts in its own results file. No private inputs/logs or library scans.
|
||||
A live user's voice/noisy recordings are not part of this initial test; synthetic
|
||||
samples cannot establish real German accuracy or superiority. Testing temporarily
|
||||
uses additional CPU/RAM and can compete with production CPU work, even without restarts.
|
||||
|
||||
## Stable Deck endpoint, prepared implementation
|
||||
|
||||
After a separate activation in an idle maintenance window:
|
||||
|
||||
```sh
|
||||
python3 /opt/athena-deck-dev/parakeet-prepared-20261013/activate-prepared.py --activate
|
||||
```
|
||||
|
||||
Uses existing manifest/installer and preserves mounts, credentials, API ports,
|
||||
profiles and audio policy. It does restart the Deck app, so do not execute while
|
||||
user work runs. First startup registers a symlinked STT catalogue entry and the
|
||||
**Parakeet Redux CPU** profile once, without publishing it. Existing Qwen stays selected.
|
||||
|
||||
Later: publish exactly one STT profile in Deck. Enabling a different STT profile
|
||||
unchecks the former one; active STT jobs block switching. `/v1/audio/transcriptions`,
|
||||
API base URL and token stay identical. `athena-stt`, `deck-stt`, `whisper-1`, plus
|
||||
names/API IDs belonging to existing disabled STT profiles route to the sole published
|
||||
STT profile, retaining current client configuration. Unknown names still fail; no
|
||||
published profile fails; ambiguous older configs fail explicitly. Chat/other model
|
||||
routing is unchanged. Native Parakeet requests are serialized and loopback-only
|
||||
behind Deck authentication; Qwen and Redux use distinct model/backend residency keys.
|
||||
Warm STT follows the currently published profile instead of silently reloading the
|
||||
old Qwen policy target. Running jobs are never evicted by warm reconciliation.
|
||||
|
||||
No silent inference fallback from Redux to Qwen: report the real backend error.
|
||||
Parakeet server accepts WAV and returns JSON text, which matches Deck's existing
|
||||
normalization and response. Its verbose_json language is an `en` placeholder and
|
||||
its language hint is not a forced language selector; Deck exposes only the existing
|
||||
text result. Word timestamps/live previews are NOT part of this initial adapter.
|
||||
The same existing120-second upload and4-GiB admission limits are retained initially;
|
||||
preparation does not claim a measured RAM minimum or change unrelated limits.
|
||||
|
||||
## Verification / restore
|
||||
|
||||
35 targeted tests passed. They cover fixed revision, no false installed state, old client-name routing,
|
||||
unknown/ambiguous/disabled routes, and warm profile switching without active-job eviction.
|
||||
Existing STT/audio-policy/execution mapping tests run too. A broad historical endpoint
|
||||
suite has pre-existing chat-forwarding failures (one reproduced against unchanged HEAD);
|
||||
those are not ASR/model test results. No measured performance/accuracy claims yet.
|
||||
|
||||
Native restore: from Git run `prepare.py --root <state>/parakeet-runtime/v0.6.1`,
|
||||
ensure the server's native account can write `<state>/parakeet-runtime` and its catalogue,
|
||||
then use the packaged server/modules. `deploy/install.py` includes parakeet_runtime.py.
|
||||
Existing profile/catalogue/endpoint/audio-policy state is part of encrypted restore.
|
||||
Public weights/runtime are reproducible from pinned URLs/digests; no secrets, weights
|
||||
or private audio committed. Fresh-host restore has not been tested.
|
||||
|
||||
Official sources:
|
||||
- https://github.com/mudler/parakeet.cpp/releases/tag/v0.6.1
|
||||
- https://github.com/mudler/parakeet.cpp/blob/v0.6.1/examples/server/README.md
|
||||
- https://github.com/mudler/parakeet.cpp/blob/v0.6.1/docs/ultra-redux.md
|
||||
- https://huggingface.co/moondream/parakeet-redux
|
||||
@@ -0,0 +1,12 @@
|
||||
"""Activate only after an explicit separate --activate request in an idle window."""
|
||||
import argparse,importlib.util,json,pathlib,subprocess,urllib.request
|
||||
p=argparse.ArgumentParser();p.add_argument('--activate',action='store_true');a=p.parse_args()
|
||||
if not a.activate:raise SystemExit('Prepared only. No services changed.')
|
||||
root=pathlib.Path('/opt/athena-deck-dev/parakeet-prepared-20261013')
|
||||
item=json.loads(subprocess.check_output(['docker','inspect','athena-voxcpm2-web']))[0]
|
||||
f=next(pathlib.Path(m['Source']) for m in item['Mounts'] if m['Destination']=='/data');key=json.loads((f/'deck-connection.json').read_text())['token']
|
||||
d=json.load(urllib.request.urlopen(urllib.request.Request('http://127.0.0.1:8108/api/v1/status',headers={'Authorization':'Bearer '+key})))
|
||||
if d['endpoint']['active_requests']:raise SystemExit('Deck request active: no activation.')
|
||||
spec=importlib.util.spec_from_file_location('installer',root/'app/deploy/install.py');m=importlib.util.module_from_spec(spec);spec.loader.exec_module(m)
|
||||
m.build=lambda runtime_image=None:'athena-deck-standalone:parakeet-prepared-20261013'
|
||||
m.update(pathlib.Path('/opt/athena-deck-dev/runtime'),reuse_runtime=True,keep_snapshots=True)
|
||||
@@ -0,0 +1,56 @@
|
||||
"""Isolated CPU-only ASR comparison. Requires explicit --go. Never reads private chats."""
|
||||
import argparse,contextlib,io,json,os,pathlib,re,signal,socket,subprocess,time,urllib.request,wave
|
||||
p=argparse.ArgumentParser();p.add_argument('--go',action='store_true');p.add_argument('--state-root',default='/var/lib/deck');p.add_argument('--cases',required=True);p.add_argument('--output',required=True);a=p.parse_args()
|
||||
if not a.go:raise SystemExit('Prepared only. Add --go after user authorization.')
|
||||
root=pathlib.Path(a.state_root);out=pathlib.Path(a.output);out.mkdir(parents=True,exist_ok=True)
|
||||
cases=json.loads(pathlib.Path(a.cases).read_text());version='v0.6.1';pr=root/'parakeet-runtime'/version
|
||||
runtime=json.loads((root/'runtime/state.json').read_text());llama=root/'runtime'/runtime['active']/'build/bin/llama-server'
|
||||
entries=[]
|
||||
for path in (root/'models').glob('*/entry.json'):
|
||||
d=json.loads(path.read_text())
|
||||
if d.get('repo')=='ggml-org/Qwen3-ASR-0.6B-GGUF':entries.append((d['file'],path.parent/'model.gguf'))
|
||||
qmodel=next(path for name,path in entries if name=='Qwen3-ASR-0.6B-Q8_0.gguf');proj=next(path for name,path in entries if name=='mmproj-Qwen3-ASR-0.6B-Q8_0.gguf')
|
||||
def wer(reference,hypothesis):
|
||||
def words(s):return re.findall(r'\w+',s.casefold())
|
||||
r,h=words(reference),words(hypothesis);row=list(range(len(h)+1))
|
||||
for i,x in enumerate(r,1):
|
||||
nxt=[i]
|
||||
for j,y in enumerate(h,1):nxt.append(min(nxt[-1]+1,row[j]+1,row[j-1]+(x!=y)))
|
||||
row=nxt
|
||||
return row[-1]/max(1,len(r))
|
||||
def request(url,audio):
|
||||
boundary='athena-synthetic-comparison'
|
||||
body=(f'--{boundary}\r\nContent-Disposition: form-data; name="model"\r\n\r\ndeck-stt\r\n--{boundary}\r\nContent-Disposition: form-data; name="language"\r\n\r\nde\r\n--{boundary}\r\nContent-Disposition: form-data; name="file"; filename="synthetic.wav"\r\nContent-Type: audio/wav\r\n\r\n').encode()+audio+f'\r\n--{boundary}--\r\n'.encode()
|
||||
with urllib.request.urlopen(urllib.request.Request(url+'/v1/audio/transcriptions',data=body,headers={'Content-Type':'multipart/form-data; boundary='+boundary}),timeout=280) as resp:return json.load(resp)['text'].split('<asr_text>')[-1].replace('<|endoftext|>','').strip()
|
||||
results=[]
|
||||
for engine in ('qwen','redux'):
|
||||
with socket.socket() as s:s.bind(('127.0.0.1',0));port=s.getsockname()[1]
|
||||
args=([str(llama),'--model',str(qmodel),'--mmproj',str(proj),'--no-mmproj-offload','--n-gpu-layers','0','--ctx-size','4096','--threads','2','--parallel','1','--host','127.0.0.1','--port',str(port),'--no-ui','--fit','off','--alias','deck-stt'] if engine=='qwen' else [str(pr/'runtime'/('parakeet-'+version+'-bin-linux-cpu-x64')/'parakeet-server'),'--model',str(pr/'redux-packed.gguf'),'--host','127.0.0.1','--port',str(port),'--threads','2','--concurrency','1'])
|
||||
start=time.monotonic();proc=subprocess.Popen(args,env=dict(os.environ,CUDA_VISIBLE_DEVICES='',OMP_NUM_THREADS='2'),stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL,start_new_session=True)
|
||||
try:
|
||||
url=f'http://127.0.0.1:{port}'
|
||||
while True:
|
||||
if proc.poll() is not None:raise RuntimeError(engine+' startup failed')
|
||||
if time.monotonic()-start>120:raise RuntimeError(engine+' startup timeout')
|
||||
try:
|
||||
with urllib.request.urlopen(url+'/health',timeout=1) as resp:
|
||||
if resp.status==200:break
|
||||
except OSError:time.sleep(.2)
|
||||
load=time.monotonic()-start
|
||||
for case in cases:
|
||||
source=pathlib.Path(a.cases).parent/case['file']
|
||||
# Converts only the explicitly listed synthetic files; no library scans.
|
||||
pcm=subprocess.check_output(['ffmpeg','-nostdin','-v','error','-i',str(source),'-ac','1','-ar','16000','-f','s16le','pipe:1'],stderr=subprocess.DEVNULL)
|
||||
buffer=io.BytesIO()
|
||||
with wave.open(buffer,'wb') as w:w.setnchannels(1);w.setsampwidth(2);w.setframerate(16000);w.writeframes(pcm)
|
||||
audio=buffer.getvalue();duration=len(pcm)/32000
|
||||
for repetition in (1,2):
|
||||
t=time.monotonic();text=request(url,audio);elapsed=time.monotonic()-t
|
||||
row=dict(engine=engine,case=case['name'],repetition=repetition,startup_seconds=round(load,3),seconds=round(elapsed,3),audio_seconds=round(duration,3),rtf=round(elapsed/duration,4),wer=round(wer(case['expected'],text),4),text=text)
|
||||
results.append(row);(out/'results.json').write_text(json.dumps(results,indent=2));print(json.dumps({k:v for k,v in row.items() if k!='text'}),flush=True)
|
||||
finally:
|
||||
if proc.poll() is None:
|
||||
os.killpg(proc.pid,signal.SIGTERM)
|
||||
try:proc.wait(timeout=10)
|
||||
except subprocess.TimeoutExpired:os.killpg(proc.pid,signal.SIGKILL);proc.wait()
|
||||
(out/'complete').write_text('Synthetic comparison complete\n')
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"version": "v0.6.1",
|
||||
"model_repo": "mudler/parakeet-cpp-gguf",
|
||||
"model_revision": "741158ae71e64ef5c89385862c18f777d07a97a1",
|
||||
"files": [
|
||||
{
|
||||
"path": "runtime.tar.gz",
|
||||
"url": "https://github.com/mudler/parakeet.cpp/releases/download/v0.6.1/parakeet-v0.6.1-bin-linux-cpu-x64.tar.gz",
|
||||
"sha256": "cce60d122ab72e1068cd0d164e54a21655a0b83f1b9c21befc20124f5a972c10"
|
||||
},
|
||||
{
|
||||
"path": "redux-packed.gguf",
|
||||
"url": "https://huggingface.co/mudler/parakeet-cpp-gguf/resolve/741158ae71e64ef5c89385862c18f777d07a97a1/redux-packed.gguf",
|
||||
"sha256": "574614b9a4d9f72ab202877a7ad6a1f4bf819dd1d27b9d42dfe8cd429fcebdd5"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
"""Download pinned CPU runtime/model only. Never start an inference service."""
|
||||
import argparse,hashlib,json,os,pathlib,tarfile,urllib.request
|
||||
p=argparse.ArgumentParser();p.add_argument('--root',required=True);args=p.parse_args()
|
||||
root=pathlib.Path(args.root);root.mkdir(parents=True,exist_ok=True)
|
||||
files=[dict(path='runtime.tar.gz',url='https://github.com/mudler/parakeet.cpp/releases/download/v0.6.1/parakeet-v0.6.1-bin-linux-cpu-x64.tar.gz',sha256='cce60d122ab72e1068cd0d164e54a21655a0b83f1b9c21befc20124f5a972c10'),dict(path='redux-packed.gguf',url='https://huggingface.co/mudler/parakeet-cpp-gguf/resolve/741158ae71e64ef5c89385862c18f777d07a97a1/redux-packed.gguf',sha256='574614b9a4d9f72ab202877a7ad6a1f4bf819dd1d27b9d42dfe8cd429fcebdd5')]
|
||||
def digest(path):
|
||||
h=hashlib.sha256()
|
||||
with path.open('rb') as f:
|
||||
for block in iter(lambda:f.read(8*1024*1024),b''):h.update(block)
|
||||
return h.hexdigest()
|
||||
for row in files:
|
||||
target=root/row['path']
|
||||
if not target.exists():
|
||||
part=target.with_suffix(target.suffix+'.part')
|
||||
with urllib.request.urlopen(row['url'],timeout=120) as r,part.open('wb') as f:
|
||||
while True:
|
||||
block=r.read(8*1024*1024)
|
||||
if not block:break
|
||||
f.write(block)
|
||||
if digest(part)!=row['sha256']:raise RuntimeError('Download checksum mismatch')
|
||||
part.replace(target)
|
||||
if digest(target)!=row['sha256']:raise RuntimeError('Existing artifact checksum mismatch')
|
||||
print(json.dumps({'verified':row['path'],'bytes':target.stat().st_size}),flush=True)
|
||||
with tarfile.open(root/'runtime.tar.gz') as t:
|
||||
# Reject traversal, links and devices rather than trusting an archive layout.
|
||||
for member in t.getmembers():
|
||||
path=pathlib.PurePosixPath(member.name)
|
||||
if path.is_absolute() or '..' in path.parts or member.issym() or member.islnk() or member.isdev():raise RuntimeError('Unsafe archive member')
|
||||
t.extractall(root/'runtime',filter='data')
|
||||
for binary in (root/'runtime').rglob('parakeet-*'):
|
||||
if binary.is_file() and binary.name in ('parakeet-cli','parakeet-server'):binary.chmod(0o755)
|
||||
(root/'manifest.json').write_text(json.dumps({'version':'v0.6.1','model_repo':'mudler/parakeet-cpp-gguf','model_revision':'741158ae71e64ef5c89385862c18f777d07a97a1','files':files},indent=2))
|
||||
print(json.dumps({'prepared':True,'inference_started':False}))
|
||||
Reference in new issue
Block a user