-
Notifications
You must be signed in to change notification settings - Fork 49
fix: serialize concurrent vLLM engine startup #282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+59
−4
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import multiprocessing | ||
| import os | ||
|
|
||
| import pytest | ||
|
|
||
| from twinkle.utils.parallel import PosixFileLock | ||
|
|
||
|
|
||
| def _hold_startup_lock(lock_path: str, acquired, release) -> None: | ||
| with PosixFileLock(lock_path): | ||
| acquired.set() | ||
| if not release.wait(timeout=5): | ||
| raise TimeoutError('test did not release vLLM startup lock') | ||
|
|
||
|
|
||
| def _acquire_startup_lock(lock_path: str, started, acquired) -> None: | ||
| started.set() | ||
| with PosixFileLock(lock_path): | ||
| acquired.set() | ||
|
|
||
|
|
||
| @pytest.mark.skipif(os.name == 'nt', reason='vLLM startup lock requires fcntl') | ||
| def test_vllm_engine_startup_is_serialized(tmp_path): | ||
| """Concurrent local sampler actors must not race vLLM's free-port probe.""" | ||
| context = multiprocessing.get_context('spawn') | ||
| lock_path = str(tmp_path / 'vllm-engine-init.lock') | ||
| first_acquired = context.Event() | ||
| release_first = context.Event() | ||
| second_started = context.Event() | ||
| second_acquired = context.Event() | ||
| first = context.Process(target=_hold_startup_lock, args=(lock_path, first_acquired, release_first)) | ||
| second = context.Process(target=_acquire_startup_lock, args=(lock_path, second_started, second_acquired)) | ||
|
|
||
| try: | ||
| first.start() | ||
| assert first_acquired.wait(timeout=5) | ||
|
|
||
| second.start() | ||
| assert second_started.wait(timeout=5) | ||
| assert not second_acquired.wait(timeout=0.2) | ||
|
|
||
| release_first.set() | ||
| assert second_acquired.wait(timeout=5) | ||
| finally: | ||
| release_first.set() | ||
| for process in (first, second): | ||
| process.join(timeout=5) | ||
| if process.is_alive(): | ||
| process.terminate() | ||
| process.join(timeout=5) | ||
|
|
||
| assert first.exitcode == 0 | ||
| assert second.exitcode == 0 | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.