Skip to content

tests: efficiency suite — tiny-model regression gates + full-model optimization dossier (#359)#360

Open
woolcoxm wants to merge 2 commits into
JustVugg:devfrom
woolcoxm:test/efficiency-suite
Open

tests: efficiency suite — tiny-model regression gates + full-model optimization dossier (#359)#360
woolcoxm wants to merge 2 commits into
JustVugg:devfrom
woolcoxm:test/efficiency-suite

Conversation

@woolcoxm

Copy link
Copy Markdown
Contributor

Closes #359.

What this adds

Two layers of efficiency coverage, both parsing telemetry glm.c already emits but nothing previously asserted on or surfaced:

tests/test_inefficiency.py — 8 tiny-model asserted tests (run via make test / test-python discovery, ~0.15s/run on glm_tiny):

  • telemetry parses (format-drift guard)
  • tiny tok/s ≥ floor (throughput regression)
  • PROFILE phases present and non-negative (accounting sanity)
  • disk-wait not dominant on a resident model (I/O-path regression)
  • CPU greedy determinism (two runs agree)
  • CUDA (auto-skip on CPU-only builds): init path (no silent exit 2), dense actually uploads VRAM, CPU-vs-CUDA argmax agreement ≥ 70% (kernel-correctness guard)

tests/test_efficiency_report.py — opt-in optimization dossier for a real model. Turns on every instrumentation flag (PROF, COLI_CUDA_PROFILE, CACHE_ROUTE, DISK_SPLIT, LOOKA) and prints 9 sections — provenance, throughput + tail latency, where-time-goes, attention breakdown, expert cache, disk I/O + phase split, routing quality + predictability, speculation, GPU tiers — each flagging inefficiency with the concrete knob to move tok/s. Never fails CI.

tools/efficiency.py — shared harness. parse_run() captures every telemetry signal; run_engine() wraps the subprocess. Reuses PROFILE_RE/SPEED_RE from tools/benchmark_cuda_fixture.py and extends the tok/s regex to also match the run_text (parenthesized) format the full-model PROMPT path emits.

Makefileefficiency / efficiency-cuda / efficiency-report targets.

How to run

make efficiency                 # tiny CPU tests (part of make test)
make efficiency-cuda            # tiny CUDA tests (needs: make glm.exe CUDA_DLL=1 && make cuda-dll)
COLI_EFFICIENCY_MODEL=../glm52_i4_g64 COLI_EFFICIENCY_CUDA=1 make efficiency-report

Verification

  • All 8 tiny tests pass (3 CUDA tests skip on a CPU-only build, pass on a CUDA build).
  • End-to-end on the full glm52_i4_g64 (390 GB), CPU and CUDA: clean exit, no crash.
  • The dossier surfaced real optimization targets on g64: 74% I/O-bound at 14.8% hit rate (cache re-fetching evicted experts — 600 loaded/token vs topk=8), and "layer input, skip attention" predicting next experts at 86% recall vs 24% for plain prefetch (signal to enable PILOT).

Notes

  • The CUDA tests require a CUDA build (make glm.exe CUDA_DLL=1 + make cuda-dll). They auto-skip otherwise — make test is green on any CPU-only build.
  • Tunable floors/thresholds are module constants (tools/efficiency.py, top of test_efficiency_report.py), overridable via env. Documented in tests/README_efficiency.md.
  • No engine code changed; this is test/tooling only.

woolcoxm added 2 commits July 17, 2026 10:52
…timization dossier

Two layers of efficiency coverage for the engine, both parsing the telemetry
glm.c already emits (REPLAY/PROFILE/[PROF]/CUDA-tier) but nothing previously
asserted on:

1. test_inefficiency.py — tiny-model asserted regression tests (8 tests, run
   in make test via test-python). Gate on: throughput floor, PROFILE phase
   accounting sanity, disk-wait not dominant on a resident model, CPU greedy
   determinism, and (when a CUDA build is present) CUDA init, dense VRAM
   upload, and CPU-vs-CUDA argmax agreement >= 70%. CUDA tests auto-skip with
   a clear build hint on CPU-only binaries.

2. test_efficiency_report.py — opt-in optimization dossier for a real model.
   Turns on every instrumentation flag (PROF, COLI_CUDA_PROFILE, CACHE_ROUTE,
   DISK_SPLIT, LOOKA) and prints 9 sections (provenance, throughput + tail
   latency, where-time-goes, attention breakdown, expert cache, disk I/O +
   phase split, routing quality + predictability, speculation, GPU tiers),
   each flagging inefficiency with the concrete knob to move tok/s. Never
   fails CI.

tools/efficiency.py is the shared harness: parse_run() captures every signal,
run_engine() wraps the subprocess. Reuses PROFILE_RE/SPEED_RE from
tools/benchmark_cuda_fixture.py and extends the tok/s regex to also catch the
run_text (parenthesized) format the full-model PROMPT path uses.

Makefile adds: efficiency / efficiency-cuda / efficiency-report targets.

Verified end-to-end on the full glm52_i4_g64 model (CPU + CUDA).
…ustVugg#360)

CI runs 'make check' = dependency-free tests, no model downloads (by design,
JustVugg#140). glm_tiny/ is a gitignored generated fixture, so test_inefficiency.py
hard-failed on the Windows/macOS/Linux runners with 'config.json: No such file
or directory' instead of skipping.

_engine_present() now requires BOTH glm.exe AND glm_tiny/config.json, and
_skip_reason() names exactly which prerequisite is missing so the skip is
actionable. Verified: 8 skipped (0 failed) with the fixture absent; 5 pass +
3 CUDA-skip with it present.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant