Fast local LLM inference on plain CPUs. No GPU, 8 GB of RAM. OpenAI-compatible server.
Python aiavx512cpu-inferenceedge-aiggufinference-enginellama-cppllmllm-inferencelocal-ailocal-llmno-gpuon-device-aiopenai-apiopenai-compatiblequantizationqwenself-hostedspeculative-decodingternary
fix(bench): compare multi-stream ratios within each CPU class (#87)
Afloat2ed79897a790
diff --git a/bench/analyze.py b/bench/analyze.pyindex ddb6796..bc696a5 100644--- a/bench/analyze.py+++ b/bench/analyze.py@@ -426,19 +426,21 @@ def multi():print("## 7. `serve --multi 4`: aggregate tok/s and per-stream identity, new vs earlier build (interleaved rounds)\n")print("| box | round | new multi4 agg | prev multi4 agg | new / prev | new one-stream `--no-spec` | prev one-stream | new multi4 / one | streams identical to alone (new / prev) | new = prev texts | RssAnon peak MiB new / prev | min MemAvailable new / prev |")print("|---|---|---|---|---|---|---|---|---|---|---|---|")- x = []+ by_class = {}for b in sorted({r["_box"] for r in R}):for rd in sorted({r["round"] for r in R if r["_box"] == b}):v = {r["arm"]: r for r in R if r["_box"] == b and r["round"] == rd}if not all(k in v for k in ("new_m4", "prev_m4", "new_one", "prev_one")):continue- x.append(v["new_m4"]["agg_tok_s"] / v["prev_m4"]["agg_tok_s"])- print(f"| {b} | {rd} | {v['new_m4']['agg_tok_s']:.2f} | {v['prev_m4']['agg_tok_s']:.2f} | {x[-1]:.3f}× | "+ ratio = v["new_m4"]["agg_tok_s"] / v["prev_m4"]["agg_tok_s"]+ by_class.setdefault(CLASS.get(b, b), []).append(ratio)+ print(f"| {b} | {rd} | {v['new_m4']['agg_tok_s']:.2f} | {v['prev_m4']['agg_tok_s']:.2f} | {ratio:.3f}× | "f"{v['new_one']['agg_tok_s']:.2f} | {v['prev_one']['agg_tok_s']:.2f} | {v['new_m4']['agg_tok_s']/v['new_one']['agg_tok_s']:.2f}× | "f"{sum(v['new_m4']['identical_to_alone'])}/4 / {sum(v['prev_m4']['identical_to_alone'])}/4 | "f"{sum(a == c for a, c in zip(v['new_m4']['texts'], v['prev_m4']['texts']))}/4 | "f"{v['new_m4']['rss_anon_peak_kb']//1024} / {v['prev_m4']['rss_anon_peak_kb']//1024} | {v['new_m4']['mem_avail_min_kb']//1024} / {v['prev_m4']['mem_avail_min_kb']//1024} |")- print(f"\nnew / prev aggregate: {flag('--multi 4 aggregate tok/s', 'Ice Lake', x)}\n")+ for cls, ratios in sorted(by_class.items()):+ print(f"\nnew / prev aggregate ({cls}): {flag('--multi 4 aggregate tok/s', cls, ratios)}\n")def kld():diff --git a/bench/test_multi_analysis_classes.py b/bench/test_multi_analysis_classes.pynew file mode 100644index 0000000..329f394--- /dev/null+++ b/bench/test_multi_analysis_classes.py@@ -0,0 +1,52 @@+import contextlib+import io+import unittest+from unittest.mock import patch++import analyze+++def round_rows(box, ratio, rd=0):+ return [{'_box': box, 'round': rd, 'arm': arm,+ 'agg_tok_s': ratio if arm == 'new_m4' else 1.,+ 'identical_to_alone': [True] * 4, 'texts': ['answer'] * 4,+ 'rss_anon_peak_kb': 1024, 'mem_avail_min_kb': 1024}+ for arm in ('new_m4', 'prev_m4', 'new_one', 'prev_one')]+++class MultiAnalysisClassesTest(unittest.TestCase):+ def analyze(self, rows):+ output = io.StringIO()+ with patch.object(analyze, 'load', return_value=rows), \+ patch.object(analyze, 'REG', []), contextlib.redirect_stdout(output):+ analyze.multi()+ regressions = list(analyze.REG)+ return output.getvalue(), regressions++ def test_other_cpu_cannot_hide_regression(self):+ output, regressions = self.analyze(round_rows('e2', 2.) + round_rows('d1', .5))+ self.assertIn('aggregate (Ice Lake): 2.000× (n=1)', output)+ self.assertIn('aggregate (Zen 4): 0.500× (n=1)', output)+ self.assertEqual([(row[1], row[2], row[4]) for row in regressions], [('Zen 4', .5, 1)])++ def test_same_class_rounds_still_pool(self):+ output, regressions = self.analyze(round_rows('e2', 1.2) + round_rows('e3', 1.4))+ self.assertIn('1.300×', output)+ self.assertIn('(n=2)', output)+ self.assertEqual(regressions, [])++ def test_unknown_boxes_remain_separate(self):+ output, regressions = self.analyze(round_rows('custom-a', .6) + round_rows('custom-b', 1.4))+ self.assertIn('aggregate (custom-a): 0.600× (n=1)', output)+ self.assertIn('aggregate (custom-b): 1.400× (n=1)', output)+ self.assertEqual([(row[1], row[2]) for row in regressions], [('custom-a', .6)])++ def test_incomplete_round_does_not_enter_summary(self):+ output, regressions = self.analyze(round_rows('e2', 1.2) + round_rows('d1', .1)[:-1])+ self.assertIn('1.200× (n=1)', output)+ self.assertNotIn('aggregate (Zen 4)', output)+ self.assertEqual(regressions, [])+++if __name__ == '__main__':+ unittest.main()