Skip to content

fix bug: schedule ratio support prefix-caching#4100

Merged
lvhan028 merged 1 commit intoInternLM:mainfrom
Tsundoku958:Tsundoku958/fix-bug-shcedule-ratio
Nov 6, 2025
Merged

fix bug: schedule ratio support prefix-caching#4100
lvhan028 merged 1 commit intoInternLM:mainfrom
Tsundoku958:Tsundoku958/fix-bug-shcedule-ratio

Conversation

@Tsundoku958
Copy link
Copy Markdown
Contributor

@Tsundoku958 Tsundoku958 commented Nov 5, 2025

Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily receiving feedbacks. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.

Motivation

During the _schedule_prefill process, the system evaluates whether the free_ratio is less than 0.1. If this condition is met, it bypasses the prefill phase and proceeds directly to decode. When the service is launched with the --enable-prefix-caching option, a significant portion of the GPU memory blocks may be occupied by the block_trie structure. This leads to repeated invocations of decode operations, gradually depleting the available memory blocks. As a result, the waiting queue remains unscheduled, while the running queue becomes fully exhausted. Ultimately, when _schedule_decoding is called, an assertion error is triggered due to the condition assert len(running) != 0 not being satisfied.

Reproduction:

GPU: 4090

Command:

lmdeploy serve api_server ../vllm_build/qwen/qwen_0.6B/  --backend pytorch --max-batch-size 256 --enable-prefix-caching
python benchmark/profile_restful_api.py --backend lmdeploy  --dataset-path ./ShareGPT_V3_unfiltered_cleaned_split.json --num-prompts 1000

Traceback:
Pasted Graphic 1

Modification

evict_block_trie when the free_ratio is less than 0.1 during the _schedule_prefill process

BC-breaking (Optional)

Does the modification introduce changes that break the backward-compatibility of the downstream repositories?
If so, please describe how it breaks the compatibility and how the downstream projects should modify their code to keep compatibility with this PR.

Use cases (Optional)

If this PR introduces a new feature, it is better to list some use cases here, and update the documentation.

Checklist

  1. Pre-commit or other linting tools are used to fix the potential lint issues.
  2. The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness.
  3. If the modification has a dependency on downstream projects of a newer version, this PR should be tested with all supported versions of downstream projects.
  4. The documentation has been modified accordingly, like docstring or example tutorials.
    @lvhan028 @grimoire

@CUHKSZzxy CUHKSZzxy mentioned this pull request Nov 6, 2025
3 tasks
Copy link
Copy Markdown
Collaborator

@RunningLeon RunningLeon left a comment

Choose a reason for hiding this comment

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

LGTM

@lvhan028 lvhan028 merged commit 9305204 into InternLM:main Nov 6, 2025
5 checks passed
@lvhan028 lvhan028 added the Bug:P1 label Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants