Hardware-aware install, per-step LLM profiles, tuned llama.cpp for 4 GB VRAM
Benchmarked on RTX 500 Ada 4 GB (~3.2 GB usable on Windows) + Core Ultra 7 155H.
- install.js: log GPU/VRAM/RAM, abort without NVIDIA >= 4 GB VRAM; always
install Qwen3.5-4B Q4_K_S, Qwen3.6-35B-A3B only with >= 48 GB RAM.
- llama.py: model registry with vision (shots) and text (report/ask)
profiles; KV q8, image tokens 1024-1536.
- 35B: vision encoder on GPU, -ngl 30 (shot 142 -> ~50 s); text: -ub 2048.
- 4B: vision encoder on GPU, FFN of layers 19-31 in RAM (shot 36 -> 22 s);
text fully on GPU (~30 tok/s, report 4.5 min).
- Per-step choice in out/llm.txt: default 4B for shots, biggest for report.
- flow.py: restart llama in text profile after shots (no mmproj for report).
- shots.py: prompt v3 (inline template + defined fields, Italian summary
rules) and bounded json_schema; stops 4B loops, title 1/38 -> 36/38.
- server.py: shots/report model selects, POST /cancel + stop button, reaper
thread that honours Prefect "Cancel" and closes runs whose process died.
- diarize.py: cut same-speaker paragraphs every 60 s (one 11-min paragraph
truncated every report at 28:52); 8 threads; CUDA provider with CPU
fallback via sherpa-onnx cuda12.cudnn9 wheel (CUDA path not yet verified).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
4ff3e6fe14
commit
a64d3fb275
+14
-8
@@ -1,12 +1,16 @@
|
||||
# /// script
|
||||
# requires-python = ">=3.10,<3.13"
|
||||
# dependencies = ["prefect>=3", "faster-whisper", "av>=14,<17", "nvidia-cublas-cu12", "nvidia-cudnn-cu12==9.*", "sherpa-onnx", "numpy", "imagehash", "Pillow", "markdown", "openvino-genai", "huggingface_hub"]
|
||||
# dependencies = ["prefect>=3", "faster-whisper", "av>=14,<17", "nvidia-cublas-cu12", "nvidia-cudnn-cu12==9.*", "nvidia-cuda-runtime-cu12", "nvidia-cufft-cu12", "sherpa-onnx==2.0.1+cuda12.cudnn9", "numpy", "imagehash", "Pillow", "markdown", "openvino-genai", "huggingface_hub"]
|
||||
# [tool.uv]
|
||||
# find-links = ["https://k2-fsa.github.io/sherpa/onnx/cuda.html"] # sherpa-onnx CUDA wheels (diarization on GPU, CPU fallback in diarize.py)
|
||||
# ///
|
||||
"""Meeting pipeline. uv run --script flow.py <name> [--from STEP] [--speakers N] [--device cuda|npu] [--bench-npu]"""
|
||||
import os
|
||||
os.environ.setdefault("PREFECT_API_URL", "http://127.0.0.1:4200/api")
|
||||
os.environ["NO_PROXY"] = "127.0.0.1,localhost"
|
||||
os.environ["PREFECT_SERVER_ANALYTICS_ENABLED"] = "false"
|
||||
os.environ.setdefault("PREFECT_LOGGING_LEVEL", os.environ.get("LOG_LEVEL", "INFO").upper())
|
||||
os.environ.setdefault("PREFECT_LOGGING_LOG_PRINTS", "true") # module print()s show in Prefect UI
|
||||
import argparse, sys
|
||||
from pathlib import Path
|
||||
from prefect import flow, task
|
||||
@@ -52,19 +56,21 @@ def t_memory(name): step_status(name, "memory"); memory.run(name)
|
||||
|
||||
|
||||
class Llama:
|
||||
"""Start llama-server once, terminate in close() only if we started it."""
|
||||
def __init__(self, name): self.name, self.p = name, None
|
||||
def ensure(self):
|
||||
log = db.out_dir(self.name) / "llama.log"
|
||||
"""Start llama-server in vision (shots) or text (report) profile; switching restarts it. Terminate in close() only if we started it."""
|
||||
def __init__(self, name): self.name, self.p, self.vision = name, None, None
|
||||
def ensure(self, vision=True):
|
||||
if self.p and self.vision != vision: self.close()
|
||||
self.vision = vision
|
||||
log = db.out_dir(self.name) / ("llama.log" if vision else "llama_text.log")
|
||||
try:
|
||||
p = llama.start(log=log)
|
||||
p = llama.start(vision=vision, log=log)
|
||||
except Exception:
|
||||
if log.exists() and "out of memory" in log.read_text(errors="replace"):
|
||||
raise RuntimeError("GPU busy: free VRAM (close other CUDA apps) and retry from 'shots'")
|
||||
raise
|
||||
self.p = self.p or p
|
||||
def close(self):
|
||||
if self.p and self.p.poll() is None: self.p.terminate()
|
||||
if self.p and self.p.poll() is None: self.p.terminate(); self.p.wait() # wait: port must be free before a profile switch
|
||||
self.p = None
|
||||
|
||||
|
||||
@@ -108,8 +114,8 @@ def meeting(name: str, start_from: str = "audio", speakers: int = 5, model: str
|
||||
if go("transcribe"): t_transcribe(name, model, device)
|
||||
spk_chain()
|
||||
if go("shots"): L.ensure(); t_shots(name)
|
||||
L.ensure()
|
||||
if go("docs"): t_docs(name)
|
||||
L.ensure(vision=False) # report/memory are text-only: drop the vision encoder, use the text profile
|
||||
if go("report"): t_report(name)
|
||||
t_memory(name)
|
||||
db.set_status(name, "done")
|
||||
|
||||
Reference in New Issue
Block a user