Skip to content

fix: Throw exception if inadequate GPUs #1508

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yinggeh
Copy link

@yinggeh yinggeh commented Jun 13, 2025

Overview:

Throw exception if inadequate GPUs in dynamo serve.

Details:

3 GPUs are needed for disagg EPD serving. 1 gpu for each E P and D. If the number of GPUs available to the user is less than the number of GPUs that an EPD service needs, the service "starts up" normally and hangs when the user tries to make an inference call, without any sign or error that the user doesn't have enough GPUs available to run the service.

Expected Behavior

When serving, an error should be thrown at/around the GPU allocation step.

Where should the reviewer start?

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

Summary by CodeRabbit

  • Bug Fixes
    • Improved error handling when requesting more GPUs than available by immediately notifying users with an error message and stopping further execution.

Copy link

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

@yinggeh
Copy link
Author

yinggeh commented Jun 13, 2025

root@4u4g-0072:/workspace/examples/multimodal# dynamo serve graphs.disagg:Frontend -f configs/disagg.yaml
2025-06-12T23:41:19.146Z  INFO utils.resolve_service_config: Running dynamo serve with config: {'Common': {'model': 'llava-hf/llava-1.5-7b-hf', 'block-size': 64, 'max-model-len': 4096, 'image-token-id': 32000, 'num-patches': 576, 'kv-transfer-config': '{"kv_connector":"DynamoNixlConnector"}'}, 'Processor': {'router': 'round-robin', 'prompt-template': 'USER: <image>\n<prompt> ASSISTANT:', 'common-configs': ['model', 'block-size']}, 'VllmDecodeWorker': {'remote-prefill': True, 'conditional-disagg': True, 'max-local-prefill-length': 10, 'max-prefill-queue-size': 2, 'ServiceArgs': {'workers': 1, 'resources': {'gpu': '1'}}, 'common-configs': ['model', 'block-size', 'image-token-id', 'max-model-len', 'num-patches', 'kv-transfer-config']}, 'VllmPrefillWorker': {'max-num-batched-tokens': 16384, 'ServiceArgs': {'workers': 1, 'resources': {'gpu': '1'}}, 'common-configs': ['model', 'block-size', 'image-token-id', 'max-model-len', 'num-patches', 'kv-transfer-config']}, 'VllmEncodeWorker': {'tensor-parallel-size': 1, 'router': 'random', 'ServiceArgs': {'workers': 1, 'resources': {'gpu': '1'}}, 'common-configs': ['model']}}   
2025-06-12T23:41:20.522Z  INFO __init__: Utilizing cupy to enable GPU acceleration.   
2025-06-12T23:41:22.604Z  WARN __init__.vllm_version_matches_substr: Using ai_dynamo_vllm   
2025-06-12T23:41:22.605Z  WARN __init__.vllm_version_matches_substr: Using ai_dynamo_vllm   
2025-06-12T23:41:22.607Z  WARN __init__.vllm_version_matches_substr: Using ai_dynamo_vllm   
2025-06-12T23:41:22.611Z  WARN __init__.vllm_version_matches_substr: Using ai_dynamo_vllm   
2025-06-12T23:41:22.612Z  WARN __init__.vllm_version_matches_substr: Using ai_dynamo_vllm   
2025-06-12T23:41:22.614Z  INFO __init__.resolve_current_platform_cls_qualname: Automatically detected platform cuda.   
2025-06-12T23:41:22.829Z  INFO nixl: NIXL is available   
2025-06-12T23:41:24.623Z  INFO encode_worker: Using cupy for array operations (GPU mode).   
╭───────────────── Dynamo Serve ──────────────────╮
│ Starting Dynamo service: graphs.disagg:Frontend │
╰─────────────────────────────────────────────────╯
2025-06-12T23:41:24.703Z  INFO resource._discover_gpus: Discovered 2 GPUs   
2025-06-12T23:41:24.725Z  INFO resource._discover_gpus: Discovered 2 GPUs   
2025-06-12T23:41:24.725Z  INFO allocator.get_resource_envs: Getting resource envs for service Frontend   
2025-06-12T23:41:24.725Z  INFO allocator.get_resource_envs: Using configured worker count: 1   
2025-06-12T23:41:24.725Z  INFO allocator.get_resource_envs: Final resource allocation - workers: 1, envs: []   
2025-06-12T23:41:24.726Z  INFO serving.serve_dynamo_graph: Serving dynamo graph with namespace dynamo   
2025-06-12T23:41:24.726Z  INFO serving.serve_dynamo_graph: Clearing namespace dynamo before serving   
2025-06-12T23:41:24.726Z  INFO allocator.get_resource_envs: Getting resource envs for service Processor   
2025-06-12T23:41:24.726Z  INFO allocator.get_resource_envs: Using configured worker count: 1   
2025-06-12T23:41:24.726Z  INFO allocator.get_resource_envs: Final resource allocation - workers: 1, envs: []   
2025-06-12T23:41:24.726Z  INFO serving.create_dynamo_watcher: Created watcher for Processor's in the dynamo namespace   
2025-06-12T23:41:24.726Z  INFO allocator.get_resource_envs: Getting resource envs for service VllmDecodeWorker   
2025-06-12T23:41:24.726Z  INFO allocator.get_resource_envs: GPU requirement found: 1   
2025-06-12T23:41:24.726Z  INFO allocator.get_resource_envs: Using configured worker count: 1   
2025-06-12T23:41:24.726Z  INFO allocator.get_resource_envs: GPU allocation enabled   
2025-06-12T23:41:24.726Z  INFO allocator.get_resource_envs: Local deployment detected. Allocating GPUs for 1 workers of 'VllmDecodeWorker'   
2025-06-12T23:41:24.726Z  INFO allocator.get_resource_envs: GPU 0 (NVIDIA H100 NVL): Memory: 93.0GB free / 93.6GB total, Utilization: 0%, Temperature: 42°C   
2025-06-12T23:41:24.726Z  INFO allocator.get_resource_envs: Final resource allocation - workers: 1, envs: [{'CUDA_VISIBLE_DEVICES': '0'}]   
2025-06-12T23:41:24.727Z  INFO serving.create_dynamo_watcher: Created watcher for VllmDecodeWorker's in the dynamo namespace   
2025-06-12T23:41:24.727Z  INFO allocator.get_resource_envs: Getting resource envs for service VllmPrefillWorker   
2025-06-12T23:41:24.727Z  INFO allocator.get_resource_envs: GPU requirement found: 1   
2025-06-12T23:41:24.727Z  INFO allocator.get_resource_envs: Using configured worker count: 1   
2025-06-12T23:41:24.727Z  INFO allocator.get_resource_envs: GPU allocation enabled   
2025-06-12T23:41:24.727Z  INFO allocator.get_resource_envs: Local deployment detected. Allocating GPUs for 1 workers of 'VllmPrefillWorker'   
2025-06-12T23:41:24.727Z  INFO allocator.get_resource_envs: GPU 1 (NVIDIA H100 NVL): Memory: 93.0GB free / 93.6GB total, Utilization: 0%, Temperature: 48°C   
2025-06-12T23:41:24.727Z  INFO allocator.get_resource_envs: Final resource allocation - workers: 1, envs: [{'CUDA_VISIBLE_DEVICES': '1'}]   
2025-06-12T23:41:24.727Z  INFO serving.create_dynamo_watcher: Created watcher for VllmPrefillWorker's in the dynamo namespace   
2025-06-12T23:41:24.727Z  INFO allocator.get_resource_envs: Getting resource envs for service VllmEncodeWorker   
2025-06-12T23:41:24.727Z  INFO allocator.get_resource_envs: GPU requirement found: 1   
2025-06-12T23:41:24.727Z  INFO allocator.get_resource_envs: Using configured worker count: 1   
2025-06-12T23:41:24.727Z  INFO allocator.get_resource_envs: GPU allocation enabled   
2025-06-12T23:41:24.727Z  INFO allocator.get_resource_envs: Local deployment detected. Allocating GPUs for 1 workers of 'VllmEncodeWorker'   
Traceback (most recent call last):
  File "/opt/dynamo/venv/bin/dynamo", line 10, in <module>
    sys.exit(cli())
             ^^^^^
  File "/opt/dynamo/venv/lib/python3.12/site-packages/typer/main.py", line 341, in __call__
    raise e
  File "/opt/dynamo/venv/lib/python3.12/site-packages/typer/main.py", line 324, in __call__
    return get_command(self)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/dynamo/venv/lib/python3.12/site-packages/click/core.py", line 1161, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/dynamo/venv/lib/python3.12/site-packages/typer/core.py", line 757, in main
    return _main(
           ^^^^^^
  File "/opt/dynamo/venv/lib/python3.12/site-packages/typer/core.py", line 195, in _main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/opt/dynamo/venv/lib/python3.12/site-packages/click/core.py", line 1697, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/dynamo/venv/lib/python3.12/site-packages/click/core.py", line 1443, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/dynamo/venv/lib/python3.12/site-packages/click/core.py", line 788, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/dynamo/venv/lib/python3.12/site-packages/typer/main.py", line 699, in wrapper
    return callback(**use_params)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/dynamo/venv/lib/python3.12/site-packages/dynamo/sdk/cli/serve.py", line 189, in serve
    serve_dynamo_graph(
  File "/opt/dynamo/venv/lib/python3.12/site-packages/dynamo/sdk/cli/serving.py", line 238, in serve_dynamo_graph
    new_watcher, new_socket, uri = create_dynamo_watcher(
                                   ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/dynamo/venv/lib/python3.12/site-packages/dynamo/sdk/cli/serving.py", line 78, in create_dynamo_watcher
    num_workers, resource_envs = scheduler.get_resource_envs(svc)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/dynamo/venv/lib/python3.12/site-packages/dynamo/sdk/cli/allocator.py", line 216, in get_resource_envs
    assigned = self.assign_gpus(num_gpus, service.name)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/dynamo/venv/lib/python3.12/site-packages/dynamo/sdk/cli/allocator.py", line 81, in assign_gpus
    raise ResourceError(
dynamo.sdk.lib.resource.ResourceError: Requested 1 GPUs, but only 0 are remaining. Serving may fail due to inadequate GPUs. Set DYN_DISABLE_AUTO_GPU_ALLOCATION=1 to disable automatic allocation and allocate GPUs manually.

@yinggeh yinggeh requested review from krishung5 and indrajit96 June 13, 2025 00:05
@yinggeh yinggeh self-assigned this Jun 13, 2025
@yinggeh yinggeh marked this pull request as ready for review June 13, 2025 00:09
Copy link
Contributor

coderabbitai bot commented Jun 13, 2025

Walkthrough

The change updates the GPU allocation logic in the ResourceAllocator class by replacing a warning log with an immediate exception raise when the requested GPU count exceeds the available GPUs. This prevents further execution in cases of insufficient resources, ensuring stricter error handling during GPU assignment.

Changes

File(s) Change Summary
deploy/sdk/src/dynamo/sdk/cli/allocator.py Changed assign_gpus to raise a ResourceError instead of logging a warning on GPU shortage

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ResourceAllocator

    User->>ResourceAllocator: assign_gpus(requested_count)
    ResourceAllocator->>ResourceAllocator: Check remaining GPUs
    alt Requested > Remaining
        ResourceAllocator-->>User: Raise ResourceError (insufficient GPUs)
    else Requested <= Remaining
        ResourceAllocator->>ResourceAllocator: Assign GPUs
        ResourceAllocator-->>User: Return assigned GPUs
    end
Loading

Possibly related issues

Poem

In the land of code where GPUs dwell,
A rabbit ensures all is well.
No silent warnings pass the gate—
Now errors shout if you over-allocate!
With stricter checks, the code is neat,
Resource management can’t be beat.
🐇✨


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

🔭 Outside diff range comments (1)
deploy/sdk/src/dynamo/sdk/cli/allocator.py (1)

80-86: 🛠️ Refactor suggestion

Correct move from soft-warning to hard failure, but emit a log entry before raising.

Switching from logger.warning to an immediate ResourceError fulfils the PR goal 👍.
However, because the raise short-circuits the method, the message is no longer captured in the logs unless the caller logs uncaught exceptions. A single logger.error(...) right before the raise keeps parity with the previous observability.

 if count > self.remaining_gpus:
-    raise ResourceError(
+    logger.error(          # visible even when the caller swallows the exception
+        f"Requested {count} GPUs, but only {self.remaining_gpus} are remaining. "
+        f"Serving may fail due to inadequate GPUs. Set {DYN_DISABLE_AUTO_GPU_ALLOCATION}=1 "
+        "to disable automatic allocation and allocate GPUs manually."
+    )
+    raise ResourceError(
         f"Requested {count} GPUs, but only {self.remaining_gpus} are remaining. "
         f"Serving may fail due to inadequate GPUs. Set {DYN_DISABLE_AUTO_GPU_ALLOCATION}=1 "
         "to disable automatic allocation and allocate GPUs manually."
     )
🧹 Nitpick comments (1)
deploy/sdk/src/dynamo/sdk/cli/allocator.py (1)

86-87: Integer cast drops fractional capacity.

self.remaining_gpus = int(max(0, self.remaining_gpus - count)) silently floors fractional
remainders. Two consecutive assign_gpus(0.5, …) calls on a 1-GPU system would mark the
machine as fully consumed after the first call (1 GPU → 1.5 → int() → 1).

Either keep remaining_gpus as a float or track whole & fractional capacity separately.

-self.remaining_gpus = int(max(0, self.remaining_gpus - count))
+self.remaining_gpus = max(0.0, self.remaining_gpus - count)  # keep precision
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0bba09a and b3e2fe4.

📒 Files selected for processing (1)
  • deploy/sdk/src/dynamo/sdk/cli/allocator.py (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build and Test - vllm
  • GitHub Check: Build and Test - vllm

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.

1 participant