Skip to content

Conversation

@kthui
Copy link
Contributor

@kthui kthui commented Jul 22, 2025

Overview:

Complete the documentations for the Request Migration feature, and update max_tokens on migrated requests accounting for responses already generated.

Details:

  • Add --migration-limit flag to dynamo-run --help.
  • Add Request Migration section to dynamo_run.md.
  • Log migration messages as warning instead of info.
  • Subtract from max_tokens for responses already generated during migration.
  • Unit test for the subtraction.
  • Add --migration-limit flag to vllm, trtllm, sglang and llama_cpp backends and their READMEs.

Where should the reviewer start?

Start with the documentation changes first, and then look at the max_tokens subtraction feature and then the updated unit test.

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

N/A

Summary by CodeRabbit

  • New Features

    • Added support for a new migration limit option, allowing configuration of how many times a request may be migrated to another engine in case of connectivity issues.
    • Enhanced documentation with a new section explaining fault tolerance and request migration, including example usage of the migration limit option.
  • Bug Fixes

    • Improved tracking of token limits during request migration to ensure correct behavior when retrying requests.
  • Documentation

    • Updated guides to include detailed information on fault tolerance, request migration, and the new migration limit option.
  • Style

    • Increased logging severity for stream disconnection and retry events to improve error visibility.

@kthui kthui self-assigned this Jul 22, 2025
@kthui kthui requested a review from a team as a code owner July 22, 2025 01:42
@copy-pr-bot
Copy link

copy-pr-bot bot commented Jul 22, 2025

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions bot added the docs label Jul 22, 2025
@kthui kthui changed the title docs: Add Request Migration docs and minor feature enhancements docs: Add Request Migration docs and minor enhancements Jul 22, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 22, 2025

Walkthrough

This update introduces a new --migration-limit command-line flag to the Worker Engine, updates documentation to explain fault tolerance and request migration, and enhances the migration logic by adjusting log levels and dynamically tracking token limits during streaming retries. Related tests are updated to validate the new behavior.

Changes

File(s) Change Summary
docs/guides/dynamo_run.md Added documentation section on "Fault Tolerance and Request Migration" and example usage for new flag.
launch/dynamo-run/src/main.rs Updated usage string to include the --migration-limit=0 flag.
lib/llm/src/migration.rs (+ tests) Changed log levels to warn, improved error comments, added dynamic token tracking in retries, updated test helpers and assertions for token limits.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant HTTP_Server
    participant Worker_Engine_A
    participant Worker_Engine_B

    Client->>HTTP_Server: Send request
    HTTP_Server->>Worker_Engine_A: Forward request
    alt Connectivity failure on Worker_Engine_A
        HTTP_Server->>Worker_Engine_B: Migrate request (if migration-limit not reached)
        Worker_Engine_B->>HTTP_Server: Continue processing (with updated max_tokens)
    end
    HTTP_Server->>Client: Return response
Loading

Estimated code review effort

3 (~45 minutes)

Possibly related PRs

Poem

A hop and a skip, requests on the run,
If one Engine falters, migration’s begun!
With tokens now counted and warnings in logs,
Our Dynamo dances through network fogs.
Rabbits rejoice—resilience anew,
As seamless migrations carry requests through! 🐇✨


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.
    • @coderabbitai modularize this function.
  • 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.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ac7e888 and 84e88d8.

📒 Files selected for processing (3)
  • docs/guides/dynamo_run.md (1 hunks)
  • launch/dynamo-run/src/main.rs (1 hunks)
  • lib/llm/src/migration.rs (12 hunks)
🧠 Learnings (2)
docs/guides/dynamo_run.md (1)

Learnt from: nnshah1
PR: #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.

lib/llm/src/migration.rs (4)

Learnt from: kthui
PR: #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.

Learnt from: kthui
PR: #1424
File: lib/runtime/src/pipeline/network/egress/push_router.rs:204-209
Timestamp: 2025-06-13T22:32:05.022Z
Learning: In async-nats, the "no responders" error is represented as async_nats::error::RequestErrorKind::NoResponders. Use err.downcast_ref::<async_nats::error::RequestError>() and then check req_err.kind() against RequestErrorKind::NoResponders to handle this error properly.

Learnt from: kthui
PR: #1424
File: lib/runtime/src/pipeline/network/egress/push_router.rs:204-209
Timestamp: 2025-06-13T22:32:05.022Z
Learning: In async-nats, the "no responders" error is represented as async_nats::client::RequestErrorKind::NoResponders, not async_nats::Error::NoResponders. Use err.downcast_ref::<async_nats::client::RequestError>() and then check request_err.kind() against RequestErrorKind::NoResponders.

