From 15c474aea0b807bcd7f8fa38650cfe9b28ebf4e0 Mon Sep 17 00:00:00 2001 From: Abiba Date: Tue, 19 May 2026 18:18:00 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20select=5Fbest=5Fgpu=20respects=20candida?= =?UTF-8?q?te=20order=20=E2=80=94=20first=20non-busy=20wins?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously it picked the least-loaded GPU globally, ignoring priority order. Now it tries candidates in order: MoE → VLM → Dense. Only falls back to least-loaded when ALL candidates are busy. --- router/router.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/router/router.py b/router/router.py index f82d968..dc29ca7 100644 --- a/router/router.py +++ b/router/router.py @@ -119,7 +119,11 @@ def is_gpu_busy(model): return active >= max_c def select_best_gpu(candidates, reason): - """Pick the best GPU from candidates, preferring least-loaded.""" + """Pick the best GPU from candidates IN ORDER — first non-busy one wins.""" + for m in candidates: + if not is_gpu_busy(m): + return {"model": m, "reason": reason} + # All busy — pick least loaded best = None best_load = 999 for m in candidates: @@ -128,10 +132,7 @@ def select_best_gpu(candidates, reason): best_load = load best = m if best: - actual_reason = reason - if is_gpu_busy(best): - actual_reason = "load_balanced_" + reason - return {"model": best, "reason": actual_reason} + return {"model": best, "reason": "load_balanced_" + reason} return None def route(rd, tier):