-
Notifications
You must be signed in to change notification settings - Fork 614
feat: router supporting intra-worker dp routing #1285
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
Closed
Closed
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
86c79ba
some prelim cleanups
PeaBrane 6bee243
router can route to dp ranks
PeaBrane dab052c
make the bunny hoppy
PeaBrane be6900e
Merge remote-tracking branch 'origin/main' into rupei/router-general
PeaBrane 25e1291
Merge remote-tracking branch 'origin/main' into rupei/router-general
PeaBrane 34e5c5b
new struct combining worker_id with dp_rank, dirty commit, breaks bin…
PeaBrane 2cef74c
binding works
PeaBrane 10d3326
dummy c binding note
PeaBrane 4483c68
add_class WorkerWithDpRank
PeaBrane 263c12d
renames + comments + fmt
PeaBrane 65ea6b5
allow suffix for dp_rank identification
PeaBrane a2ef896
WIP: fix fn dp_rank, add TODO's
alec-flowers e80d66c
refactor: fix bugs, kv publishing working
alec-flowers 7a733bd
fix panicing metric thread issue
alec-flowers 1bddc8e
remove verbose log
alec-flowers ee283cc
update v1 worker
alec-flowers 183a8fe
put dp_rank in PreprocessedRequest
PeaBrane be7f951
new agg config
PeaBrane e1011d8
updated comments
PeaBrane 5bf4fae
update v1 example
alec-flowers d6ded6c
final touches for it working with dp
alec-flowers 61b94ac
Merge branch 'main' into rupei/router-general
alec-flowers 9335efe
fix cost function trace
PeaBrane 931b837
fmt
PeaBrane 2a72271
Merge branch 'main' into rupei/router-general
PeaBrane eb7bb10
WIP document current work steps
alec-flowers 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
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
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
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,100 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
# Work In Progress. This is not usable currently | ||
|
||
import asyncio | ||
import logging | ||
import os | ||
import signal | ||
import socket | ||
from typing import Optional | ||
|
||
from utils.args import parse_vllm_args | ||
from vllm import run_headless | ||
from vllm.distributed.kv_events import KVEventsConfig | ||
|
||
from dynamo.sdk import service | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
BLOCK_SIZE = 16 | ||
|
||
|
||
@service( | ||
dynamo={ | ||
"enabled": True, | ||
"namespace": "dynamo", | ||
}, | ||
resources={"gpu": 1, "cpu": "10", "memory": "20Gi"}, | ||
workers=1, | ||
) | ||
class VllmHeadlessWorker: | ||
def __init__(self): | ||
class_name = self.__class__.__name__ | ||
self.engine_args = parse_vllm_args(class_name, "") | ||
self.engine_args.kv_events_config = KVEventsConfig( | ||
enable_kv_cache_events=True, publisher="zmq" | ||
) | ||
if not self.engine_args.block_size: | ||
logger.info(f"block_size not set, default to {BLOCK_SIZE}") | ||
self.engine_args.block_size = BLOCK_SIZE | ||
|
||
os.environ["VLLM_NO_USAGE_STATS"] = "1" # Avoid internal HTTP requests | ||
|
||
model_config = self.engine_args.create_model_config() | ||
self.default_sampling_params = model_config.get_diff_sampling_param() | ||
|
||
self.kv_publishers = [] | ||
|
||
signal.signal(signal.SIGTERM, self.shutdown_vllm_engine) | ||
signal.signal(signal.SIGINT, self.shutdown_vllm_engine) | ||
|
||
self.set_side_channel_host_and_port() | ||
|
||
async def async_init(self): | ||
run_headless(self.engine_args) | ||
|
||
def shutdown_vllm_engine(self, signum, frame): | ||
"""Shutdown the background loop""" | ||
logger.info(f"Received signal {signum}, shutting down") | ||
loop = asyncio.get_event_loop() | ||
try: | ||
self.engine_client.shutdown() | ||
for publisher in self.kv_publishers: | ||
publisher.shutdown() | ||
logger.info("VllmWorker shutdown complete") | ||
except Exception as e: | ||
logger.error(f"Error during shutdown: {e}") | ||
finally: | ||
loop.stop() | ||
|
||
def set_side_channel_host_and_port( | ||
self, hostname: Optional[str] = None, port: Optional[int] = None | ||
): | ||
"""vLLM V1 NixlConnector creates a side channel to exchange metadata with other NIXL connectors. | ||
This sets the port number for the side channel. | ||
""" | ||
if hostname is None: | ||
hostname = socket.gethostname() | ||
if port is None: | ||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: | ||
s.bind(("", 0)) # Bind to a free port provided by the host. | ||
port = s.getsockname()[1] # Get the port number assigned. | ||
logger.debug("Setting VLLM_NIXL_SIDE_CHANNEL_HOST to %s", hostname) | ||
os.environ["VLLM_NIXL_SIDE_CHANNEL_HOST"] = hostname | ||
logger.debug("Setting VLLM_NIXL_SIDE_CHANNEL_PORT to %s", port) | ||
os.environ["VLLM_NIXL_SIDE_CHANNEL_PORT"] = str(port) |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
V1 and prefix caching are enabled by default