From e2d6574aa7041a6af5653012063ba5379502573d Mon Sep 17 00:00:00 2001 From: hlin99 Date: Thu, 29 Oct 2026 13:22:38 +0800 Subject: [PATCH] test: construct scheduling policies without instance registry Upcoming proxy refactors stop injecting the instance registry into scheduling policies: RoundRobinSchedulingPolicy no longer accepts a registry argument and LoadBalancedScheduler takes the model lengths as data instead of querying the backend. Make the integration tests tolerant of both API versions so the suite stays green against current main and against the refactored proxy. Signed-off-by: hlin99 --- .../1p1d_advanced/test_dual_routing.py | 6 +++--- .../1p1d_advanced/test_multi_model_routing.py | 2 +- xpyd_integration/1p1d_basic/test_proxy.py | 18 +++++++++++++++++- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/xpyd_integration/1p1d_advanced/test_dual_routing.py b/xpyd_integration/1p1d_advanced/test_dual_routing.py index 7598075..a14e3c7 100644 --- a/xpyd_integration/1p1d_advanced/test_dual_routing.py +++ b/xpyd_integration/1p1d_advanced/test_dual_routing.py @@ -126,7 +126,7 @@ def _make_dual_proxy_app(addrs, node_models): for addr in addrs.values(): reg.mark_healthy(addr) - sched = RoundRobinSchedulingPolicy(registry=reg) + sched = RoundRobinSchedulingPolicy() proxy = Proxy( prefill_instances=all_prefill, decode_instances=all_decode, @@ -288,7 +288,7 @@ async def test_all_dual_single_model(dual_nodes): reg.add("aggregated", addr, model="test-model") reg.mark_healthy(addr) - sched = RoundRobinSchedulingPolicy(registry=reg) + sched = RoundRobinSchedulingPolicy() proxy = Proxy( prefill_instances=[], decode_instances=[], @@ -404,7 +404,7 @@ async def test_randomized_deployment(dual_nodes, seed): for info in reg.get_all_instances(): reg.mark_healthy(info.address) - sched = RoundRobinSchedulingPolicy(registry=reg) + sched = RoundRobinSchedulingPolicy() proxy = Proxy( prefill_instances=all_prefill, decode_instances=all_decode, diff --git a/xpyd_integration/1p1d_advanced/test_multi_model_routing.py b/xpyd_integration/1p1d_advanced/test_multi_model_routing.py index 48cdea9..33e66e5 100644 --- a/xpyd_integration/1p1d_advanced/test_multi_model_routing.py +++ b/xpyd_integration/1p1d_advanced/test_multi_model_routing.py @@ -129,7 +129,7 @@ def _make_multi_model_proxy_app(addrs): for name in addrs: reg.mark_healthy(addrs[name]) - sched = RoundRobinSchedulingPolicy(registry=reg) + sched = RoundRobinSchedulingPolicy() proxy = Proxy( prefill_instances=all_prefill, diff --git a/xpyd_integration/1p1d_basic/test_proxy.py b/xpyd_integration/1p1d_basic/test_proxy.py index 450f90d..5c979e4 100644 --- a/xpyd_integration/1p1d_basic/test_proxy.py +++ b/xpyd_integration/1p1d_basic/test_proxy.py @@ -144,14 +144,30 @@ def test_round_robin_reservation_release_is_idempotent(): assert not runtime._active +def _make_load_balanced_policy(prefill, decode, model_lens): + """Build LoadBalancedScheduler across proxy API versions. + + Newer proxies require the model lengths to be injected, older ones query + them through the backend. Try the injection path first and fall back. + """ + model_lengths = dict(zip([*prefill, *decode], model_lens, strict=True)) + try: + return LoadBalancedScheduler( + prefill, decode, model_lengths=model_lengths + ) + except TypeError: + return LoadBalancedScheduler(prefill, decode) + + @patch( "xpyd.scheduler.load_balanced.query_instance_model_len", return_value=[131072, 131072], + create=True, ) def test_load_balanced_scheduling(mock_query): prefill = ["p1:1", "p2:2"] decode = ["d1:1", "d2:2"] - policy = LoadBalancedScheduler(prefill, decode) + policy = _make_load_balanced_policy(prefill, decode, [131072, 131072, 131072, 131072]) runtime = Scheduler() p_context = SchedulingContext(role="prefill", request_len=100, max_tokens=50)