Repository navigation
Studio tests: give managed engines ports another worker cannot be handed - #15915
Merged
danielhanchen merged 1 commit intoOct 29, 2026
Merged
Conversation
Member
Author
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
danielhanchen
deleted the
tests-engine-ports-outside-the-ephemeral-range
branch
October 29, 2026 06:45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(Python 3.13, g-r)on #15656's staging run failed a test #15656 does not touch:It passes on main when run alone.
Cause
The fake engine in that test never listens; it prints a line and sleeps. The only way
ManagedEngine._start_oncereturns instead of timing out is a200fromGET {base_url}/health.managed_engine._free_port()binds port 0, reads the port and closes the socket, so the port goes back to the ephemeral pool before the engine is spawned. Anybind(0)on the runner in that gap can be handed the same port. On a busy runner that is mostly another xdist worker's test server, and its 200 on/healthturns a start that must time out into "ready".About a dozen engine tests depend on nothing answering. A plugin that hands the released ephemeral port to a listener answering 200 (only ephemeral ports, since only those can reach another
bind(0)) fails these on main:test_a_startup_timeout_names_where_the_engine_stalledtest_rocm_engine_sees_one_device_mask_and_its_own_memory_budgettest_server_outlives_short_lived_start_threadtest_startup_deadline_counts_engine_silencetest_vllm_does_not_retry_other_failures_or_twicetest_vllm_drafter_retry_respects_an_external_stoptest_vllm_mamba_retry_respects_a_cancelled_loadtest_vllm_mamba_retry_respects_an_external_stoptest_vllm_relaunches_at_the_tightest_data_parallel_ranktest_vllm_relaunches_once_at_the_mamba_block_counttest_vllm_retries_once_without_a_drafter_that_breaks_startupFix
A backend conftest autouse fixture replaces
managed_engine._free_portduring tests. Each xdist worker gets its own block of 250 ports from 21000 up. That is below the ephemeral range on Linux (32768+), macOS and Windows (49152+), sobind(0)never hands those ports out, and two workers never share one.The two tests of the allocator itself request the new
real_engine_free_portfixture and get the real function back:test_engine_port_stays_below_the_limit_when_the_os_offers_high_portstest_only_sglang_reserves_space_for_its_derived_portNew guard,
test_the_suite_hands_engines_ports_no_other_process_can_be_given: the ports engines get in the suite are in that block. Against main's conftest it fails (43577).Verification
9258bfc732test_managed_engines.py+test_managed_engines_rocm.py,-n 8with the port-stealing pluginmanaged_engine(24 files),-n 16Cross-platform run of this branch
test_engine_ports.py+test_managed_engines_rocm.pyon the staging cross-platform legs, including the new guard:ubuntu-latest: 40 passedmacos-15: 20 passed, 20 skippedwindows-latest: 20 passed, 20 skippedThe skips are the Linux-only tests of the ROCm file.
Not changed
The product side of this: a foreign listener that answers
/healthon the port Studio picked is taken as the engine. In real use the window is milliseconds and needs another local process to bind that port in it.llama_cpp._find_free_portalready notes the same gap. A real fix would have the engine report its pid on/healthor bind the port itself, which is a separate change.