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

Add VLLM_SCHED_PREFILL_KVC_FREEPCT #89

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion vllm/core/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
ARTIFICIAL_PREEMPTION_MAX_CNT = 500


VLLM_SCHED_PREFILL_KVC_FREEPCT = float(
os.getenv("VLLM_SCHED_PREFILL_KVC_FREEPCT", 0.0)) # noqa
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move to envs.py


class PreemptionMode(enum.Enum):
"""Preemption modes.

Expand Down Expand Up @@ -644,7 +647,15 @@ def _schedule_prefills(
waiting_queue = deque([s for s in waiting_queue])

leftover_waiting_sequences: Deque[SequenceGroup] = deque()
while self._passed_delay(time.time()) and waiting_queue:
pct_blocks_free = 100.0
#only calculate pct_blocks_free if VLLM_SCHED_PREFILL_KVC_FREEPCT feature is enabled
if VLLM_SCHED_PREFILL_KVC_FREEPCT>0.0:
num_free_blocks = self.block_manager.gpu_allocator.get_num_free_blocks()
total_blocks = self.block_manager.num_total_gpu_blocks
pct_blocks_free = 100*num_free_blocks/total_blocks
#print('>>> Num free blocks',num_free_blocks,'Pct Free',pct_blocks_free,flush=True)

while pct_blocks_free>VLLM_SCHED_PREFILL_KVC_FREEPCT and self._passed_delay(time.time()) and waiting_queue:
seq_group = waiting_queue[0]

waiting_seqs = seq_group.get_seqs(status=SequenceStatus.WAITING)
Expand Down
Loading