Skip to content
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

Implement Modal's Keep Warm feature for faster inference #59

Open
slavakurilyak opened this issue Aug 6, 2024 · 1 comment
Open

Implement Modal's Keep Warm feature for faster inference #59

slavakurilyak opened this issue Aug 6, 2024 · 1 comment

Comments

@slavakurilyak
Copy link

Description

It would be great to use keep_warm when creating Modal containers using ComfyDeploy. This feature allows Modal to maintain a pool of pre-warmed instances, which can reduce cold start times and improve the responsiveness of the serverless GPU inference for ComfyUI.

Current Situation

Currently, ComfyDeploy scales from zero, which means there is a noticeable delay when spinning up new containers for inference requests.

Proposed Solution

Implement Modal's keep_warm feature in the Modal function decorators used in ComfyDeploy. This can be done by modifying the comfyui-deploy/builder/modal-builder/src/template/app.py file.

Example Implementation

import modal

# ... existing imports ...

@stub.function(
    image=target_image,
    gpu=config["gpu"],
    allow_concurrent_inputs=100,
    concurrency_limit=1,
    timeout=10 * 60,
    keep_warm=3  # Add this line to keep 3 containers warm (suggested default)
)
@asgi_app()
def comfyui_app():
    # ... existing function body ...

Benefits

  1. Reduced cold start latency
  2. Faster response times for inference requests
  3. Improved user experience, especially for applications requiring quick responses

Considerations

  • The number of warm containers (e.g., keep_warm=3) should be configurable based on expected load and cost considerations.
  • The front-end components must be updated to reflect this.
@omarei-omoto
Copy link

yes please :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants