Skip to content

Conversation

@tedzhouhk
Copy link
Contributor

@tedzhouhk tedzhouhk commented Jun 18, 2025

  • break profile_sla into different file
  • support vllm_v1 sweeping
  • correct a typo in docs

Summary by CodeRabbit

  • New Features

    • Added support for profiling two backend versions ("vllm_v0" and "vllm_v1") with backend-specific configuration and plotting.
    • Introduced modular utilities for configuration handling, GPU detection, profiling, and plotting.
    • Enhanced performance profiling with new plotting capabilities and decode request range options.
  • Documentation

    • Updated profiling and SLA planner documentation to reflect new module paths and required backend argument.
  • Refactor

    • Restructured profiling script to use external utility modules, improving maintainability and modularity.
    • Backend-specific logic and plotting are now handled through dedicated utility modules.

@copy-pr-bot
Copy link

copy-pr-bot bot commented Jun 18, 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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 18, 2025

Walkthrough

The profiling script and its related utilities were refactored for modularity, moving local utility functions and constants into new utility modules. Backend-specific configuration handling was introduced via a dictionary of modifier classes. Plotting and benchmarking logic were externalized, and the main script now selects backend-specific behaviors based on a new argument.

Changes

File(s) Change Summary
benchmarks/profiler/profile_sla.py Refactored to remove local utilities, import modular functions/classes for config, plotting, and benchmarking.
benchmarks/profiler/utils/config.py New module with backend-specific config modifier classes and a selector dictionary.
benchmarks/profiler/utils/defaults.py New module defining DECODE_NUM_REQUESTS_RANGE constant.
benchmarks/profiler/utils/genai_perf.py New module with functions for genai-perf command construction and benchmarking logic.
benchmarks/profiler/utils/plot.py New module providing plotting utilities for profiling results.
benchmarks/profiler/utils/utils.py New module with GPU/resource management and deployment utility functions.
components/planner/src/dynamo/planner/defaults.py Added classes/constants for backend-specific worker component names.
components/planner/src/dynamo/planner/local_connector.py Updated LocalConnector constructor to require a backend parameter.
docs/architecture/load_planner.md, docs/architecture/sla_planner.md Updated documentation to reflect new script invocation and backend argument.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant profile_sla.py
    participant ConfigModifier
    participant Utils
    participant GenAIPerf
    participant Plot

    User->>profile_sla.py: Run with --backend <vllm_v0/vllm_v1>
    profile_sla.py->>ConfigModifier: Select config modifier by backend
    profile_sla.py->>Utils: Detect GPUs, prepare deployment
    profile_sla.py->>ConfigModifier: Convert and set config for profiling
    profile_sla.py->>Utils: Launch deployment, wait for server
    loop Profiling (Prefill/Decode)
        profile_sla.py->>GenAIPerf: Run benchmark (prefill/decode)
        GenAIPerf-->>profile_sla.py: Return profiling results
    end
    profile_sla.py->>Plot: Generate plots from results
    profile_sla.py-->>User: Save and report results
Loading

Poem

In the warren of code, things now modular hop,
Utilities bundled, no more local crop.
Backends distinguished—v0 or v1—
Configs and plots, all neatly spun.
With scripts now cleaner, the profiling’s a breeze,
This rabbit approves—refactor with ease! 🐇


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

🔭 Outside diff range comments (2)
benchmarks/profiler/profile_sla.py (2)

125-129: log2(0) crash when no GPU present

Guard against available_gpus == 0 to avoid ValueError.

if available_gpus == 0:
    logger.error("No GPU detected – cannot profile.")
    exit(1)

338-362: tp_size is undefined – should be best_prefill_tp

The selected-prefill interpolation block re-uses tp_size, which is out of scope and will raise NameError.

-prefill_config = config_modifier.set_config_tp_size(prefill_config, tp_size)
+prefill_config = config_modifier.set_config_tp_size(
+    prefill_config, best_prefill_tp
+)-logger.info(f"Starting dynamo serve with TP size {tp_size}...")
+dynamo_serve_cmd = get_dynamo_serve_cmd(prefill_config_fn)
+logger.info(f"Starting dynamo serve with TP size {best_prefill_tp}…")

Apply the same substitution for all subsequent references inside this block.

♻️ Duplicate comments (2)
benchmarks/profiler/utils/config.py (1)

218-236: Same undefined-variable issue as above

Replicate the fix for the v1 path.

benchmarks/profiler/profile_sla.py (1)

430-446: Decode interpolation block suffers from the same variable leak

Replace tp_size with best_decode_tp for log messages and throughput calculation.

🧹 Nitpick comments (2)
benchmarks/profiler/utils/genai_perf.py (1)

154-160: Prefer context-manager for Popen