Learnt from: ishandhanani
PR: #1626
File: lib/llm/src/preprocessor.rs:238-239
Timestamp: 2025-06-24T20:59:35.725Z
Learning: In lib/llm/src/preprocessor.rs, the sampling_options call in the preprocess_request method is placed in the common section after the match statement on request.prompt_input_type(), meaning it applies to both PromptInput::Tokens and PromptInput::Text request types.

🧰 Additional context used
🧠 Learnings (2)
docs/guides/dynamo_run.md (1)

Learnt from: nnshah1
PR: #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.

lib/llm/src/migration.rs (4)

Learnt from: kthui
PR: #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.

Learnt from: kthui
PR: #1424
File: lib/runtime/src/pipeline/network/egress/push_router.rs:204-209
Timestamp: 2025-06-13T22:32:05.022Z
Learning: In async-nats, the "no responders" error is represented as async_nats::error::RequestErrorKind::NoResponders. Use err.downcast_ref::<async_nats::error::RequestError>() and then check req_err.kind() against RequestErrorKind::NoResponders to handle this error properly.

Learnt from: kthui
PR: #1424
File: lib/runtime/src/pipeline/network/egress/push_router.rs:204-209
Timestamp: 2025-06-13T22:32:05.022Z
Learning: In async-nats, the "no responders" error is represented as async_nats::client::RequestErrorKind::NoResponders, not async_nats::Error::NoResponders. Use err.downcast_ref::<async_nats::client::RequestError>() and then check request_err.kind() against RequestErrorKind::NoResponders.

Learnt from: ishandhanani
PR: #1626
File: lib/llm/src/preprocessor.rs:238-239
Timestamp: 2025-06-24T20:59:35.725Z
Learning: In lib/llm/src/preprocessor.rs, the sampling_options call in the preprocess_request method is placed in the common section after the match statement on request.prompt_input_type(), meaning it applies to both PromptInput::Tokens and PromptInput::Text request types.

⏰ 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: pre-merge-rust (lib/bindings/python)
  • GitHub Check: pre-merge-rust (lib/runtime/examples)
  • GitHub Check: pre-merge-rust (.)
  • GitHub Check: Build and Test - vllm
🔇 Additional comments (8)
launch/dynamo-run/src/main.rs (1)

27-27: LGTM! The migration-limit flag follows the established CLI pattern.

The addition of --migration-limit=0 to the usage string is consistent with other optional flags and properly documents the new fault tolerance feature.

docs/guides/dynamo_run.md (1)

212-227: Well-documented feature explanation!

The new "Fault Tolerance and Request Migration" section clearly explains the migration behavior, the --migration-limit flag usage, and provides a practical example. The documentation effectively communicates how the feature enhances reliability in distributed deployments.

lib/llm/src/migration.rs (6)

116-118: Appropriate logging level upgrade for migration events.

Elevating these log messages from info to warning level is correct - stream disconnections and recreation failures are operational concerns that warrant higher visibility.


141-141: Consistent logging level for retry events.

Good change - retry attempts due to NoResponders errors are warning-level events that operators need to monitor.


168-171: Correct implementation of token limit tracking during migration.

The logic properly tracks and updates the remaining token budget by subtracting already-generated tokens. Using saturating_sub is a good defensive programming practice to handle edge cases.


188-195: Test helper properly updated to support max_tokens testing.

The parameterization of max_tokens in the test helper enables comprehensive testing of the token tracking feature.


274-285: Excellent test coverage for the token tracking feature.

The assertion comprehensively validates that max_tokens is correctly adjusted based on already-generated responses, ensuring the migration logic respects token limits.


473-473: Test updates are consistent with the new max_tokens parameter.

All test cases have been properly updated to specify appropriate max_tokens values, maintaining test coverage while adapting to the new API.

Also applies to: 504-504, 535-535, 571-571, 591-591, 638-638

@kthui kthui requested review from a team, PeaBrane, ishandhanani and jthomson04 as code owners July 28, 2025 22:05
@pull-request-size pull-request-size bot added size/L and removed size/M labels Jul 28, 2025
@kthui kthui changed the title docs: Add Request Migration docs and minor enhancements chore: Add Request Migration docs and minor enhancements Jul 28, 2025
@github-actions github-actions bot added chore and removed docs labels Jul 28, 2025
@kthui kthui enabled auto-merge (squash) July 28, 2025 22:57
Copy link
Contributor

@rmccorm4 rmccorm4 left a comment

Choose a reason for hiding this comment

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

One comment on out=vllm being removed in dynamo-run (I believe), but LGTM otherwise

@kthui kthui merged commit fdcf611 into main Jul 28, 2025
14 checks passed
@kthui kthui deleted the jacky-ft-migrate-docs branch July 28, 2025 23:51
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