Skip to content

Conversation

@grahamking
Copy link
Contributor

@grahamking grahamking commented Aug 4, 2025

Example:

python -m dynamo.frontend \
  --model-name Qwen3-0.6B-Q8_0.gguf \
  --model-path ~/llms/Qwen3-0.6B \
  --static-endpoint dynamo.backend.generate

The worker is any engine wrapped with @dynamo_worker(static=True) and listening on endpoint matching --static-endpoint. See lib/bindings/python/examples/hello_world/server_sglang_static.py.

Without etcd we cannot auto-discover information about the model, so we have to pass --model-name and --model-path.

For development this is also supported in dynamo-run:

  • Node 1: dynamo-run in=http out=dyn://dynamo.backend.generate --model-name Qwen3-0.6B-Q8_0.gguf --model-path ~/llms/Qwen3-0.6B
  • Node 2: dynamo-run in=dyn://dynamo.backend.generate out=llamacpp ~/llms/Qwen3-0.6B-Q8_0.gguf --static-worker --context-length 4096

Summary by CodeRabbit

  • New Features

    • Added support for "static mode" operation, allowing configuration of fixed backend endpoints without auto-discovery.
    • Introduced new command-line flags for specifying static endpoints, model names, and model paths.
    • Enabled launching static workers that do not register with etcd, improving deployment flexibility.
    • Added a new example server for SGLang with static configuration.
  • Documentation

    • Updated guides to reflect new static worker setup and revised output syntax.
    • Added detailed instructions for configuring static endpoints without etcd.
  • Refactor

    • Centralized and streamlined engine pipeline construction for improved maintainability.
  • Bug Fixes

    • Improved validation and error messages for static configuration flags.
  • Chores

    • Removed deprecated static server example in favor of updated usage.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 4, 2025

Walkthrough

This update introduces a "static mode" for Dynamo's distributed runtime, allowing the frontend and worker nodes to operate without etcd-based auto-discovery. New CLI flags and validation logic support specifying static endpoints, model names, and paths. Core engine, runtime, and entrypoint logic are extended to recognize and properly handle static configurations. Documentation and Python/Rust examples are updated to demonstrate and explain static mode usage.

Changes

Cohort / File(s) Change Summary
Frontend Static Mode & CLI Extensions
components/frontend/src/dynamo/frontend/main.py
Adds static mode support: new CLI flags (--static-endpoint, --model-name, --model-path), validation functions, and logic to initialize runtime and engine with static configuration if specified.
Python Example: Static SGLang Server
lib/bindings/python/examples/hello_world/server_sglang_static.py
New example server demonstrating static worker configuration, argument parsing, endpoint/model validation, and streaming generation endpoint.
Python Example: Legacy Static Server Removed
lib/bindings/python/examples/hello_world/server_static.py
Removes deprecated static server example.
Docs: Static Mode & Output Syntax
docs/guides/dynamo_run.md
Updates output syntax (out=auto), adds section on static workers without etcd, and documents static mode CLI usage.
Rust CLI & Flags: Static Mode
launch/dynamo-run/src/opt.rs, launch/dynamo-run/src/flags.rs, launch/dynamo-run/src/main.rs
Adds Output::Static variant, renames Dynamic to Auto, introduces static_worker flag, updates validation, parsing, and output logic for static/auto modes.
Rust Runtime & EngineConfig
launch/dynamo-run/src/lib.rs, lib/bindings/python/rust/llm/entrypoint.rs, lib/llm/src/entrypoint.rs
Updates runtime initialization for static mode, adds StaticRemote engine config, propagates is_static flag, and extends engine selection logic for static/auto modes.
Engine Preparation & Entrypoint
lib/llm/src/entrypoint/input/common.rs, lib/llm/src/entrypoint/input/endpoint.rs, lib/llm/src/entrypoint/input/http.rs
Adds support for StaticRemote engine config in engine preparation and entrypoint logic, with conditional model attachment and error handling for invalid contexts.
Engine Pipeline Refactor
lib/llm/src/discovery/watcher.rs, lib/llm/src/engines.rs
Refactors chat/completion engine construction into reusable functions, centralizing pipeline assembly for both dynamic and static routing modes.

Sequence Diagram(s)

Static Mode Engine Initialization (Frontend to Worker)

