From fc38595c65c4047697c8ded41e2d67d81dfe33e1 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Sat, 3 Oct 2026 19:12:20 +0200 Subject: [PATCH] setup: recommend the hybrid worker count only with more E-cores than P-cores (#642) docs/AMD_HIP.md's gfx1030 report measured an i7-13700KF (8P + 8E) at 38-42 tok/s with all 15 workers against 36 with 8, so a CPU with no more E-cores than P-cores keeps the engine's own count; the E-heavy chips the fork measured (i9-14900KF: 15 of 23 faster) get the recommendation. --- setup.py | 8 ++++++-- tools/test_setup_hybrid.py | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index c59245ee..818cbb22 100644 --- a/setup.py +++ b/setup.py @@ -341,11 +341,15 @@ def cpu_cores(): def hybrid_pool_workers(cores) -> int | None: """#642 (Hardin22's measurement): on a hybrid CPU the expert pool runs best on the P-cores but the host loop's one plus HALF of the E-cores - an E-core runs the expert kernels ~2.2x slower and each layer waits for its slowest - part (i9-14900KF, 8P + 16E: 15 workers decoded 165 / 116 tok/s against 106 / 84 with all 23). None: not hybrid - (the engine's own default, one worker per physical core but the host's, stays).""" + part (i9-14900KF, 8P + 16E: 15 workers decoded 165 / 116 tok/s against 106 / 84 with all 23). Only on a CPU with + more E-cores than P-cores: on an i7-13700KF (8P + 8E, docs/AMD_HIP.md's gfx1030 report) all 15 workers decoded + 38-42 tok/s against 36 with 8, so there the engine's own count stays. None: the engine's own default (one worker + per physical core but the host's) stays.""" if not cores: return None p, e = cores + if e <= p: + return None return max(1, p - 1 + e // 2) diff --git a/tools/test_setup_hybrid.py b/tools/test_setup_hybrid.py index b07d2e3c..a5b9a164 100644 --- a/tools/test_setup_hybrid.py +++ b/tools/test_setup_hybrid.py @@ -23,7 +23,8 @@ class HybridWorkers(unittest.TestCase): self.assertEqual(setup.hybrid_pool_workers((8, 16)), 15) # i9-14900K: the fork's measured 15 self.assertEqual(setup.hybrid_pool_workers((6, 8)), 9) # i5-13600K self.assertEqual(setup.hybrid_pool_workers((4, 8)), 7) # Ryzen AI 9 HX 370 (Zen 5 + Zen 5c) - self.assertEqual(setup.hybrid_pool_workers((1, 1)), 1) + self.assertIsNone(setup.hybrid_pool_workers((8, 8))) # i7-13700K: all cores measured faster (AMD_HIP.md) + self.assertIsNone(setup.hybrid_pool_workers((8, 4))) def test_recommend_keeps_a_given_count(self): with mock.patch.object(setup, "cpu_cores", lambda: (8, 16)), mock.patch.object(setup, "ok", lambda *a: None):