From 184012cac4ef602b7ad06eada31054a99b3f4cbc Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Sat, 10 Oct 2026 11:02:14 +0200 Subject: [PATCH] serve: cards whose speed scores are within 5% keep the config's card order (#1760) --- serve/server.py | 4 +++- serve/test_server.py | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/serve/server.py b/serve/server.py index 58836195..4afacfd7 100644 --- a/serve/server.py +++ b/serve/server.py @@ -2430,7 +2430,7 @@ def ordered_gpus(cfg: dict, scores=None, vrams=None) -> list[int]: """#1352: the cards of a layer split in the order the engine stages them. With "layer_split": "auto" (the default) the faster card goes LAST - the last stage runs the head, the draft layer and the verify, and a prompt chunk waits on it (the reporter's 4070 Ti SUPER + 5060 Ti: a 6K prompt took 50 s one way round and 15 s the - other); "faster" is multiprocessors x max clock. Equal cards keep the config's order (the sort is stable), and + other); "faster" is multiprocessors x max clock. Equal cards - scores within 5% - keep the config's order, and so does anything we cannot measure. "gpu_order": "as_given" keeps the config's order whatever the cards. A manual "layer_split" ("24") also keeps it: the user placed the layers. #1576: the reorder is skipped when it would land the last stage on a card with less total VRAM than the one the config put there - that stage's head, @@ -2446,6 +2446,8 @@ def ordered_gpus(cfg: dict, scores=None, vrams=None) -> list[int]: sc = scores if scores is not None else (hip_speed_scores(gl) if hip else gpu_speed_scores(gl)) if not sc or any(i not in sc for i in gl): return gl + if max(sc[i] for i in gl) < 1.05 * min(sc[i] for i in gl): + return gl # #1760: cards within 5% of each other are the same card (two 5070 Ti read 1.2% apart on the clock): keep the order out = sorted(gl, key=lambda i: sc[i]) if out != gl: vram = vrams if vrams is not None else (None if scores is not None else gpu_vram_mib(gl, hip)) diff --git a/serve/test_server.py b/serve/test_server.py index 34b02a7e..c3d25d51 100644 --- a/serve/test_server.py +++ b/serve/test_server.py @@ -1631,6 +1631,8 @@ class GpuChoice(unittest.TestCase): self.assertEqual(ordered_gpus(base, fast_first), [2, 0]) self.assertEqual(ordered_gpus({"gpu": [2, 0], "args": []}, fast_first), [2, 0]) self.assertEqual(ordered_gpus(base, {0: 5.0, 2: 5.0}), [0, 2]) # identical cards + self.assertEqual(ordered_gpus(base, {0: 173740000.0, 2: 171640000.0}), [0, 2]) # #1760: two 5070 Ti, 1.2% apart + self.assertEqual(ordered_gpus(base, {0: 106.0, 2: 100.0}), [2, 0]) # 6% apart: a real difference self.assertEqual(ordered_gpus({**base, "gpu_order": "as_given"}, fast_first), [0, 2]) self.assertEqual(ordered_gpus({**base, "layer_split": "24"}, fast_first), [0, 2]) self.assertEqual(ordered_gpus({**base, "args": ["--layer-split", "24"]}, fast_first), [0, 2])