sequenceDiagram
    participant User
    participant Frontend (Static Mode)
    participant DistributedRuntime
    participant Worker (Static)
    User->>Frontend (Static Mode): Launch with --static-endpoint, --model-name, --model-path
    Frontend (Static Mode)->>DistributedRuntime: Initialize (static config)
    Frontend (Static Mode)->>Worker (Static): Route request to static endpoint
    Worker (Static)->>Frontend (Static Mode): Process/generate response
    Frontend (Static Mode)->>User: Return response
Loading

EngineConfig Selection (Rust)

sequenceDiagram
    participant CLI
    participant Flags Parser
    participant Runtime
    participant Engine Selector

    CLI->>Flags Parser: Parse CLI arguments (auto/static)
    Flags Parser->>Runtime: Initialize (static_worker flag)
    Runtime->>Engine Selector: Request EngineConfig
    Engine Selector->>Runtime: Return StaticRemote/Auto/StaticFull/StaticCore config
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~35 minutes

Poem

In static fields where endpoints dwell,
A rabbit flips a new mode’s shell.
No more discovery’s winding chase—
Just paths and names, all in their place.
With engines tuned and flags anew,
The static breeze brings something new.
🐇✨ Out=auto, and off we hop!

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (4)
docs/guides/dynamo_run.md (1)

150-153: Add language specification to fenced code block

The static analysis tool correctly identified a missing language specification for the fenced code block.

-```
+```bash
 Node 1: dynamo-run in=http out=dyn://dynamo.backend.generate --model-name Qwen3-0.6B-Q8_0.gguf --model-path ~/llms/Qwen3-0.6B
 Node 2: dynamo-run in=dyn://dynamo.backend.generate out=llamacpp ~/llms/Qwen3-0.6B-Q8_0.gguf --static-worker --context-length 4096
-```
+```
lib/llm/src/engines.rs (1)

440-524: Consider refactoring to reduce code duplication.

Both build_chat_completions and build_completions share nearly identical pipeline construction logic. While the current implementation is correct, consider extracting the common pipeline building logic into a generic helper function to improve maintainability.

The functions could share a common pipeline builder that accepts the frontend as a parameter, since that's the only component that differs between them. Would you like me to propose a refactored implementation that reduces this duplication?

lib/bindings/python/examples/hello_world/server_sglang_static.py (2)

29-36: Add type hints to Config class fields.

Consider adding type hints to improve code readability and enable better IDE support.

 class Config:
     """Command line parameters or defaults"""
 
-    namespace: str
-    component: str
-    endpoint: str
-    model: str
+    namespace: str
+    component: str
+    endpoint: str
+    model: str
+
+    def __init__(self):
+        self.namespace: str = ""
+        self.component: str = ""
+        self.endpoint: str = ""
+        self.model: str = ""

139-139: Add newline at end of file.

Add a newline character at the end of the file to follow Unix conventions.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4b8a748 and bf3c408.

📒 Files selected for processing (15)
  • components/frontend/src/dynamo/frontend/main.py (4 hunks)
  • docs/guides/dynamo_run.md (4 hunks)
  • launch/dynamo-run/src/flags.rs (4 hunks)
  • launch/dynamo-run/src/lib.rs (5 hunks)
  • launch/dynamo-run/src/main.rs (2 hunks)
  • launch/dynamo-run/src/opt.rs (3 hunks)
  • lib/bindings/python/examples/hello_world/server_sglang_static.py (1 hunks)
  • lib/bindings/python/examples/hello_world/server_static.py (0 hunks)
  • lib/bindings/python/rust/llm/entrypoint.rs (3 hunks)
  • lib/llm/src/discovery/watcher.rs (2 hunks)
  • lib/llm/src/engines.rs (2 hunks)
  • lib/llm/src/entrypoint.rs (2 hunks)
  • lib/llm/src/entrypoint/input/common.rs (5 hunks)
  • lib/llm/src/entrypoint/input/endpoint.rs (2 hunks)
  • lib/llm/src/entrypoint/input/http.rs (3 hunks)
💤 Files with no reviewable changes (1)
  • lib/bindings/python/examples/hello_world/server_static.py
