feat: diffusion router#2
Conversation
Summary of ChangesHello @alphabetc1, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a dedicated and feature-rich router for SGLang diffusion workers, enhancing the system's scalability, reliability, and maintainability. By centralizing worker management, load distribution, and health monitoring, it provides a robust layer for handling diffusion generation requests, while also improving code quality and testability through new development tooling and comprehensive testing. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new SGLang diffusion router, adding comprehensive infrastructure for load-balancing diffusion workers. Key changes include the creation of a DiffusionRouter class with FastAPI endpoints for worker registration, health checks, request proxying (for image/video generation), and broadcasting update_weights_from_disk operations. It supports 'least-request', 'round-robin', and 'random' routing algorithms, and implements background health checks with worker quarantine. The PR also adds a CLI for the router, detailed README.md documentation, and dedicated benchmark scripts for performance comparison of routing algorithms. Unit tests cover CLI argument parsing, router core logic, and API endpoint behavior. Review comments highlight several issues: outdated rev versions for pre-commit hooks (pre-commit-hooks, ruff-pre-commit, black, codespell) which need to be updated to stable versions, insufficient security validation in _normalize_worker_url for the add_worker endpoint (failing to block loopback addresses or enforce port presence, potentially leading to SSRF), the lack of authentication/authorization for sensitive endpoints like /add_worker, /update_weights_from_disk, and the catch-all proxy, and a suggestion to expand the ruff configuration to include more code quality checks (e.g., E,F,W). A minor suggestion was also made to simplify the pytest command in the README.md.
Extract the SGLang diffusion router into a standalone package with CLI entry point, load-balancing algorithms, health checking, SSRF protection, unit tests, benchmarks, and pre-commit hooks for code quality. Derived from radixark/miles#544.