-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Implement preemption via recomputation & Refactor scheduling logic #12
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
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
51a2557
Add watermark to avoid thrashing
WoosukKwon ab21ab8
Add Policy class
WoosukKwon 15e1e41
Refactor Policy class
WoosukKwon 0e2b47a
Use recomputation as preemption mechanism
WoosukKwon 3c2da3e
Bug fix in is_prompt
WoosukKwon bcf6a6f
Minor
WoosukKwon 4b56dc1
Minor
WoosukKwon 9578fea
Add back swapping
WoosukKwon dd999f4
Apply watermark to can_swap_in
WoosukKwon 86b7e9a
Refactor & Ensure priority swapped > waiting
WoosukKwon f2f13f5
Revert server.py
WoosukKwon 24968fc
Bugfix
WoosukKwon 9b159e4
Bugfix
WoosukKwon 2452758
Minor fix
WoosukKwon 3b66f86
Merge branch 'main' into recomp+sched
WoosukKwon 0a55d43
Fix merge errors
WoosukKwon 9edf814
Add more comments
WoosukKwon 8d81e01
Minor
WoosukKwon 2333ef4
Merge branch 'main' into recomp+sched
WoosukKwon ea8c27c
Add arrival time in fastapi frontend
WoosukKwon b6745db
Merge branch 'main' into recomp+sched
WoosukKwon 4c798c3
Move scheduling logic to _schedule & Add preemption mode
WoosukKwon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from typing import List | ||
|
||
from cacheflow.sequence import SequenceGroup | ||
|
||
|
||
class Policy: | ||
|
||
def get_priority( | ||
self, | ||
now: float, | ||
seq_group: SequenceGroup, | ||
) -> float: | ||
raise NotImplementedError | ||
|
||
def sort_by_priority( | ||
self, | ||
now: float, | ||
seq_groups: List[SequenceGroup], | ||
) -> List[SequenceGroup]: | ||
return sorted( | ||
seq_groups, | ||
key=lambda seq_group: self.get_priority(now, seq_group), | ||
reverse=True, | ||
) | ||
|
||
|
||
class FCFS(Policy): | ||
|
||
def get_priority( | ||
self, | ||
now: float, | ||
seq_group: SequenceGroup, | ||
) -> float: | ||
return now - seq_group.arrival_time | ||
|
||
|
||
class PolicyFactory: | ||
|
||
_POLICY_REGISTRY = { | ||
'fcfs': FCFS, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will we add SSF in another PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. In this PR, I tried to make minimal changes. |
||
} | ||
|
||
@classmethod | ||
def get_policy(cls, policy_name: str, **kwargs) -> Policy: | ||
return cls._POLICY_REGISTRY[policy_name](**kwargs) |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, is this function only wrong when we use recomputation preemption for parallel decoding?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, and for beam search as well.