Using with subprocess.Popen(…) as proc: guarantees the process is reaped on exceptions.

Also applies to: 187-193, 204-210

benchmarks/profiler/utils/plot.py (1)

68-72: Call plt.tight_layout() before saving

This avoids clipped labels when figures are resized.

     plt.savefig(plot_path, dpi=300)
+    plt.tight_layout()

Also applies to: 97-101, 144-170, 218-221

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d2bec6f and 317e630.

📒 Files selected for processing (10)
  • benchmarks/profiler/profile_sla.py (12 hunks)
  • benchmarks/profiler/utils/config.py (1 hunks)
  • benchmarks/profiler/utils/defaults.py (1 hunks)
  • benchmarks/profiler/utils/genai_perf.py (1 hunks)
  • benchmarks/profiler/utils/plot.py (1 hunks)
  • benchmarks/profiler/utils/utils.py (1 hunks)
  • components/planner/src/dynamo/planner/defaults.py (1 hunks)
  • components/planner/src/dynamo/planner/local_connector.py (1 hunks)
  • docs/architecture/load_planner.md (1 hunks)
  • docs/architecture/sla_planner.md (1 hunks)
🧰 Additional context used
🪛 Pylint (3.3.7)
benchmarks/profiler/utils/utils.py

[refactor] 85-100: Too many nested blocks (6/5)

(R1702)

components/planner/src/dynamo/planner/defaults.py

[refactor] 49-49: Too few public methods (0/2)

(R0903)


[refactor] 54-54: Too few public methods (0/2)

(R0903)

benchmarks/profiler/utils/config.py

[refactor] 104-107: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it

(R1705)


[refactor] 111-114: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it

(R1705)


[refactor] 204-207: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it

(R1705)


[refactor] 211-214: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it

(R1705)

benchmarks/profiler/utils/genai_perf.py

[refactor] 66-66: Too many arguments (6/5)

(R0913)


[refactor] 66-66: Too many positional arguments (6/5)

(R0917)


[refactor] 99-99: Too many arguments (7/5)

(R0913)


[refactor] 99-99: Too many positional arguments (7/5)

(R0917)


[refactor] 161-169: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it

(R1705)


[refactor] 154-159: Consider using 'with' for resource-allocating operations

(R1732)


[refactor] 172-172: Too many arguments (6/5)

(R0913)


[refactor] 172-172: Too many positional arguments (6/5)

(R0917)


[refactor] 187-192: Consider using 'with' for resource-allocating operations

(R1732)


[refactor] 211-219: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it

(R1705)


[refactor] 204-209: Consider using 'with' for resource-allocating operations

(R1732)

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: pre-merge-rust (lib/runtime/examples)
  • GitHub Check: pre-merge-rust (lib/bindings/python)
  • GitHub Check: pre-merge-rust (.)
  • GitHub Check: Build and Test - vllm
🔇 Additional comments (4)
benchmarks/profiler/utils/defaults.py (1)

16-31: LGTM! Clean constant definition for decode profiling.

The DECODE_NUM_REQUESTS_RANGE constant is well-structured with reasonable values for profiling decode workloads across different request counts. The modularization of this constant into a dedicated defaults module improves code organization.

components/planner/src/dynamo/planner/defaults.py (1)

49-62: Backend-specific component name mapping looks good.

The design cleanly separates component names by backend version using dedicated classes and a mapping dictionary. This enables runtime selection of appropriate component names based on the backend parameter.

Note: The static analysis warnings about "too few public methods" are false positives - these classes are intentionally designed as data containers for constants, not traditional classes with methods.

docs/architecture/load_planner.md (1)

30-31: Documentation correctly updated to reflect refactoring changes.

The module path change from utils.profile_sla to profile_sla and the addition of the required --backend argument are consistent with the refactoring and backend-specific support introduced in this PR.

components/planner/src/dynamo/planner/local_connector.py (1)

35-42: Backend parameter added but not utilized.

The backend parameter is documented in the constructor but not assigned to any instance variable or used within the constructor body.

Verify if the backend parameter should be stored as an instance variable or used elsewhere:

#!/bin/bash
# Description: Check if backend parameter is used in other methods or subclasses
# Expected: Find usage patterns or confirm it's preparation for future implementation

# Search for backend usage in LocalConnector and related files
ast-grep --pattern 'self.backend'
rg -A 3 -B 3 'backend.*str' components/planner/src/dynamo/planner/

tedzhouhk and others added 3 commits June 18, 2025 11:29
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: Hongkuan Zhou <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: Hongkuan Zhou <[email protected]>
@tedzhouhk tedzhouhk merged commit 7ff1006 into main Jun 18, 2025
11 checks passed
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.

3 participants