Integrate Basalt telemetry and shared GPU speech runtimes
Publish the reviewed accumulated runtime, scheduler, profile, UI, native recipes and historical maintenance evidence. Includes Qwen GPU ASR correction and shared Anna/atelier ownership. Validated with 784 local tests, Python/JSON parsing and eight JavaScript syntax checks. Live GPU acceptance and full fresh-host restore limits remain documented.
This commit is contained in:
1 parent
4e404d077d
commit
c0bc5d3a1b
172 files changed
+52473
-147
No files matched your search
+29
-8
@@ -23,8 +23,9 @@ class Scheduler:
|
||||
"""FIFO admission; same-profile requests share configured slots, switches drain."""
|
||||
def __init__(self, worker):
|
||||
self.worker=worker;self.evict_voice=lambda:None;self.evict_tts=lambda:None;self.cv=threading.Condition();self.queue=[];self.tts_queue=[];self.key=None;self.active=0;self.tts_active=0;self.transition=False;self.gpu_mode="llm"
|
||||
self.stt_queue=[];self.stt_active=0;self.evict_stt=lambda:False
|
||||
def status(self):
|
||||
with self.cv:return dict(active_requests=self.active+self.tts_active,waiting_requests=len(self.queue)+len(self.tts_queue),tts_waiting_requests=len(self.tts_queue),switching=self.transition)
|
||||
with self.cv:return dict(active_requests=self.active+self.tts_active+self.stt_active,waiting_requests=len(self.queue)+len(self.tts_queue)+len(self.stt_queue),tts_waiting_requests=len(self.tts_queue),stt_waiting_requests=len(self.stt_queue),switching=self.transition)
|
||||
@contextlib.contextmanager
|
||||
def lease(self, key, slots=1, prepare=None, timeout=600, allowed=lambda:True, modes=("llm",)):
|
||||
ticket=object();deadline=time.monotonic()+timeout;claimed=False
|
||||
@@ -35,7 +36,7 @@ class Scheduler:
|
||||
while True:
|
||||
if self.gpu_mode not in modes:raise InferenceError("Andere Betriebsart aktiv oder Moduswechsel läuft; GPU-Auftrag ist gesperrt.")
|
||||
if not allowed():raise InferenceError('Endpunkt wird gestoppt oder Profil ist nicht mehr aktiviert.')
|
||||
if self.queue[0] is ticket and not self.transition and (not self.active or (self.key==key and self.active<slots)) and (not self.tts_active or self.key==key and key!=('image',)):
|
||||
if self.queue[0] is ticket and not self.transition and (not self.active or (self.key==key and self.active<slots)) and (not self.tts_active or self.key==key and key!=('image',)) and (not self.stt_active or self.key==key and key[0]=='chat'):
|
||||
self.queue.pop(0);self.active+=1;claimed=True
|
||||
switch=self.key!=key;self.key=key
|
||||
# Also verifies/restarts a crashed worker when there are no other leases.
|
||||
@@ -51,7 +52,7 @@ class Scheduler:
|
||||
try:
|
||||
if switch:self.worker.stop()
|
||||
if switch and key!=('voice',):self.evict_voice()
|
||||
if key[0]!='chat':self.evict_tts()
|
||||
if key[0]!='chat':self.evict_tts();self.evict_stt()
|
||||
if prepare:
|
||||
try:prepare()
|
||||
except MemoryAdmissionError:
|
||||
@@ -59,7 +60,9 @@ class Scheduler:
|
||||
# estimate fail although both workers fit after LLM loading.
|
||||
# Drain speech first, release only our TTS, then run the same
|
||||
# admission check again. AudioPolicy reloads it if free VRAM fits.
|
||||
if key[0]!='chat' or self.tts_active or not self.evict_tts():raise
|
||||
if key[0]!='chat' or self.tts_active or self.stt_active:raise
|
||||
released_tts=self.evict_tts();released_stt=self.evict_stt()
|
||||
if not released_tts and not released_stt:raise
|
||||
prepare()
|
||||
except Exception:
|
||||
self.worker.stop()
|
||||
@@ -75,15 +78,16 @@ class Scheduler:
|
||||
lease=self.lease((kind,),timeout=600 if wait else 0,allowed=allowed,modes=("music",) if kind=="music" else ("llm","separator") if kind=="separator" else ("llm","voice") if kind=="voice" else ("llm",))
|
||||
lease.__enter__()
|
||||
return lambda:lease.__exit__(None,None,None)
|
||||
def tts_reservation(self,wait=False):
|
||||
def tts_reservation(self,wait=False,allowed=lambda:True):
|
||||
deadline=time.monotonic()+(600 if wait else 0)
|
||||
ticket=object()
|
||||
with self.cv:
|
||||
self.tts_queue.append(ticket)
|
||||
try:
|
||||
while True:
|
||||
if not allowed():raise InferenceError('Sprachauftrag wurde abgebrochen.')
|
||||
if self.gpu_mode!='llm':raise InferenceError('Andere Betriebsart aktiv; Sprachausgabe ist derzeit nicht verfügbar.')
|
||||
if self.tts_queue[0] is ticket and not self.tts_active and not self.transition and not (self.key==('image',) and self.active) and not self.queue:
|
||||
if self.tts_queue[0] is ticket and not self.tts_active and not self.stt_active and not self.transition and (not self.active or self.key and self.key[0]=='chat') and not self.queue:
|
||||
self.tts_active=1;break
|
||||
if time.monotonic()>=deadline:raise InferenceError('Sprachausgabe wartet auf belegte Ressourcen. Bitte erneut versuchen.')
|
||||
self.cv.wait(min(1,max(.01,deadline-time.monotonic())))
|
||||
@@ -92,11 +96,28 @@ class Scheduler:
|
||||
def release():
|
||||
with self.cv:self.tts_active-=1;self.cv.notify_all()
|
||||
return release
|
||||
def stt_reservation(self,wait=False,allowed=lambda:True):
|
||||
deadline=time.monotonic()+(600 if wait else 0);ticket=object()
|
||||
with self.cv:
|
||||
if len(self.stt_queue)>=16:raise InferenceError('STT-Warteschlange voll.')
|
||||
self.stt_queue.append(ticket)
|
||||
try:
|
||||
while True:
|
||||
if self.gpu_mode!='llm':raise InferenceError('Andere Betriebsart aktiv; GPU-Spracherkennung ist gesperrt.')
|
||||
if not allowed():raise InferenceError('GPU-Spracherkennung wurde abgebrochen.')
|
||||
if self.stt_queue[0] is ticket and not self.stt_active and not self.tts_active and not self.transition and not self.queue and not self.tts_queue and (not self.active or self.key and self.key[0]=='chat'):
|
||||
self.stt_active=1;break
|
||||
if time.monotonic()>=deadline:raise InferenceError('GPU-Spracherkennung wartet auf belegte Ressourcen.')
|
||||
self.cv.wait(min(1,max(.01,deadline-time.monotonic())))
|
||||
finally:self.stt_queue.remove(ticket);self.cv.notify_all()
|
||||
def release():
|
||||
with self.cv:self.stt_active-=1;self.cv.notify_all()
|
||||
return release
|
||||
def unload_idle(self):
|
||||
with self.cv:
|
||||
if self.active or self.tts_active:return False
|
||||
if self.active or self.tts_active or self.stt_active or self.queue or self.tts_queue or self.stt_queue:return False
|
||||
self.transition=True
|
||||
try:self.worker.stop();self.evict_tts();self.evict_voice();self.key=None
|
||||
try:self.worker.stop();self.evict_tts();self.evict_stt();self.evict_voice();self.key=None
|
||||
finally:self.transition=False;self.cv.notify_all()
|
||||
return True
|
||||
|
||||
|
||||
Reference in new issue
Block a user