gpt comments
This commit is contained in:
parent
64ad19f3d8
commit
c3bb09cc50
3 changed files with 21 additions and 8 deletions
|
|
@ -311,10 +311,16 @@ class AudioCodecManager:
|
|||
) -> Tuple[bytes, int]:
|
||||
"""Unified decode — dispatches to the right codec decoder."""
|
||||
if audio_type == "snac":
|
||||
if not token_ids:
|
||||
raise ValueError("SNAC decoding requires token_ids")
|
||||
return self.decode_snac(torch.tensor([token_ids], dtype = torch.long), device)
|
||||
elif audio_type == "bicodec":
|
||||
if not text:
|
||||
raise ValueError("BiCodec decoding requires text")
|
||||
return self.decode_bicodec(text, device)
|
||||
elif audio_type == "dac":
|
||||
if not text:
|
||||
raise ValueError("DAC decoding requires text")
|
||||
return self.decode_dac(text, device)
|
||||
raise ValueError(f"Cannot decode audio_type: {audio_type}")
|
||||
|
||||
|
|
|
|||
|
|
@ -732,8 +732,17 @@ class LlamaCppBackend:
|
|||
self._hf_repo = None
|
||||
self._hf_variant = None
|
||||
self._is_vision = False
|
||||
self._is_audio = False
|
||||
self._audio_type = None
|
||||
self._port = None
|
||||
self._healthy = False
|
||||
# Free audio codec GPU memory
|
||||
if LlamaCppBackend._codec_mgr is not None:
|
||||
LlamaCppBackend._codec_mgr.unload()
|
||||
LlamaCppBackend._codec_mgr = None
|
||||
import torch
|
||||
if torch.cuda.is_available():
|
||||
torch.cuda.empty_cache()
|
||||
return True
|
||||
|
||||
def _kill_process(self):
|
||||
|
|
@ -1079,6 +1088,7 @@ class LlamaCppBackend:
|
|||
temperature: float = 0.6,
|
||||
top_p: float = 0.95,
|
||||
top_k: int = 50,
|
||||
min_p: float = 0.0,
|
||||
max_new_tokens: int = 2048,
|
||||
repetition_penalty: float = 1.1,
|
||||
) -> tuple:
|
||||
|
|
@ -1098,6 +1108,7 @@ class LlamaCppBackend:
|
|||
"temperature": temperature,
|
||||
"top_p": top_p,
|
||||
"top_k": top_k if top_k >= 0 else 0,
|
||||
"min_p": min_p,
|
||||
"repeat_penalty": repetition_penalty,
|
||||
}
|
||||
if stop:
|
||||
|
|
|
|||
|
|
@ -159,9 +159,7 @@ async def load_model(
|
|||
from utils.models import is_audio_input_type
|
||||
|
||||
_gguf_audio = llama_backend.detect_audio_type()
|
||||
_gguf_is_audio = _gguf_audio is not None and _gguf_audio not in (
|
||||
"audio_vlm",
|
||||
)
|
||||
_gguf_is_audio = _gguf_audio in ("snac", "bicodec", "dac")
|
||||
llama_backend._is_audio = _gguf_is_audio
|
||||
llama_backend._audio_type = _gguf_audio
|
||||
if _gguf_is_audio:
|
||||
|
|
@ -547,11 +545,9 @@ async def generate_audio(
|
|||
if llama_backend.is_loaded and getattr(llama_backend, "_is_audio", False):
|
||||
model_name = llama_backend.model_identifier
|
||||
gen = lambda: llama_backend.generate_audio_response(
|
||||
text = text,
|
||||
audio_type = llama_backend._audio_type,
|
||||
temperature = payload.temperature,
|
||||
top_p = payload.top_p,
|
||||
top_k = payload.top_k,
|
||||
text = text, audio_type = llama_backend._audio_type,
|
||||
temperature = payload.temperature, top_p = payload.top_p,
|
||||
top_k = payload.top_k, min_p = payload.min_p,
|
||||
max_new_tokens = payload.max_tokens or 2048,
|
||||
repetition_penalty = payload.repetition_penalty,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue