fix(m0): count only video windows that played 1080p60 under the cap they claim
- A window counts only when the player kept the asked quality and height the whole time and played the source's 60 fps; a player stuck below 1080p is a stage error, not a note. - Pauses, seeks and buffering are counted inside the page during the window, so a pause that ended before the last snapshot no longer passes as GPU stutter. - A capped window whose cap found nothing to pause, ran no pause cycle, or could not pause or resume a process is an error and does not count for the cap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -74,6 +74,6 @@ LLM 단계는 8080 포트를 씁니다. 다른 프로그램이 이 포트를 쓰
|
||||
|
||||
`run_m0_game_live.bat`을 더블클릭하면 실제 게임을 켠 상태로 잽니다(`gamemode_live`). 게임을 창 모드로 켜고 플레이 화면까지 들어간 뒤 Enter를 누르고 15초 안에 게임으로 돌아가면 됩니다. 게임 중 배치 4개(전문가 2GB·0GB, 음성 인식 GPU·CPU)를 차례로 재고 10~15분 걸리며, 끝나면 알림음이 울립니다. 게임 화면이나 게임 이름은 저장하지 않고 VRAM 사용량과 속도만 적습니다. 그래픽 메모리를 많이 쓰는 게임이면 배치가 켜지지 않을 수 있는데, 그것도 결과로 적습니다.
|
||||
|
||||
`run_m0_video.bat`을 더블클릭하면 Jarvis 옆에서 보는 영상이 끊기는지 잽니다(`video_drops`). 크롬(없으면 엣지)이 새 임시 프로필로 떠서 유튜브의 Blender 영상(Big Buck Bunny, 1080p 60fps, 소리 끔)을 틉니다. 광고가 나오면 건너뛸 수 있을 때 건너뛰고 끝날 때까지 기다립니다. 영상을 틀어 둔 채로 (1) Jarvis를 끈 상태 1분, (2) LLM(평소 배치, STT 자리와 여유 1GB)과 STT를 켜 두고 쉬는 상태 1분, (3) LLM이 답하고 STT가 10명 동시 전사를 쉬지 않고 하는 상태를 GPU 95% 제한 없이 두 번, 제한을 켜고 두 번, (4) 다시 Jarvis를 끈 상태 1분을 잽니다. 각각 끊긴 프레임 수(유튜브 "전문가용 통계"의 Dropped Frames와 같은 값)와, 화면에 프레임이 50ms·100ms 넘게 안 바뀐 횟수를 셉니다. 10~15분 걸립니다. 그동안 브라우저 창을 가리거나 최소화하지 말고 PC에 손대지 않으시면 됩니다. 인터넷으로 영상을 받으므로 네트워크가 느리면 버퍼링도 따로 적습니다.
|
||||
`run_m0_video.bat`을 더블클릭하면 Jarvis 옆에서 보는 영상이 끊기는지 잽니다(`video_drops`). 크롬(없으면 엣지)이 새 임시 프로필로 떠서 유튜브의 Blender 영상(Big Buck Bunny, 1080p 60fps, 소리 끔)을 틉니다. 광고가 나오면 건너뛸 수 있을 때 건너뛰고 끝날 때까지 기다립니다. 영상을 틀어 둔 채로 (1) Jarvis를 끈 상태 1분, (2) LLM(평소 배치, STT 자리와 여유 1GB)과 STT를 켜 두고 쉬는 상태 1분, (3) LLM이 답하고 STT가 10명 동시 전사를 쉬지 않고 하는 상태를 GPU 95% 제한 없이 두 번, 제한을 켜고 두 번, (4) 다시 Jarvis를 끈 상태 1분을 잽니다. 각각 끊긴 프레임 수(유튜브 "전문가용 통계"의 Dropped Frames와 같은 값)와, 화면에 프레임이 50ms·100ms 넘게 안 바뀐 횟수를 셉니다. 10~15분 걸립니다. 그동안 브라우저 창을 가리거나 최소화하지 말고 PC에 손대지 않으시면 됩니다. 광고, 일시정지, 버퍼링, 건너뛰기가 끼었거나 화질이 1080p 60fps가 아니었던 구간, 제한을 켰는데 Jarvis를 실제로 멈추지 못한 구간은 기록만 하고 비교에서는 뺍니다.
|
||||
|
||||
다 끝나고 필요 없으면 작업 폴더(`\JarvisM0`)를 통째로 지우면 됩니다. Python, 모델, Strata(엔진과 설정 포함)는 모두 그 안에 설치하도록 지정해 두었습니다.
|
||||
|
||||
@@ -34,6 +34,10 @@ from m0lib.llm_client import ChatClient, http_json
|
||||
# Blender's own upload (CC BY 3.0, 10:34, 4K and 1080p at 60 fps): no music claim, rarely ads.
|
||||
VIDEO_URL = "https://www.youtube.com/watch?v=aqz-KE-bpKQ"
|
||||
QUALITY = "hd1080"
|
||||
# What a counted window must have played: the asked quality at its height and the source's 60 fps (the
|
||||
# player's frame counter includes dropped frames, so a busy GPU does not lower it; a 30 fps format does).
|
||||
WANT = {"quality": QUALITY, "height": 1080, "fps": 60}
|
||||
MIN_FPS_SHARE = 0.8
|
||||
QUIET_S = 60 # the video alone, and Jarvis loaded but idle
|
||||
SETTLE_S = 5 # after a quality change or a seek, before a window starts
|
||||
MIN_LEFT_S = 240 # a window that could reach the end starts the video again first
|
||||
@@ -155,8 +159,11 @@ _INSTALL = """(() => {
|
||||
const v = document.querySelector('video.html5-main-video') || document.querySelector('video');
|
||||
if (!v || !v.requestVideoFrameCallback) return false;
|
||||
if (window.__m0 && window.__m0.v === v) return true;
|
||||
const m = window.__m0 = {v, shown: 0, last: null, maxGap: 0, gaps: [0, 0], waits: 0, ad: false};
|
||||
const m = window.__m0 = {v, shown: 0, last: null, maxGap: 0, gaps: [0, 0], waits: 0, pauses: 0, seeks: 0,
|
||||
ad: false, minH: v.videoHeight, maxH: v.videoHeight};
|
||||
v.addEventListener('waiting', () => { m.waits++; });
|
||||
v.addEventListener('pause', () => { m.pauses++; });
|
||||
v.addEventListener('seeking', () => { m.seeks++; });
|
||||
const tick = (now) => {
|
||||
if (m.last !== null) {
|
||||
const g = now - m.last;
|
||||
@@ -165,6 +172,7 @@ _INSTALL = """(() => {
|
||||
if (g > %(g1)d) m.gaps[1]++;
|
||||
}
|
||||
m.last = now; m.shown++;
|
||||
m.minH = Math.min(m.minH, v.videoHeight); m.maxH = Math.max(m.maxH, v.videoHeight);
|
||||
const p = document.getElementById('movie_player');
|
||||
if (p && p.classList.contains('ad-showing')) m.ad = true;
|
||||
v.requestVideoFrameCallback(tick);
|
||||
@@ -174,13 +182,14 @@ _INSTALL = """(() => {
|
||||
})()""" % {"g0": GAP_MS[0], "g1": GAP_MS[1]}
|
||||
|
||||
_RESET = "(() => { const m = window.__m0; m.shown = 0; m.last = null; m.maxGap = 0; m.gaps = [0, 0]; " \
|
||||
"m.waits = 0; m.ad = false; return true; })()"
|
||||
"m.waits = 0; m.pauses = 0; m.seeks = 0; m.ad = false; m.minH = m.maxH = m.v.videoHeight; return true; })()"
|
||||
|
||||
_SNAPSHOT = """(() => {
|
||||
const m = window.__m0, v = m.v, p = document.getElementById('movie_player');
|
||||
const q = v.getVideoPlaybackQuality();
|
||||
return {dropped: q.droppedVideoFrames, total: q.totalVideoFrames, shown: m.shown, max_gap_ms: m.maxGap,
|
||||
gaps: m.gaps, waits: m.waits, ad: m.ad || !!(p && p.classList.contains('ad-showing')),
|
||||
gaps: m.gaps, waits: m.waits, pauses: m.pauses, seeks: m.seeks, min_height: m.minH, max_height: m.maxH,
|
||||
ad: m.ad || !!(p && p.classList.contains('ad-showing')),
|
||||
paused: v.paused, ended: v.ended, time: v.currentTime, duration: v.duration,
|
||||
width: v.videoWidth, height: v.videoHeight,
|
||||
quality: p && p.getPlaybackQuality ? p.getPlaybackQuality() : null};
|
||||
@@ -321,10 +330,12 @@ def open_video_page(work: Path, url: str = VIDEO_URL, extra_args: tuple[str, ...
|
||||
# --------------------------------------------------------------------------
|
||||
# One measured window and the comparison.
|
||||
|
||||
def window_stats(before: dict, after: dict, seconds: float) -> dict:
|
||||
"""What the video did between two snapshots (``after`` also carries the shown-frame counters
|
||||
since the reset just before ``before``). A window with an ad, a pause, the end or a reload of the
|
||||
counters is kept but not counted (``valid`` False, with the reason)."""
|
||||
def window_stats(before: dict, after: dict, seconds: float, want: dict | None = None) -> dict:
|
||||
"""What the video did between two snapshots (``after`` also carries the counters kept since the
|
||||
reset just before ``before``). A window is kept but not counted (``valid`` False, with the
|
||||
reasons) when something other than the GPU could have changed it: an ad, a pause or a seek at
|
||||
any point, buffering, the end, a reload of the counters, or (with ``want``) another quality,
|
||||
height or a lower frame rate than the source's."""
|
||||
out: dict = {"seconds": round(seconds, 1)}
|
||||
reasons = []
|
||||
if after.get("total", 0) < before.get("total", 0) or after.get("dropped", 0) < before.get("dropped", 0):
|
||||
@@ -332,6 +343,10 @@ def window_stats(before: dict, after: dict, seconds: float) -> dict:
|
||||
for key, why in (("ad", "an ad was showing"), ("paused", "the video was paused"), ("ended", "the video ended")):
|
||||
if after.get(key):
|
||||
reasons.append(why)
|
||||
for key, why in (("pauses", "the video was paused during the window"),
|
||||
("seeks", "the video jumped during the window"), ("waits", "the video was buffering")):
|
||||
if after.get(key):
|
||||
reasons.append(f"{why} ({after[key]}x)")
|
||||
total = after.get("total", 0) - before.get("total", 0)
|
||||
dropped = after.get("dropped", 0) - before.get("dropped", 0)
|
||||
out.update(frames=total, dropped=dropped, shown=after.get("shown"),
|
||||
@@ -344,6 +359,17 @@ def window_stats(before: dict, after: dict, seconds: float) -> dict:
|
||||
quality=after.get("quality"), height=after.get("height"))
|
||||
if total <= 0 and not reasons:
|
||||
reasons.append("the video showed no frames")
|
||||
if want:
|
||||
got = {before.get("quality"), after.get("quality")}
|
||||
if got != {want["quality"]}:
|
||||
reasons.append(f"the quality was {'/'.join(sorted(str(q) for q in got))}, not {want['quality']}")
|
||||
heights = {before.get("height"), after.get("min_height"), after.get("max_height"), after.get("height")}
|
||||
heights.discard(None)
|
||||
if heights != {want["height"]}:
|
||||
reasons.append(f"the picture was {'/'.join(str(h) for h in sorted(heights))} lines high, "
|
||||
f"not {want['height']}")
|
||||
if out["fps"] is not None and total > 0 and out["fps"] < want["fps"] * MIN_FPS_SHARE:
|
||||
reasons.append(f"the video played {out['fps']} fps, not {want['fps']}")
|
||||
out["valid"] = not reasons
|
||||
if reasons:
|
||||
out["invalid_because"] = reasons
|
||||
@@ -367,8 +393,23 @@ def compare(rows: list[dict]) -> dict:
|
||||
return out
|
||||
|
||||
|
||||
def cap_problems(duty: dict, pids: list[int]) -> list[str]:
|
||||
"""Why a capped window did not run under the cap it claims: nothing to pause, no pause cycle,
|
||||
or a process that could not be paused or resumed at once."""
|
||||
out = []
|
||||
if not pids:
|
||||
out.append("the cap found no engine process to pause")
|
||||
elif not duty.get("cycles"):
|
||||
out.append("the cap paused nothing during the window")
|
||||
if duty.get("failed_processes"):
|
||||
out.append(f"{duty['failed_processes']} process(es) could not be paused or resumed at once")
|
||||
if duty.get("left_paused"):
|
||||
out.append(f"{duty['left_paused']} process(es) are still paused")
|
||||
return out
|
||||
|
||||
|
||||
def measure_window(page: VideoPage, work: Callable[[], dict] | None = None,
|
||||
seconds: float | None = None) -> tuple[dict, dict]:
|
||||
seconds: float | None = None, want: dict | None = WANT) -> tuple[dict, dict]:
|
||||
"""The video's stats over ``work()`` (or ``seconds`` of nothing), with the GPU's use meanwhile."""
|
||||
page.keep_room()
|
||||
page.reset()
|
||||
@@ -381,7 +422,7 @@ def measure_window(page: VideoPage, work: Callable[[], dict] | None = None,
|
||||
else:
|
||||
time.sleep(QUIET_S if seconds is None else seconds)
|
||||
after = page.snapshot()
|
||||
stats = window_stats(before, after, time.perf_counter() - t0)
|
||||
stats = window_stats(before, after, time.perf_counter() - t0, want)
|
||||
stats["gpu_util"] = util.summary()
|
||||
return stats, done
|
||||
|
||||
@@ -415,8 +456,10 @@ def measure(r: StageResult, s: "llm.Strata", preset: dict, context: int, stt_pyt
|
||||
if not start["started"]:
|
||||
r.error("video", start.get("error") or "the video did not start playing")
|
||||
return
|
||||
if start.get("quality") != quality:
|
||||
r.note(f"the player stayed at {start.get('quality')} instead of {quality}")
|
||||
if start.get("quality") != quality or start.get("height") != WANT["height"]:
|
||||
# Every window then plays something else; they are kept but none is counted.
|
||||
r.error("video", f"the player stayed at {start.get('quality')} ({start.get('height')} lines) "
|
||||
f"instead of {quality}")
|
||||
|
||||
def row(key: str, jarvis: str, cap: float | None = None) -> dict:
|
||||
x = {"key": key, "jarvis": jarvis, "gpu_cap": cap}
|
||||
@@ -472,8 +515,6 @@ def measure(r: StageResult, s: "llm.Strata", preset: dict, context: int, stt_pyt
|
||||
say(f" - Jarvis가 답하고 STT가 쉬지 않고 전사하는 중{' (GPU 95% 제한)' if cap else ''}")
|
||||
x = row(key, "busy", cap)
|
||||
pids = llm.cap_pids(s, stt) if cap else []
|
||||
if cap and not pids:
|
||||
r.error(f"video {key} gpu cap", "found no engine process to pause")
|
||||
|
||||
def work() -> dict:
|
||||
with gpucap.DutyCap(pids, cap or 1.0) as duty:
|
||||
@@ -487,8 +528,13 @@ def measure(r: StageResult, s: "llm.Strata", preset: dict, context: int, stt_pyt
|
||||
r.error(f"video {key}", err)
|
||||
if cap:
|
||||
x["gpu_cap"] = done["duty"]
|
||||
if x["gpu_cap"]["left_paused"]:
|
||||
r.error(f"video {key} gpu cap", f"{x['gpu_cap']['left_paused']} process(es) are still paused")
|
||||
problems = cap_problems(x["gpu_cap"], pids)
|
||||
for why in problems:
|
||||
r.error(f"video {key} gpu cap", why)
|
||||
if problems:
|
||||
# Not a capped window, so it must not count for the cap.
|
||||
stats["valid"] = False
|
||||
stats["invalid_because"] = stats.get("invalid_because", []) + problems
|
||||
keep(x, stats)
|
||||
busy = stt.finish()
|
||||
r["stt_busy"] = {k: busy.get(k) for k in ("status", "batch10_s", "single_s", "errors", "busy_share")
|
||||
|
||||
Reference in New Issue
Block a user