🧰 Additional context used
🧠 Learnings (10)
📓 Common learnings
Learnt from: nnshah1
PR: ai-dynamo/dynamo#1444
File: tests/fault_tolerance/utils/metrics.py:30-32
Timestamp: 2025-07-01T13:55:03.940Z
Learning: The `@dynamo_worker()` decorator in the dynamo codebase returns a wrapper that automatically injects the `runtime` parameter before calling the wrapped function. This means callers only need to provide the non-runtime parameters, while the decorator handles injecting the runtime argument automatically. For example, a function with signature `async def get_metrics(runtime, log_dir)` decorated with `@dynamo_worker()` can be called as `get_metrics(log_dir)` because the decorator wrapper injects the runtime parameter.
Learnt from: GuanLuo
PR: ai-dynamo/dynamo#1371
File: examples/llm/benchmarks/vllm_multinode_setup.sh:18-25
Timestamp: 2025-06-05T01:46:15.509Z
Learning: In multi-node setups with head/worker architecture, the head node typically doesn't need environment variables pointing to its own services (like NATS_SERVER, ETCD_ENDPOINTS) because local processes can access them via localhost. Only worker nodes need these environment variables to connect to the head node's external IP address.
Learnt from: fsaady
PR: ai-dynamo/dynamo#1730
File: examples/sglang/slurm_jobs/scripts/worker_setup.py:230-244
Timestamp: 2025-07-03T10:14:30.570Z
Learning: In examples/sglang/slurm_jobs/scripts/worker_setup.py, background processes (like nats-server, etcd) are intentionally left running even if later processes fail. This design choice allows users to manually connect to nodes and debug issues without having to restart the entire SLURM job from scratch, providing operational flexibility for troubleshooting in cluster environments.
📚 Learning: the asyncenginecontextprovider trait in lib/runtime/src/engine.rs was intentionally changed from `se...
Learnt from: ryanolson
PR: ai-dynamo/dynamo#1919
File: lib/runtime/src/engine.rs:168-168
Timestamp: 2025-07-14T21:25:56.930Z
Learning: The AsyncEngineContextProvider trait in lib/runtime/src/engine.rs was intentionally changed from `Send + Sync + Debug` to `Send + Debug` because the Sync bound was overly constraining. The trait should only require Send + Debug as designed.

Applied to files:

  • lib/bindings/python/rust/llm/entrypoint.rs
  • lib/llm/src/entrypoint/input/http.rs
  • lib/llm/src/entrypoint/input/endpoint.rs
  • lib/llm/src/entrypoint.rs
  • lib/llm/src/entrypoint/input/common.rs
  • launch/dynamo-run/src/lib.rs
  • lib/llm/src/engines.rs
📚 Learning: the `@dynamo_worker()` decorator in the dynamo codebase returns a wrapper that automatically injects...
Learnt from: nnshah1
PR: ai-dynamo/dynamo#1444
File: tests/fault_tolerance/utils/metrics.py:30-32
Timestamp: 2025-07-01T13:55:03.940Z
Learning: The `@dynamo_worker()` decorator in the dynamo codebase returns a wrapper that automatically injects the `runtime` parameter before calling the wrapped function. This means callers only need to provide the non-runtime parameters, while the decorator handles injecting the runtime argument automatically. For example, a function with signature `async def get_metrics(runtime, log_dir)` decorated with `@dynamo_worker()` can be called as `get_metrics(log_dir)` because the decorator wrapper injects the runtime parameter.

Applied to files:

  • docs/guides/dynamo_run.md
  • launch/dynamo-run/src/lib.rs
📚 Learning: in examples/sglang/slurm_jobs/scripts/worker_setup.py, background processes (like nats-server, etcd)...
Learnt from: fsaady
PR: ai-dynamo/dynamo#1730
File: examples/sglang/slurm_jobs/scripts/worker_setup.py:230-244
Timestamp: 2025-07-03T10:14:30.570Z
Learning: In examples/sglang/slurm_jobs/scripts/worker_setup.py, background processes (like nats-server, etcd) are intentionally left running even if later processes fail. This design choice allows users to manually connect to nodes and debug issues without having to restart the entire SLURM job from scratch, providing operational flexibility for troubleshooting in cluster environments.

Applied to files:

  • docs/guides/dynamo_run.md
📚 Learning: in multi-node setups with head/worker architecture, the head node typically doesn't need environment...
Learnt from: GuanLuo
PR: ai-dynamo/dynamo#1371
File: examples/llm/benchmarks/vllm_multinode_setup.sh:18-25
Timestamp: 2025-06-05T01:46:15.509Z
Learning: In multi-node setups with head/worker architecture, the head node typically doesn't need environment variables pointing to its own services (like NATS_SERVER, ETCD_ENDPOINTS) because local processes can access them via localhost. Only worker nodes need these environment variables to connect to the head node's external IP address.

Applied to files:

  • docs/guides/dynamo_run.md
📚 Learning: in lib/llm/src/kv_router/scoring.rs, the user prefers to keep the panic behavior when calculating lo...
Learnt from: PeaBrane
PR: ai-dynamo/dynamo#1285
File: lib/llm/src/kv_router/scoring.rs:58-63
Timestamp: 2025-05-30T06:38:09.630Z
Learning: In lib/llm/src/kv_router/scoring.rs, the user prefers to keep the panic behavior when calculating load_avg and variance with empty endpoints rather than adding guards for division by zero. They want the code to fail fast on this error condition.

Applied to files:

  • lib/llm/src/entrypoint/input/endpoint.rs
📚 Learning: in lib/runtime/src/component/client.rs, the current mutex usage in get_or_create_dynamic_instance_so...
Learnt from: grahamking
PR: ai-dynamo/dynamo#1962
File: lib/runtime/src/component/client.rs:270-273
Timestamp: 2025-07-16T12:41:12.543Z
Learning: In lib/runtime/src/component/client.rs, the current mutex usage in get_or_create_dynamic_instance_source is temporary while evaluating whether the mutex can be dropped entirely. The code currently has a race condition between try_lock and lock().await, but this is acknowledged as an interim state during the performance optimization process.

Applied to files:

  • lib/llm/src/entrypoint/input/common.rs
  • launch/dynamo-run/src/lib.rs
📚 Learning: in lib/llm/src/kv_router/scoring.rs, peabrane prefers panic-based early failure over result-based er...
Learnt from: PeaBrane
PR: ai-dynamo/dynamo#1392
File: lib/llm/src/kv_router/scoring.rs:35-46
Timestamp: 2025-06-05T01:02:15.318Z
Learning: In lib/llm/src/kv_router/scoring.rs, PeaBrane prefers panic-based early failure over Result-based error handling for the worker_id() method to catch invalid data early during development.

Applied to files:

  • launch/dynamo-run/src/flags.rs
📚 Learning: in lib/llm/src/kv_router/publisher.rs, the functions `create_stored_blocks` and `create_stored_block...
Learnt from: alec-flowers
PR: ai-dynamo/dynamo#1181
File: lib/llm/src/kv_router/publisher.rs:379-425
Timestamp: 2025-05-29T00:02:35.018Z
Learning: In lib/llm/src/kv_router/publisher.rs, the functions `create_stored_blocks` and `create_stored_block_from_parts` are correctly implemented and not problematic duplications of existing functionality elsewhere in the codebase.

