fix(runtime): grammar bench measures OFF only to avoid ZeroGPU abort
Browse filesRunning grammar-on + grammar-off back-to-back inside the single demo.load
warmup handler stacked a 3rd GPU acquisition after the warmup gen, which
ZeroGPU aborted ("GPU task aborted"). grammar-on throughput is already the
normal [zerogpu-bench] number every real freeform call prints (~17-22 tok/s),
so measure only the unconstrained grammar-off run here — keeping the handler
to 2 GPU acquisitions (warmup + bench), the range the log shows succeeds.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- src/buddy_fusion/runtime.py +26 -22
src/buddy_fusion/runtime.py
CHANGED
|
@@ -475,34 +475,38 @@ def warmup() -> None:
|
|
| 475 |
|
| 476 |
|
| 477 |
def _grammar_bench(cfg: "LlamaRuntimeConfig", model_path: str) -> None:
|
| 478 |
-
"""One-off diagnostic: run the
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 486 |
import json
|
| 487 |
from .exemplars import pick_exemplar
|
| 488 |
-
from .prompts import build_freeform_messages
|
| 489 |
|
| 490 |
prompt = "a small round dragon with two curved horns and a long tail"
|
| 491 |
ex = pick_exemplar(prompt)
|
| 492 |
-
common = dict(
|
| 493 |
-
model_path=model_path,
|
| 494 |
-
messages=build_freeform_messages(prompt, json.dumps(ex)),
|
| 495 |
-
max_tokens=int(os.getenv("BUDDY_GRAMMAR_BENCH_TOKENS", "400")),
|
| 496 |
-
temperature=0.8,
|
| 497 |
-
top_p=0.9,
|
| 498 |
-
n_ctx=max(cfg.n_ctx, 4096),
|
| 499 |
-
n_threads=cfg.n_threads,
|
| 500 |
-
n_gpu_layers=cfg.n_gpu_layers,
|
| 501 |
-
flash_attn=cfg.flash_attn,
|
| 502 |
-
)
|
| 503 |
try:
|
| 504 |
-
_run_freeform_completion(
|
| 505 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 506 |
except Exception as exc: # noqa: BLE001 - diagnostic only, never break warmup
|
| 507 |
print(f"[grammar-bench] failed: {exc}", flush=True)
|
| 508 |
|
|
|
|
| 475 |
|
| 476 |
|
| 477 |
def _grammar_bench(cfg: "LlamaRuntimeConfig", model_path: str) -> None:
|
| 478 |
+
"""One-off diagnostic: run the freeform prompt UNCONSTRAINED (no GBNF grammar)
|
| 479 |
+
to isolate how much grammar-constrained sampling costs vs raw 12B decode.
|
| 480 |
+
|
| 481 |
+
Only the grammar-OFF run lives here: the grammar-ON throughput is already the
|
| 482 |
+
normal [zerogpu-bench] number every real freeform call prints (~17-22 tok/s),
|
| 483 |
+
so there is no need to re-measure it. Running BOTH inside this one demo.load
|
| 484 |
+
handler stacked a 3rd GPU acquisition after the warmup gen and ZeroGPU aborted
|
| 485 |
+
it ("GPU task aborted"); keeping the handler to 2 acquisitions (warmup + this)
|
| 486 |
+
is in the range the log shows succeeds. Uses the same n_ctx=4096 / freeform
|
| 487 |
+
GPU wrapper as the real calls so the number transfers directly. Gated by
|
| 488 |
+
BUDDY_GRAMMAR_BENCH=1; read [grammar-bench-off] off the log, compare against
|
| 489 |
+
the [zerogpu-bench] (grammar-on) lines, then unset the env."""
|
| 490 |
import json
|
| 491 |
from .exemplars import pick_exemplar
|
| 492 |
+
from .prompts import build_freeform_messages
|
| 493 |
|
| 494 |
prompt = "a small round dragon with two curved horns and a long tail"
|
| 495 |
ex = pick_exemplar(prompt)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 496 |
try:
|
| 497 |
+
_run_freeform_completion(
|
| 498 |
+
model_path=model_path,
|
| 499 |
+
messages=build_freeform_messages(prompt, json.dumps(ex)),
|
| 500 |
+
schema=None,
|
| 501 |
+
max_tokens=int(os.getenv("BUDDY_GRAMMAR_BENCH_TOKENS", "400")),
|
| 502 |
+
temperature=0.8,
|
| 503 |
+
top_p=0.9,
|
| 504 |
+
n_ctx=max(cfg.n_ctx, 4096),
|
| 505 |
+
n_threads=cfg.n_threads,
|
| 506 |
+
n_gpu_layers=cfg.n_gpu_layers,
|
| 507 |
+
flash_attn=cfg.flash_attn,
|
| 508 |
+
label="grammar-bench-off",
|
| 509 |
+
)
|
| 510 |
except Exception as exc: # noqa: BLE001 - diagnostic only, never break warmup
|
| 511 |
print(f"[grammar-bench] failed: {exc}", flush=True)
|
| 512 |
|