[Refactor / Style] Unify all event loops (except for PP)#12959
[Refactor / Style] Unify all event loops (except for PP)#12959
Conversation
Summary of ChangesHello @hnyls2002, 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 focuses on refactoring and improving the code structure within the SGLang scheduler, specifically targeting disaggregated prefill and decode operations. The changes aim to enhance code readability, maintainability, and reduce duplication by standardizing the interface for KV receivers and consolidating complex logic into dedicated helper methods. This streamlines the management of request states and KV cache during the lifecycle of a request, contributing to a more organized and efficient codebase. Highlights
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 several good refactorings that improve code clarity and reduce duplication across the event loops. Key changes include adding clear() and abort() methods to the BaseKVReceiver to avoid hasattr checks, and extracting common logic in decode.py and prefill.py into new, reusable methods. These changes make the code cleaner and more maintainable. The overall quality of the code is improved, and I have not identified any issues with this refactoring.
Now all event loops follow the same logic:
Non-overlap loop:
Overlap loop:
And all idle batch's preparation (MLP sync) happens inside
build_next_batch()