feat(m0): measure the normal placement with room for the STT and paced STT partials
The gamemode_stt run showed Strata's automatic placement filling the card next to the STT (15.9 of 16.3 GB, first token 1.6 -> 7.5 s) and the STT's back-to-back partial passes cutting LLM output to a third. The new gamemode_tune stage measures both fixes the user chose: - stt_room: one start without experts (STT loaded) gives the LLM's base VRAM; --expert-vram gets what is left after the STT's ten-speaker growth (from this PC's stt stage) and a 768 MiB margin. - stt_pace: a ten-speaker partial pass every 2 s, or none, with finals every 0.5 s and finals first; records final wait and STT GPU share. run_m0_gamemode_tune.bat runs it unattended. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,9 @@ With --opt mode=load it is instead the STT load the gamemode stages put next to
|
||||
the LLM: load the model on device=cuda|cpu, write {"status": "loaded"} to --out,
|
||||
wait for the file go=PATH, then transcribe ten speakers at once (and one final
|
||||
clip) on a loop until the file stop=PATH appears, and write the timings.
|
||||
partial_every=SECONDS|none and final_every=SECONDS pace that loop the way the app
|
||||
would while the LLM answers: a ten-speaker partial pass every N seconds (none: no
|
||||
partials) and a final clip every M seconds in between.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -77,27 +80,73 @@ def batch_transcribe(model, audios: list, beam: int = 1) -> tuple[list[str], flo
|
||||
return texts, time.perf_counter() - t0
|
||||
|
||||
|
||||
def load_loop(batch, single, go: Path, stop: Path, wait_s: float = 3600, max_s: float = 600) -> dict:
|
||||
"""Wait for ``go``, then run ``batch()`` (ten speakers) and ``single()`` (one final clip)
|
||||
in turn until ``stop`` appears. An error (out of memory) ends the loop and is kept."""
|
||||
def load_loop(batch, single, go: Path, stop: Path, pace: dict | None = None, wait_s: float = 3600,
|
||||
max_s: float = 600) -> dict:
|
||||
"""Wait for ``go``, then run ``batch()`` (a ten-speaker partial pass) and ``single()`` (one final
|
||||
clip) until ``stop`` appears. Without ``pace`` they run back to back (every speaker talking
|
||||
without a break). With ``pace`` a partial pass starts every ``partial_every`` s (None: none) and a
|
||||
final every ``final_every`` s. A final that is due goes first; one that falls due during a
|
||||
partial pass waits for it (final_wait_s).
|
||||
An error (out of memory) ends the loop and is kept."""
|
||||
t0 = time.monotonic()
|
||||
while not go.exists():
|
||||
if stop.exists() or time.monotonic() - t0 > wait_s:
|
||||
return {"status": "not_started", "batch10_s": stats([]), "single_s": stats([]), "errors": []}
|
||||
return {"status": "not_started", "batch10_s": stats([]), "single_s": stats([]), "errors": [],
|
||||
"pace": pace}
|
||||
time.sleep(0.2)
|
||||
b, one, errors = [], [], []
|
||||
t1 = time.monotonic()
|
||||
while not stop.exists() and time.monotonic() - t1 < max_s:
|
||||
# perf_counter: time.monotonic ticks every ~16 ms on Windows, too coarse for a 0.1 s clip.
|
||||
b, one, waits, errors = [], [], [], []
|
||||
t1 = time.perf_counter()
|
||||
every_p = (pace or {}).get("partial_every")
|
||||
every_f = (pace or {}).get("final_every")
|
||||
next_p, next_f = t1, t1
|
||||
|
||||
def timed(fn, into):
|
||||
s0 = time.perf_counter()
|
||||
fn()
|
||||
into.append(time.perf_counter() - s0)
|
||||
|
||||
while not stop.exists() and time.perf_counter() - t1 < max_s:
|
||||
try:
|
||||
for fn, into in ((batch, b), (single, one)):
|
||||
s0 = time.perf_counter()
|
||||
fn()
|
||||
into.append(time.perf_counter() - s0)
|
||||
if pace is None:
|
||||
timed(batch, b)
|
||||
timed(single, one)
|
||||
continue
|
||||
now = time.perf_counter()
|
||||
# A final goes first: the answer waits for it, not for the subtitles.
|
||||
if every_f is not None and now >= next_f:
|
||||
waits.append(now - next_f)
|
||||
next_f = max(next_f + every_f, now)
|
||||
timed(single, one)
|
||||
continue
|
||||
if every_p is not None and now >= next_p:
|
||||
next_p = now + every_p
|
||||
timed(batch, b)
|
||||
continue
|
||||
dues = [x for x, on in ((next_p, every_p is not None), (next_f, every_f is not None)) if on]
|
||||
time.sleep(min(max(min(dues, default=now + 0.1) - now, 0.0), 0.1))
|
||||
except Exception as e:
|
||||
errors.append(f"{type(e).__name__}: {str(e)[:300]}")
|
||||
break
|
||||
return {"status": "done", "batch10_s": stats(b), "single_s": stats(one), "errors": errors,
|
||||
"seconds": round(time.monotonic() - t1, 1)}
|
||||
seconds = time.perf_counter() - t1
|
||||
res = {"status": "done", "batch10_s": stats(b), "single_s": stats(one), "errors": errors,
|
||||
"seconds": round(seconds, 1), "pace": pace,
|
||||
"busy_share": round(min((sum(b) + sum(one)) / seconds, 1.0), 3) if seconds > 0 else None}
|
||||
if pace is not None:
|
||||
res["final_wait_s"] = stats(waits)
|
||||
return res
|
||||
|
||||
|
||||
def parse_pace(opts: dict) -> dict | None:
|
||||
"""partial_every=SECONDS|none, final_every=SECONDS; neither: back to back (None)."""
|
||||
if "partial_every" not in opts and "final_every" not in opts:
|
||||
return None
|
||||
|
||||
def num(key):
|
||||
v = opts.get(key, "none")
|
||||
return None if v == "none" else float(v)
|
||||
|
||||
return {"partial_every": num("partial_every"), "final_every": num("final_every")}
|
||||
|
||||
|
||||
def load_worker(out: Path, work: Path, opts: dict) -> int:
|
||||
@@ -122,7 +171,7 @@ def load_worker(out: Path, work: Path, opts: dict) -> int:
|
||||
return 0
|
||||
write_json(out, dict(res, status="loaded"))
|
||||
res.update(load_loop(lambda: batch_transcribe(model, clips), lambda: transcribe(model, clips[0], 1),
|
||||
Path(opts["go"]), Path(opts["stop"])))
|
||||
Path(opts["go"]), Path(opts["stop"]), pace=parse_pace(opts)))
|
||||
write_json(out, res)
|
||||
return 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user