-
Notifications
You must be signed in to change notification settings - Fork 691
docs: organize sglang readme #1910
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
21 commits
Select commit
Hold shift + click to select a range
77a0f16
iter
ishandhanani bd20096
Merge branch 'main' into ishan/add-expert-dist
ishandhanani e786851
bump
ishandhanani 81a2987
revamp
ishandhanani d88ee4b
bump
ishandhanani 3f93396
bump
ishandhanani 39c6a83
go
ishandhanani ae51f31
gp
ishandhanani 878d326
ok
ishandhanani e7c0303
revert root readme
ishandhanani e2f7868
add
ishandhanani 4dcb0d1
go
ishandhanani ca5e9bb
bump
ishandhanani f802b32
bump
ishandhanani 99587cd
bump
ishandhanani 33b6a4e
bump
ishandhanani 18567a1
bump
ishandhanani b98b2c5
go
ishandhanani f6fedf3
bump
ishandhanani 5ed9998
small
ishandhanani a28f1cb
Merge branch 'main' into ishan/add-expert-dist
ishandhanani 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
5 changes: 5 additions & 0 deletions
5
examples/sglang/multinode-examples.md → examples/sglang/docs/multinode-examples.md
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,92 @@ | ||
| <!-- | ||
| 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. | ||
| --> | ||
|
|
||
| # Supporting SGLang's native endpoints via HTTP Server | ||
|
|
||
| # Introduction | ||
|
|
||
| The SGLang HTTP server provides a REST API interface for managing and monitoring SGLang components running in a dynamo distributed environment. It leverages dynamo's service discovery mechanism to automatically find and communicate with SGLang workers across the cluster. | ||
|
|
||
| ## Architecture Overview | ||
|
|
||
| The HTTP server (`sgl_http_server.py`) is built on FastAPI and integrates with dynamo's `DistributedRuntime` to discover and interact with SGLang components. It uses the following discovery flow: | ||
|
|
||
| 1. **Service Discovery**: Queries dynamo's etcd instance to find components that expose specific endpoints | ||
| 2. **Dynamic Targeting**: Automatically discovers all matching components across namespaces without requiring manual configuration | ||
| 3. **Direct Communication**: Establishes direct connections to discovered component instances using dynamo's client infrastructure | ||
|
|
||
| ## Discovery Mechanism | ||
|
|
||
| The server uses dynamo's hierarchical service discovery structure: | ||
|
|
||
| - **DistributedRuntime**: Maintains connections to etcd (service discovery) and NATS (messaging) | ||
| - **Namespace**: Logical grouping of components (default: "dynamo") | ||
| - **Component**: Individual SGLang workers or services | ||
| - **Endpoint**: Specific functionality exposed by each component | ||
|
|
||
| The discovery process queries etcd with the prefix `instances/` to find all registered components that expose the target endpoint. Components are identified by their namespace, component name, and endpoint, allowing the server to dynamically scale operations across multiple instances. | ||
|
|
||
| ## Supported Endpoints | ||
|
|
||
| ### Current Endpoints | ||
|
|
||
| #### POST /flush_cache | ||
| Flushes the radix cache across all discovered SGLang components. | ||
|
|
||
| **Behavior:** | ||
| - Discovers all components in the specified namespace that expose the `flush_cache` endpoint | ||
| - Sends flush requests to all instances of each discovered component | ||
| - Returns success/failure status with details about the operation | ||
|
|
||
| **Response:** | ||
| ```json | ||
| { | ||
| "message": "Cache flush initiated", | ||
| "success": true | ||
| } | ||
| ``` | ||
|
|
||
| ### Upcoming Endpoints | ||
|
|
||
| The following endpoints will be supported in future releases: | ||
|
|
||
| #### POST /start_expert_distribution_record | ||
| Begins recording expert distribution metrics across SGLang components. | ||
|
|
||
| #### POST /stop_expert_distribution_record | ||
| Stops the expert distribution recording process. | ||
|
|
||
| #### GET /dump_expert_distribution_record | ||
| Retrieves the collected expert distribution data. | ||
|
|
||
| ## Configuration | ||
|
|
||
| The server accepts the following command-line arguments: | ||
|
|
||
| - `--port`: HTTP server port (default: 9001) | ||
| - `--ns/--namespace`: Target dynamo namespace (default: "dynamo") | ||
| - `--comp/--component`: Specific component name to target (default: discover all) | ||
| - `--endpoint`: Endpoint name to discover (default: "flush_cache") | ||
|
|
||
| ## Usage | ||
|
|
||
| Start the server: | ||
| ```bash | ||
| python sgl_http_server.py --port 9001 --namespace dynamo | ||
| ``` | ||
|
|
||
| The server will automatically discover all SGLang components in the specified namespace and provide HTTP endpoints for managing them. |
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.