Applied to files:

  • lib/llm/src/engines.rs
  • lib/llm/src/discovery/watcher.rs
📚 Learning: the codebase uses async-nats version 0.40, not the older nats crate. error handling should use async...
Learnt from: kthui
PR: ai-dynamo/dynamo#1424
File: lib/runtime/src/pipeline/network/egress/push_router.rs:204-209
Timestamp: 2025-06-13T22:07:24.843Z
Learning: The codebase uses async-nats version 0.40, not the older nats crate. Error handling should use async_nats::error::Error variants, not nats::Error variants.

Applied to files:

  • lib/llm/src/engines.rs
  • lib/llm/src/discovery/watcher.rs
🪛 markdownlint-cli2 (0.17.2)
docs/guides/dynamo_run.md

150-150: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Build and Test - vllm
  • GitHub Check: pre-merge-rust (lib/runtime/examples)
  • GitHub Check: pre-merge-rust (.)
  • GitHub Check: pre-merge-rust (lib/bindings/python)
🔇 Additional comments (16)
lib/bindings/python/rust/llm/entrypoint.rs (1)

26-26: LGTM: Static engine type addition

The new Static = 4 variant properly extends the EngineType enum to support static workers.

lib/llm/src/entrypoint/input/endpoint.rs (2)

45-62: LGTM: Conditional model attachment for static configurations

The conditional model attachment logic correctly prevents static workers from registering with etcd when is_static is true. This aligns with the PR objective of supporting workers without etcd dependency.


91-93: LGTM: Appropriate error handling for StaticRemote

The panic with a clear error message correctly prevents misuse of StaticRemote configurations in endpoint contexts, as these are intended only for frontend nodes.

docs/guides/dynamo_run.md (2)

96-96: LGTM: Consistent documentation updates for output parameter changes

