You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "tvalentyn (via GitHub)" <gi...@apache.org> on 2025/06/11 01:16:16 UTC

[PR] Allow only one thread at a time to start the VLLM server. [beam]

tvalentyn opened a new pull request, #35234:
URL: https://github.com/apache/beam/pull/35234

   **Please** add a meaningful description for your change here
   
   ------------------------
   
   Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
   
    - [ ] Mention the appropriate issue in your description (for example: `addresses #123`), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment `fixes #<ISSUE NUMBER>` instead.
    - [ ] Update `CHANGES.md` with noteworthy changes.
    - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://github.com/apache/beam/blob/master/CONTRIBUTING.md#make-the-reviewers-job-easier).
   
   To check the build health, please visit [https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md)
   
   GitHub Actions Tests Status (on master branch)
   ------------------------------------------------------------------------------------------------
   [![Build python source distribution and wheels](https://github.com/apache/beam/actions/workflows/build_wheels.yml/badge.svg?event=schedule&&?branch=master)](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
   [![Python tests](https://github.com/apache/beam/actions/workflows/python_tests.yml/badge.svg?event=schedule&&?branch=master)](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
   [![Java tests](https://github.com/apache/beam/actions/workflows/java_tests.yml/badge.svg?event=schedule&&?branch=master)](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
   [![Go tests](https://github.com/apache/beam/actions/workflows/go_tests.yml/badge.svg?event=schedule&&?branch=master)](https://github.com/apache/beam/actions?query=workflow%3A%22Go+tests%22+branch%3Amaster+event%3Aschedule)
   
   See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more information about GitHub Actions CI or the [workflows README](https://github.com/apache/beam/blob/master/.github/workflows/README.md) to see a list of phrases to trigger workflows.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Allow only one thread at a time to start the VLLM server. [beam]

Posted by "tvalentyn (via GitHub)" <gi...@apache.org>.
tvalentyn merged PR #35234:
URL: https://github.com/apache/beam/pull/35234


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Allow only one thread at a time to start the VLLM server. [beam]

Posted by "tvalentyn (via GitHub)" <gi...@apache.org>.
tvalentyn commented on PR #35234:
URL: https://github.com/apache/beam/pull/35234#issuecomment-2961033545

   R: @damccorm or @claudevdm 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Allow only one thread at a time to start the VLLM server. [beam]

Posted by "tvalentyn (via GitHub)" <gi...@apache.org>.
tvalentyn commented on code in PR #35234:
URL: https://github.com/apache/beam/pull/35234#discussion_r2139191584


##########
sdks/python/apache_beam/ml/inference/vllm_inference.py:
##########
@@ -114,28 +114,30 @@ def __init__(self, model_name: str, vllm_server_kwargs: dict[str, str]):
     self._server_started = False
     self._server_process = None
     self._server_port: int = -1
+    self._server_process_lock = threading.RLock()

Review Comment:
   When `large_model=true`, multiple processes share the server through a single server handle shared across processes, and only one process is responsible for managing the handle.
   
   The problem is that right now we call `check_connectivity`  from an async method: https://github.com/apache/beam/blob/de76cfa16d36e2cb8dd1a1092710f0cd477e0f8d/sdks/python/apache_beam/ml/inference/vllm_inference.py#L219 and `check_connectivity` happens to also start the server if the process already terminated, so as a result we create many processes at once (see internal: b/422577332), and overwrite `self._server_process`.
   
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Allow only one thread at a time to start the VLLM server. [beam]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #35234:
URL: https://github.com/apache/beam/pull/35234#issuecomment-2961034797

   Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment `assign set of reviewers`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Allow only one thread at a time to start the VLLM server. [beam]

Posted by "tvalentyn (via GitHub)" <gi...@apache.org>.
tvalentyn commented on code in PR #35234:
URL: https://github.com/apache/beam/pull/35234#discussion_r2139191584


##########
sdks/python/apache_beam/ml/inference/vllm_inference.py:
##########
@@ -114,28 +114,30 @@ def __init__(self, model_name: str, vllm_server_kwargs: dict[str, str]):
     self._server_started = False
     self._server_process = None
     self._server_port: int = -1
+    self._server_process_lock = threading.RLock()

Review Comment:
   When `large_model=true`, multiple processes share the server through a single server handle shared across processes, and only one process is responsible for managing the handle.
   
   The problem is that right now we call `check_connectivity`  from an async method: https://github.com/apache/beam/blob/de76cfa16d36e2cb8dd1a1092710f0cd477e0f8d/sdks/python/apache_beam/ml/inference/vllm_inference.py#L219 and `check_connectivity` happens to also start the server if the process already terminated, so as a result we create many processes at once (see internal: b/422577332), and overwrite `self._server_process`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Allow only one thread at a time to start the VLLM server. [beam]

Posted by "tvalentyn (via GitHub)" <gi...@apache.org>.
tvalentyn commented on code in PR #35234:
URL: https://github.com/apache/beam/pull/35234#discussion_r2139191584


##########
sdks/python/apache_beam/ml/inference/vllm_inference.py:
##########
@@ -114,28 +114,30 @@ def __init__(self, model_name: str, vllm_server_kwargs: dict[str, str]):
     self._server_started = False
     self._server_process = None
     self._server_port: int = -1
+    self._server_process_lock = threading.RLock()

Review Comment:
   When large_model=true, multiple processes share the server through a single server handle shared across processes, and only one process is responsible for managing the handle.
   
   The problem is that right now we call `check_connectivity`  from an async method: https://github.com/apache/beam/blob/de76cfa16d36e2cb8dd1a1092710f0cd477e0f8d/sdks/python/apache_beam/ml/inference/vllm_inference.py#L219 and `check_connectivity` happens to also start the server if the process already terminated, so as a result we create many processes at once (see internal: b/422577332), and overwrite `self._server_process`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Allow only one thread at a time to start the VLLM server. [beam]

Posted by "tvalentyn (via GitHub)" <gi...@apache.org>.
tvalentyn commented on code in PR #35234:
URL: https://github.com/apache/beam/pull/35234#discussion_r2139191584


##########
sdks/python/apache_beam/ml/inference/vllm_inference.py:
##########
@@ -114,28 +114,30 @@ def __init__(self, model_name: str, vllm_server_kwargs: dict[str, str]):
     self._server_started = False
     self._server_process = None
     self._server_port: int = -1
+    self._server_process_lock = threading.RLock()

Review Comment:
   When `large_model=true`, multiple processes share the server through a single server handle shared across processes, and only one process is responsible for managing the handle. The cross-process lock should not be necessary.
   
   The problem is that right now we call `check_connectivity`  from an async method: https://github.com/apache/beam/blob/de76cfa16d36e2cb8dd1a1092710f0cd477e0f8d/sdks/python/apache_beam/ml/inference/vllm_inference.py#L219 and `check_connectivity` happens to also start the server if the process already terminated, so as a result we create many processes at once (see internal: b/422577332), and overwrite `self._server_process`.
   
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Allow only one thread at a time to start the VLLM server. [beam]

Posted by "claudevdm (via GitHub)" <gi...@apache.org>.
claudevdm commented on code in PR #35234:
URL: https://github.com/apache/beam/pull/35234#discussion_r2140136315


##########
sdks/python/apache_beam/ml/inference/vllm_inference.py:
##########
@@ -114,28 +114,30 @@ def __init__(self, model_name: str, vllm_server_kwargs: dict[str, str]):
     self._server_started = False
     self._server_process = None
     self._server_port: int = -1
+    self._server_process_lock = threading.RLock()

Review Comment:
   Makes sense. Thanks



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Allow only one thread at a time to start the VLLM server. [beam]

Posted by "claudevdm (via GitHub)" <gi...@apache.org>.
claudevdm commented on code in PR #35234:
URL: https://github.com/apache/beam/pull/35234#discussion_r2139070201


##########
sdks/python/apache_beam/ml/inference/vllm_inference.py:
##########
@@ -114,28 +114,30 @@ def __init__(self, model_name: str, vllm_server_kwargs: dict[str, str]):
     self._server_started = False
     self._server_process = None
     self._server_port: int = -1
+    self._server_process_lock = threading.RLock()

Review Comment:
   What happens when multiple threads try to start the server at the same time? Should we use a cross process lock since multiple processes also share the server?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Allow only one thread at a time to start the VLLM server. [beam]

Posted by "tvalentyn (via GitHub)" <gi...@apache.org>.
tvalentyn commented on code in PR #35234:
URL: https://github.com/apache/beam/pull/35234#discussion_r2139191584


##########
sdks/python/apache_beam/ml/inference/vllm_inference.py:
##########
@@ -114,28 +114,30 @@ def __init__(self, model_name: str, vllm_server_kwargs: dict[str, str]):
     self._server_started = False
     self._server_process = None
     self._server_port: int = -1
+    self._server_process_lock = threading.RLock()

Review Comment:
   When large_model=true, multiple processes share the server through a single server handle shared across processes, and only one process is responsible for managing the handle.
   
   The problem is that right now we call `check_connectivity`  from an async method: https://github.com/apache/beam/blob/de76cfa16d36e2cb8dd1a1092710f0cd477e0f8d/sdks/python/apache_beam/ml/inference/vllm_inference.py#L219 and check_connectivity happens to also start the server if it's unresponsive, so as a result we create many processes at once (see internal: b/422577332), and ovewrite `self._server_process`



##########
sdks/python/apache_beam/ml/inference/vllm_inference.py:
##########
@@ -114,28 +114,30 @@ def __init__(self, model_name: str, vllm_server_kwargs: dict[str, str]):
     self._server_started = False
     self._server_process = None
     self._server_port: int = -1
+    self._server_process_lock = threading.RLock()

Review Comment:
   When large_model=true, multiple processes share the server through a single server handle shared across processes, and only one process is responsible for managing the handle.
   
   The problem is that right now we call `check_connectivity`  from an async method: https://github.com/apache/beam/blob/de76cfa16d36e2cb8dd1a1092710f0cd477e0f8d/sdks/python/apache_beam/ml/inference/vllm_inference.py#L219 and check_connectivity happens to also start the server if it's unresponsive, so as a result we create many processes at once (see internal: b/422577332), and overwrite `self._server_process`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org