feat(m0): measure the 1 GB room for other programs and a 95 % GPU cap
User decision (2026-11-10, room to watch a video next to Jarvis): the normal placement leaves 1 GB of VRAM for programs opened later, and Jarvis's GPU work is capped at 95 %. - gamemode_tune's normal rows take OTHER_ROOM_MIB off the expert budget. - gpucap.DutyCap pauses the Strata engine (strata.exe --serve under the kit) and the STT worker with their children together for 10 ms of every 200 ms (NtSuspendProcess), and always resumes them. - Every row samples nvidia-smi utilization.gpu; capped rows have an uncapped twin (normal with and without the STT, game 2 GB with 2 s partials) so the run shows the cost and what the GPU really gets back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -10,8 +10,9 @@ Options (--opt key=value):
|
||||
only=together the same with the STT loaded next to it and transcribing ten
|
||||
speakers at once, on the GPU and on the CPU (needs stt_python=)
|
||||
only=live game placements and the STT while the user runs a real game
|
||||
only=tune the normal placement with room left for the STT, and in the game
|
||||
placement the STT doing fewer partial passes while the LLM answers
|
||||
only=tune the normal placement with room left for the STT and 1 GB for other
|
||||
programs, the game placement with the STT doing fewer partial passes
|
||||
while the LLM answers, and both with Jarvis capped at 95 % of the GPU
|
||||
stt_python=PATH the Python of the stt venv (m0.py passes it)
|
||||
"""
|
||||
|
||||
@@ -34,6 +35,7 @@ from m0lib.common import (IS_WINDOWS, GpuSampler, StageResult, ask, gpu_memory_m
|
||||
from m0lib.llm_bench import (bench_single, quick_bench, test_decode, test_images, test_parallel, # noqa: E402
|
||||
test_tools, test_vram_shrink, warmup)
|
||||
from m0lib.tool_fix import test_tools_fixed, tools_passed # noqa: E402
|
||||
from m0lib import gpucap # noqa: E402
|
||||
from m0lib.llm_client import ChatClient, http_json # noqa: E402
|
||||
|
||||
PRESETS = {
|
||||
@@ -111,18 +113,30 @@ LIVE = [lv for lv in TOGETHER if lv["key"].startswith("game_")]
|
||||
# whole run. Without a game the STT keeps every partial (user decision), so only the game
|
||||
# placement is paced; its back-to-back row is the baseline measured in the same run.
|
||||
# The 2 GB expert placement is the game minimum on a 16 GB card (faster than 0 GB in a real game).
|
||||
# Then (user decision, 2026-11-10, for watching a video next to Jarvis):
|
||||
# - the normal placement also leaves OTHER_ROOM_MIB free for programs opened later ("other_room_mib");
|
||||
# - Jarvis's GPU work (the engine and the STT worker together) is paused for 5 % of every 200 ms
|
||||
# ("gpu_cap", gpucap.DutyCap). The rows with and without it measure what it costs and how much
|
||||
# GPU time it really gives back (queued work still runs during the pause).
|
||||
STT_ROOM_MARGIN_MIB = 768 # what Strata's qwen36 engine itself keeps free when it places experts
|
||||
STT_GROWTH_FALLBACK_MIB = 1440 # M0 stt on the game PC: ten speakers at once over the loaded model
|
||||
OTHER_ROOM_MIB = 1024 # the app's default room for other programs in the normal placement
|
||||
GPU_CAP = 0.95
|
||||
_PARTIAL_2S = {"partial_every": 2.0, "final_every": 0.5}
|
||||
_FINALS_ONLY = {"partial_every": None, "final_every": 0.5}
|
||||
_ROOM = {"parallel": 1, "vision": "gpu", "sets": ["prefill=2048"], "stt": "cuda", "stt_room": True}
|
||||
_ROOM = {"parallel": 1, "vision": "gpu", "sets": ["prefill=2048"], "stt_room": True,
|
||||
"other_room_mib": OTHER_ROOM_MIB}
|
||||
_GAME2 = {**_GAME, "context": 16384, "sets": _EXP2, "stt": "cuda"}
|
||||
TUNED = [
|
||||
{"key": "normal_stt_room_stt_gpu", **_ROOM},
|
||||
{"key": "game_experts_2g_16k_stt_gpu", **_GAME, "context": 16384, "sets": _EXP2, "stt": "cuda"},
|
||||
{"key": "game_experts_2g_16k_partial_2s", **_GAME, "context": 16384, "sets": _EXP2, "stt": "cuda",
|
||||
"stt_pace": _PARTIAL_2S},
|
||||
{"key": "game_experts_2g_16k_finals_only", **_GAME, "context": 16384, "sets": _EXP2, "stt": "cuda",
|
||||
"stt_pace": _FINALS_ONLY},
|
||||
# The room is worked out in the first row, with the STT loaded; the rows after it reuse it.
|
||||
{"key": "normal_room_stt_gpu", **_ROOM, "stt": "cuda"},
|
||||
{"key": "normal_room_stt_gpu_cap95", **_ROOM, "stt": "cuda", "gpu_cap": GPU_CAP},
|
||||
{"key": "normal_room_llm_only", **_ROOM},
|
||||
{"key": "normal_room_llm_only_cap95", **_ROOM, "gpu_cap": GPU_CAP},
|
||||
{"key": "game_experts_2g_16k_stt_gpu", **_GAME2},
|
||||
{"key": "game_experts_2g_16k_partial_2s", **_GAME2, "stt_pace": _PARTIAL_2S},
|
||||
{"key": "game_experts_2g_16k_partial_2s_cap95", **_GAME2, "stt_pace": _PARTIAL_2S, "gpu_cap": GPU_CAP},
|
||||
{"key": "game_experts_2g_16k_finals_only", **_GAME2, "stt_pace": _FINALS_ONLY},
|
||||
]
|
||||
LEVEL_SETS = {"levels": LEVELS, "together": TOGETHER, "live": LIVE, "tune": TUNED}
|
||||
INSTALL_URL = "https://github.com/Niko1221/Strata/releases/latest/download/install.ps1"
|
||||
@@ -298,6 +312,10 @@ class SttLoad:
|
||||
self.cmd += ["--opt", f"{key}={'none' if v is None else v}"]
|
||||
self.proc: subprocess.Popen | None = None
|
||||
|
||||
@property
|
||||
def pid(self) -> int | None:
|
||||
return self.proc.pid if self.proc else None
|
||||
|
||||
def _read(self) -> dict:
|
||||
try:
|
||||
return read_json(self.out)
|
||||
@@ -463,8 +481,12 @@ def measure_levels(r: StageResult, s: Strata, preset: dict, context: int, levels
|
||||
continue
|
||||
sets = list(lv["sets"])
|
||||
if lv.get("stt_room"):
|
||||
where = (row["context"], lv["parallel"], lv["vision"])
|
||||
where = (row["context"], lv["parallel"], lv["vision"], lv.get("other_room_mib", 0))
|
||||
if where not in rooms:
|
||||
if not stt:
|
||||
# The probe needs the STT model in VRAM, as the app has it.
|
||||
r.error(f"level {lv['key']}", "no STT room was measured with the STT loaded")
|
||||
continue
|
||||
rooms[where] = stt_room(r, s, preset, row, lv, base)
|
||||
row["stt_room"] = rooms[where]
|
||||
sets.append(f"expert-vram={row['stt_room']['expert_vram_gib']}")
|
||||
@@ -483,7 +505,18 @@ def measure_levels(r: StageResult, s: Strata, preset: dict, context: int, levels
|
||||
c.chat([{"role": "user", "content": "안녕"}], max_tokens=8) # loading is not answer time
|
||||
if stt:
|
||||
stt.go()
|
||||
row.update(quick_bench(c))
|
||||
cap = lv.get("gpu_cap")
|
||||
pids = cap_pids(s, stt) if cap else []
|
||||
if cap and not pids:
|
||||
r.error(f"level {lv['key']} gpu cap", "found no engine process to pause")
|
||||
with gpucap.UtilSampler() as util, gpucap.DutyCap(pids, cap or 1.0) as duty:
|
||||
row.update(quick_bench(c))
|
||||
row["gpu_util"] = util.summary(cap)
|
||||
if cap:
|
||||
row["gpu_cap"] = duty.summary()
|
||||
if row["gpu_cap"]["failed_processes"]:
|
||||
r.error(f"level {lv['key']} gpu cap",
|
||||
f"{row['gpu_cap']['failed_processes']} process(es) could not be paused")
|
||||
for err in row["errors"]:
|
||||
r.error(f"level {lv['key']}", err)
|
||||
except Exception as e:
|
||||
@@ -540,10 +573,11 @@ def staging_gib(lines: list[str], default: float = 1.10) -> float:
|
||||
|
||||
|
||||
def expert_budget_gib(total_mib: int, used_mib: int, probe_model_mib: int, staging: float, growth_mib: int,
|
||||
margin_mib: int = STT_ROOM_MARGIN_MIB) -> float:
|
||||
"""--expert-vram (GiB, rounded down to 0.1) that leaves the STT's growth and the margin free.
|
||||
The budget first holds the staging, which the start without experts already has."""
|
||||
spare = total_mib - used_mib - probe_model_mib - growth_mib - margin_mib
|
||||
margin_mib: int = STT_ROOM_MARGIN_MIB, other_mib: int = 0) -> float:
|
||||
"""--expert-vram (GiB, rounded down to 0.1) that leaves the STT's growth, the margin and the room
|
||||
for other programs free. The budget first holds the staging, which the start without experts
|
||||
already has."""
|
||||
spare = total_mib - used_mib - probe_model_mib - growth_mib - margin_mib - other_mib
|
||||
if spare <= 0:
|
||||
return 0.0
|
||||
return math.floor((staging * 1024 + spare) / 1024 * 10) / 10
|
||||
@@ -553,7 +587,7 @@ def stt_room(r: StageResult, s: Strata, preset: dict, row: dict, lv: dict, base:
|
||||
"""Start the placement once without experts (the STT model already loaded), see what the LLM
|
||||
holds, stop it, and work out the expert budget that leaves the STT's ten-speaker growth free."""
|
||||
room: dict = {"stt_growth_mib": stt_growth_mib(s.log.parent.parent), "margin_mib": STT_ROOM_MARGIN_MIB,
|
||||
"expert_vram_gib": 0.0}
|
||||
"other_room_mib": lv.get("other_room_mib", 0), "expert_vram_gib": 0.0}
|
||||
say(" STT 자리 계산: 전문가 층 없이 한 번 켜서 LLM 기본 VRAM을 잽니다")
|
||||
before = gpu_memory_mib()
|
||||
launch = s.launch(preset, row["context"], parallel=lv["parallel"], vision=lv["vision"],
|
||||
@@ -571,7 +605,8 @@ def stt_room(r: StageResult, s: Strata, preset: dict, row: dict, lv: dict, base:
|
||||
room.update(probe_model_mib=after[0] - before[0], used_before_mib=before[0], total_mib=before[1],
|
||||
staging_gib=staging_gib(lines))
|
||||
room["expert_vram_gib"] = expert_budget_gib(before[1], before[0], room["probe_model_mib"],
|
||||
room["staging_gib"], room["stt_growth_mib"])
|
||||
room["staging_gib"], room["stt_growth_mib"],
|
||||
other_mib=room["other_room_mib"])
|
||||
if room["expert_vram_gib"] == 0:
|
||||
r.note(f"{lv['key']}: no room for experts next to the STT; started with --expert-vram 0")
|
||||
else:
|
||||
@@ -580,6 +615,16 @@ def stt_room(r: StageResult, s: Strata, preset: dict, row: dict, lv: dict, base:
|
||||
return room
|
||||
|
||||
|
||||
def cap_pids(s: Strata, stt: SttLoad | None) -> list[int]:
|
||||
"""The processes the GPU cap pauses together: the engine and the STT worker, with their children.
|
||||
None when the engine is not found (pausing only the STT would not be the cap)."""
|
||||
procs = gpucap.process_table()
|
||||
roots = gpucap.engine_roots(procs, s.home)
|
||||
if not roots:
|
||||
return []
|
||||
return gpucap.with_children(procs, roots + ([stt.pid] if stt and stt.pid else []))
|
||||
|
||||
|
||||
def ask_for_a_game() -> bool:
|
||||
"""The live stage needs someone to start a game first. False when nobody is there or they say no."""
|
||||
if not interactive():
|
||||
|
||||
Reference in New Issue
Block a user