Balance burst requests by tracking pending master assignments#2143
Open
RWL-Dittrich wants to merge 1 commit into
Open
Balance burst requests by tracking pending master assignments#2143RWL-Dittrich wants to merge 1 commit into
RWL-Dittrich wants to merge 1 commit into
Conversation
20300c1 to
df05dcc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
When a cluster runs multiple instances of the same model, the master should send new requests to the least busy instance. But with several requests arriving at the same time, most of them were sent to one instance while the other stayed idle.
Root cause:
The master checks
self.state.tasksto see how many tasks each instance has, then emits aTaskCreatedevent. However,self.stateis only updated later by_event_processor.Because of that delay, several requests can all see the same old state:
node1=0, node2=0. Since ties always pick the first instance, the whole burst can go to one node.This happens inside the master scheduler, so it does not matter which node receives the HTTP request.
Changes
Master._pending_assignmentsto track tasks that were assigned but are not yet visible inself.state._in_flight_counts(model_id, exclude)to count both tasks inself.stateand pending assignments.TextGeneration,ImageGeneration, andImageEditsschedulers.Why It Works
The master now counts tasks immediately after assigning them, instead of waiting for the event to update
self.state.Example:
node1=0, node2=0and picks node 1.node1=1, node2=0because request 1 is pending, so it picks node 2.This prevents bursts from all going to the same instance. Once the
TaskCreatedevent is applied, the task is counted throughself.stateand the pending entry is removed.Test Plan
Manual Testing
/v1/chat/completionsrequests at the same time.Automated Testing
src/exo/master/tests/test_master.pystill covers the single-instanceTextGenerationpath.