C.W.K.
Stream
Lesson 02 of 05 · published

Local 벤치마크

~18 min · ops, benchmark

Level 0Downloader
0 XP0/41 lessons0/11 achievements
0/120 XP to next level120 XP to go0% complete

뭘 측정?

(모델, 하드웨어) 쌍당 세 숫자:

  • Token / second (decode). 헤드라인 숫자. Streaming 반응성이 이거에 의존.
  • 첫 토큰까지 시간 (TTFT). 모델 load + prompt eval 포함. 모델이 warm일 땐 ~0으로 떨어져.
  • 메모리 비용. ollama psSIZE 컬럼.

기록해 — 기억 믿지 마

6개월 후엔 32B 모델이 이 Mac에 viable했는지 기억 못 해. 적어둬: 하드웨어, 모델, quant, num_ctx, env var, 세 숫자. 단순 Markdown 표면 충분.

공정한 벤치마크

  • 모델 이미 warm인 상태에서 (timing 전 warmup prompt 한 번).
  • 응답 길이 대충 안정되도록 고정 seed 사용.
  • 여러 run에 고정 prompt.
  • 세 번 실행하고 median 사용.

Code

벤치마크 harness·python
import httpx, json, time, statistics

OLLAMA = "http://localhost:11434"

def bench(model: str, prompt: str, runs: int = 3) -> dict:
    """모델 warm한 다음 N번 timed iteration."""
    # Warmup
    httpx.post(f"{OLLAMA}/api/chat", json={
        "model": model,
        "messages": [{"role": "user", "content": "ok"}],
        "stream": False, "options": {"num_predict": 1, "seed": 1},
    }, timeout=300.0)

    tps_runs, ttft_runs = [], []
    for i in range(runs):
        t0 = time.time()
        first_token_at = None
        with httpx.stream("POST", f"{OLLAMA}/api/chat", json={
            "model": model,
            "messages": [{"role": "user", "content": prompt}],
            "stream": True, "options": {"seed": 42, "num_predict": 200},
        }, timeout=None) as r:
            for line in r.iter_lines():
                if not line:
                    continue
                chunk = json.loads(line)
                if first_token_at is None and chunk.get("message", {}).get("content"):
                    first_token_at = time.time() - t0
                if chunk.get("done"):
                    ec = chunk.get("eval_count", 0)
                    ed = chunk.get("eval_duration", 1) or 1
                    tps_runs.append(ec / (ed / 1e9))
                    break
        ttft_runs.append(first_token_at or 0)

    return {
        "model": model,
        "runs": runs,
        "tps_median": statistics.median(tps_runs),
        "ttft_median_s": statistics.median(ttft_runs),
    }

print(bench("qwen2.5:7b", "Explain unified memory in 4 bullets."))

External links

Exercise

벤치마크를 설치된 모델 셋에 같은 고정 prompt로 돌려. 모델당 세 숫자를 Markdown 표에 기록. 하드웨어의 best tok/s 식별하고 진짜 use case에 충분한지 결정.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.