The replacement of out=dyn with out=auto throughout the documentation correctly reflects the CLI changes and maintains consistency.

Also applies to: 144-144, 208-208, 583-583


146-156: LGTM: Clear documentation for static worker functionality

The new section provides excellent documentation for the static worker feature, including:

  • Clear examples for both frontend and worker nodes
  • Explanation of the trade-offs (no etcd dependency vs manual configuration)
  • Required parameters for static mode

This will help users understand when and how to use static workers.

lib/llm/src/entrypoint.rs (3)

39-40: LGTM: StaticRemote variant addition

The new StaticRemote variant properly represents remote networked engines known at startup, complementing the existing Dynamic variant for etcd-discovered engines. The documentation comment clearly explains the distinction.


46-46: LGTM: is_static field addition

The addition of the is_static boolean field to StaticFull and StaticCore variants enables proper differentiation between static and dynamic configurations within these engine types.

Also applies to: 53-53


62-62: LGTM: local_model method update

The local_model method correctly handles the new StaticRemote variant, maintaining consistency with the existing pattern matching.

launch/dynamo-run/src/main.rs (2)

27-27: LGTM: Updated usage string for new output options

The usage string correctly reflects the new auto and static endpoint (dyn://<path>) output options, as well as the new --static-worker flag. This provides clear guidance to users on the available options.


137-137: LGTM: Updated dynamic output detection

The logic correctly identifies both Output::Auto and Output::Static(_) as dynamic outputs since both utilize the distributed runtime, distinguishing them from local engine outputs.

lib/llm/src/entrypoint/input/http.rs (1)

52-89: LGTM! Clean implementation of static remote engine support.

The static remote configuration properly initializes the distributed runtime, retrieves the endpoint client, and builds the necessary engines. The conditional KV chooser creation based on router mode is handled correctly.

launch/dynamo-run/src/opt.rs (1)

15-22: Clear documentation and naming improvements.

The rename from Dynamic to Auto better describes the auto-discovery behavior, and the new Static variant is well-documented with its requirements clearly stated.

lib/llm/src/discovery/watcher.rs (1)

204-233: Excellent refactoring to centralize engine construction.

The extraction of pipeline construction logic to the engines module helper functions reduces code duplication and improves maintainability. The KV chooser logic is correctly preserved and shared between both engines.

launch/dynamo-run/src/lib.rs (1)

102-146: LGTM! Consistent implementation of static engine support.

The changes properly handle the new Output::Auto and Output::Static variants, and consistently set the is_static field across all engine configurations based on the static_worker flag.

lib/llm/src/entrypoint/input/common.rs (1)

94-140: LGTM! Well-structured implementation of StaticRemote engine configuration.

The implementation properly:

  • Initializes distributed runtime with static configuration
  • Handles KV routing mode with appropriate chooser creation
  • Uses the centralized engine building helper
  • Provides clear logging for debugging
components/frontend/src/dynamo/frontend/main.py (1)

39-67: LGTM! Robust validation for static mode arguments.

The validation functions properly ensure:

  • Static endpoints follow the required namespace.component.endpoint format
  • Model names are non-empty strings
  • Model paths point to existing directories

Example:
```
python -m dynamo.frontend \
  --model-name Qwen3-0.6B-Q8_0.gguf
  --model-path ~/llms/Qwen3-0.6B \
  --static-endpoint dynamo.backend.generate
```

The worker is any engine built with `@dynamo_worker(static=True)` and
listening on endpoint matching `--static-endpoint`. See
`lib/bindings/python/examples/hello_world/server_sglang_static.py`.

Without etcd we cannot auto-discover information about the model, so we
have to pass `--model-name` and `--model-path`.

For development this is also supported in `dynamo-run`:
- Node 1: `dynamo-run in=http out=dyn://dynamo.backend.generate --model-name Qwen3-0.6B-Q8_0.gguf --model-path ~/llms/Qwen3-0.6B`
- Node 2: `dynamo-run in=dyn://dynamo.backend.generate out=llamacpp ~/llms/Qwen3-0.6B-Q8_0.gguf --static-worker --context-length 4096`
@grahamking grahamking disabled auto-merge August 6, 2025 00:04
@grahamking grahamking merged commit 6a1a801 into main Aug 6, 2025
14 of 15 checks passed
@grahamking grahamking deleted the gk-remote-static branch August 6, 2025 13:51
@biswapanda
Copy link
Contributor

Lgtm - it's already merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants