Repository navigation
[Serve] Make gang scheduling tests avoid handle-based placement checks - #64345
abrarsheikh merged 4 commits into
Conversation
Signed-off-by: wanadzhar913 <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request refactors tests in test_deployment_scheduler_downscale.py and test_gang_scheduling.py to verify replica states and counts directly via controller state and serve.status() rather than relying on handle routing, which can be affected by locality routing. Feedback on these changes suggests handling potential KeyError exceptions in the newly added _wait_until_running_replicas helper to prevent premature test failures when applications or deployments are not yet registered in serve.status().
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
why does #63629 change the test behavior should the default still be prefer local routing to False? |
Signed-off-by: abrar <[email protected]> # Conflicts: # python/ray/serve/tests/test_deployment_scheduler_downscale.py
test_gang_context inferred gang membership by looping up to 100 handle.remote() calls until it observed all 4 replicas. Under locality-aware routing (parameterized in ray-project#63629) this loop only hits local replicas and never sees all gangs, so it would undercount like the other handle-based placement checks this PR converts. Read the GangContext from controller replica state instead. The controller stores the exact GangContext each replica reports from its own ReplicaContext (round-tripped via initialize_and_get_metadata), so this verifies the same values deterministically without depending on request routing. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Signed-off-by: abrar <[email protected]>
Several loops still infer placement/gang structure through handle routing. Add comments explaining why each is safe under locality-aware routing so they are not mistaken for the pattern this PR converts: - PACK strategy node check: asserts all replicas share one node; routing can only surface a subset of nodes, so it cannot inflate the count. - Placement-group info checks: each response is a self-contained per-replica invariant, so sampling any subset is sufficient. - Startup-failure and health-failure gang discovery: single-node clusters (ray.init(num_cpus=1)), so every replica is local and locality routing still reaches all of them. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Signed-off-by: abrar <[email protected]>
ef683d6 to
e699782
Compare
|
Hi there, abrarsheikh. Many apologies for not being able to work on this the past week, and for missing your question. Tysm for helping me unblock myself! |
jeffreywang88
left a comment
There was a problem hiding this comment.
LGTM, thanks for making the tests more robust!
ray-project#64345) ## Summary Several gang scheduling tests inferred replica placement by issuing repeated `DeploymentHandle` calls and counting the distinct nodes / gangs / replicas observed in the responses. Request routing is not a scheduler-state API: with locality-aware routing (added per-deployment and parameterized in ray-project#63629), repeated calls may legitimately prefer local replicas, so these tests can undercount nodes, gangs, or replicas even when scheduler state is correct. This PR makes the tests read placement directly from controller replica state instead of inferring it from handle responses. ## Changes In `test_gang_scheduling.py`: - Add helpers to read RUNNING replicas (and their node / gang IDs) from controller state. - Verify placement via controller state in `test_incomplete_deployment`, `test_gang_scheduling_spread_strategy`, `test_gang_context`, `test_scale_gang_boundary`, and `test_gang_migration`. - Keep handle calls where the test checks request serving or zero-downtime, and add comments documenting the remaining handle-based loops that are safe under locality routing (PACK / placement-group invariant checks, single-node discovery). Note: the originally-planned `test_deployment_scheduler_downscale.py` change was dropped — ray-project#64325 already converted that test to controller-state waiting on master. ## Related issues - Related to ray-project#59929 - Depends on / unblocks ray-project#63629 ## Tests ```bash pytest python/ray/serve/tests/test_gang_scheduling.py -q ``` --------- Signed-off-by: wanadzhar913 <[email protected]> Signed-off-by: abrar <[email protected]> Co-authored-by: abrar <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]> Signed-off-by: 400Ping <[email protected]>
Summary
Several gang scheduling tests inferred replica placement by issuing repeated
DeploymentHandlecalls and counting the distinct nodes / gangs / replicasobserved in the responses. Request routing is not a scheduler-state API: with
locality-aware routing (added per-deployment and parameterized in #63629),
repeated calls may legitimately prefer local replicas, so these tests can
undercount nodes, gangs, or replicas even when scheduler state is correct.
This PR makes the tests read placement directly from controller replica state
instead of inferring it from handle responses.
Changes
In
test_gang_scheduling.py:controller state.
test_incomplete_deployment,test_gang_scheduling_spread_strategy,test_gang_context,test_scale_gang_boundary, andtest_gang_migration.add comments documenting the remaining handle-based loops that are safe under
locality routing (PACK / placement-group invariant checks, single-node
discovery).
Note: the originally-planned
test_deployment_scheduler_downscale.pychange wasdropped — #64325 already converted that test to controller-state waiting on
master.
Related issues
Tests