-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat(router): add dynamic worker taint updates #12620
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
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
39bf101
feat(router): add dynamic worker taint updates
tmonty12 4408ee5
fix(router): scope taint updates to base model
tmonty12 c8bfeba
fix(backends): expose model taint update route
tmonty12 28e3c02
fix(discovery): scope model taint update events
tmonty12 2eac0fc
fix(discovery): address dynamic taint review
tmonty12 7bdb6aa
fix(backend): register model taint updates in common worker
tmonty12 05ad60f
test(router): cover dynamic model taint updates
tmonty12 80b070b
style(bindings): apply rustfmt to taint test
tmonty12 13b8a03
fix(sglang): reserve model taint update route
tmonty12 d500fa5
fix(runtime): harden discovery taint updates
tmonty12 0044445
style(sglang): sort model taint imports
tmonty12 bf77a5c
fix(router): address worker taint review feedback
tmonty12 98af87b
fix(ci): update runtime examples lockfile
tmonty12 043a449
fix(ci): update kvbm bindings lockfile
tmonty12 e97fcee
fix(ci): update python bindings lockfile
tmonty12 c6ab547
fix(runtime): address model taint review feedback
tmonty12 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,44 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """Worker-local HTTP route for updating model routing taints.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import Any | ||
|
|
||
| from dynamo.llm import update_model_taints | ||
| from dynamo.runtime import DistributedRuntime, Endpoint | ||
|
|
||
| MODEL_TAINT_ROUTE = "update/model_taints" | ||
| TOPOLOGY_TAINT_PREFIX = "dynamo.topology/" | ||
|
|
||
|
|
||
| def register_model_taint_route(runtime: DistributedRuntime, endpoint: Endpoint) -> None: | ||
| """Register POST /engine/update/model_taints on the system status server.""" | ||
|
|
||
| async def _update_model_taints(body: dict[str, Any]) -> dict[str, Any]: | ||
| if not isinstance(body, dict): | ||
| raise ValueError("request body must be a JSON object") | ||
|
|
||
| taints = body.get("taints") | ||
| if not isinstance(taints, list) or not all( | ||
| isinstance(taint, str) for taint in taints | ||
| ): | ||
| raise ValueError("'taints' must be a JSON array of strings") | ||
| if reserved := next( | ||
| (taint for taint in taints if taint.startswith(TOPOLOGY_TAINT_PREFIX)), | ||
| None, | ||
| ): | ||
| raise ValueError( | ||
| f"taint '{reserved}' uses reserved prefix '{TOPOLOGY_TAINT_PREFIX}'" | ||
| ) | ||
|
|
||
| unique_taints = set(taints) | ||
| await update_model_taints(endpoint, unique_taints) | ||
| return { | ||
| "status": "ok", | ||
| "taints": sorted(unique_taints), | ||
| } | ||
|
|
||
| runtime.register_engine_route(MODEL_TAINT_ROUTE, _update_model_taints) | ||
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,62 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import asyncio | ||
| from unittest.mock import AsyncMock | ||
|
|
||
| import pytest | ||
|
|
||
| from dynamo.common import model_taints | ||
|
|
||
| pytestmark = [pytest.mark.pre_merge, pytest.mark.unit, pytest.mark.gpu_0] | ||
|
|
||
|
|
||
| class _Runtime: | ||
| def __init__(self) -> None: | ||
| self.route_name: str | None = None | ||
| self.handler = None | ||
|
|
||
| def register_engine_route(self, name, handler) -> None: | ||
| self.route_name = name | ||
| self.handler = handler | ||
|
|
||
|
|
||
| def test_model_taint_route_updates_worker(monkeypatch: pytest.MonkeyPatch) -> None: | ||
| update = AsyncMock() | ||
| monkeypatch.setattr(model_taints, "update_model_taints", update) | ||
| runtime = _Runtime() | ||
| endpoint = object() | ||
|
|
||
| model_taints.register_model_taint_route(runtime, endpoint) | ||
|
|
||
| assert runtime.route_name == "update/model_taints" | ||
| response = asyncio.run( | ||
| runtime.handler({"taints": ["capacity/fast", "capacity/fast"]}) | ||
| ) | ||
| assert response == { | ||
| "status": "ok", | ||
| "taints": ["capacity/fast"], | ||
| } | ||
| update.assert_awaited_once_with(endpoint, {"capacity/fast"}) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| ("body", "message"), | ||
| [ | ||
| ({}, "'taints' must be a JSON array of strings"), | ||
| ({"taints": "fast"}, "'taints' must be a JSON array of strings"), | ||
| ({"taints": [1]}, "'taints' must be a JSON array of strings"), | ||
| ( | ||
| {"taints": ["dynamo.topology/zone=west"]}, | ||
| "uses reserved prefix 'dynamo.topology/'", | ||
| ), | ||
| ], | ||
| ) | ||
| def test_model_taint_route_rejects_invalid_requests(body, message) -> None: | ||
| runtime = _Runtime() | ||
| model_taints.register_model_taint_route(runtime, object()) | ||
|
|
||
| with pytest.raises(ValueError, match=message): | ||
| asyncio.run(runtime.handler(body)) |
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.