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

Fix hanging when prompt exceeds limit #1029

Merged
merged 1 commit into from
Sep 17, 2023
Merged

Conversation

chenxu2048
Copy link
Contributor

I discovered that my API server with AsyncLLMEngine was blocked when a lengthy prompt was submitted to it. This problem shares similarities with issues #765 and #1026.

The scheduler is adding seq_groups that are larger than the prompt_limit:

if num_prompt_tokens > self.prompt_limit:
    logger.warning(
        f"Input prompt ({num_prompt_tokens} tokens) is too long"
        f" and exceeds limit of {self.prompt_limit}")
    for seq in seq_group.get_seqs():
        seq.status = SequenceStatus.FINISHED_IGNORED
    ignored_seq_groups.append(seq_group)
    self.waiting.pop(0)
    continue

And it returns when the schedule is not empty:

if scheduled:
    scheduler_outputs = SchedulerOutputs(
        scheduled_seq_groups=scheduled,
        prompt_run=True,
        num_batched_tokens=num_batched_tokens,
        blocks_to_swap_in=blocks_to_swap_in,
        blocks_to_swap_out=blocks_to_swap_out,
        blocks_to_copy=blocks_to_copy,
        ignored_seq_groups=ignored_seq_groups,
    )
    return scheduler_outputs

However, in LLMEngine._schedule, ignored_seq_groups is returned when scheduler_outputs.is_empty().

def step(self) -> List[RequestOutput]:
    (seq_group_metadata_list, scheduler_outputs,
     early_return) = self._schedule()
    if early_return is not None:
        return early_return

The third value returned by LLMEngine._schedule will always be None, and the ignored seq groups are thus LEAKED.

Copy link
Member

@zhuohan123 zhuohan123 left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for the great fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants