Skip to content

[BugFix] fix get_request from scheduler#5369

Merged
Jiang-Jia-Jun merged 1 commit intoPaddlePaddle:developfrom
juncaipeng:fix_sch
Dec 4, 2025
Merged

[BugFix] fix get_request from scheduler#5369
Jiang-Jia-Jun merged 1 commit intoPaddlePaddle:developfrom
juncaipeng:fix_sch

Conversation

@juncaipeng
Copy link
Collaborator

@juncaipeng juncaipeng commented Dec 4, 2025

Motivation

修复v1调度下从 splitwise_scheduler 拉不到长请求的问题

v1调度设置scheduler_config.max_num_batched_tokens为8192

 if self.scheduler_config.max_num_batched_tokens is None:
            if int(envs.ENABLE_V1_KVCACHE_SCHEDULER):
                if paddle.is_compiled_with_xpu():
                    self.scheduler_config.max_num_batched_tokens = self.model_config.max_model_len
                else:
                    self.scheduler_config.max_num_batched_tokens = 8192  # if set to max_model_len, it's easy to be OOM
            else:
                if self.cache_config.enable_chunked_prefill:
                    self.scheduler_config.max_num_batched_tokens = 2048
                else:
                    self.scheduler_config.max_num_batched_tokens = self.model_config.max_model_len

基于scheduler_config.max_num_batched_tokens来从 splitwise_scheduler 拉取请求

  if self.cfg.scheduler_config.splitwise_role != "mixed":
      max_num_batched_tokens = self.cfg.scheduler_config.max_num_batched_tokens
  else:
      max_num_batched_tokens = self.cfg.model_config.max_model_len

tasks = self.scheduler.get_requests(
                    available_blocks=available_blocks,
                    block_size=self.cfg.cache_config.block_size,
                    reserved_output_blocks=self.cfg.cache_config.enc_dec_block_num,
                    max_num_batched_tokens=max_num_batched_tokens,
                    batch=num_prefill_batch,
                )

Modifications

修改 splitwise_scheduler

Usage or Command

Accuracy Tests

Checklist

  • Add at least a tag in the PR title.
    • Tag list: [[FDConfig],[APIServer],[Engine], [Scheduler], [PD Disaggregation], [Executor], [Graph Optimization], [Speculative Decoding], [RL], [Models], [Quantization], [Loader], [OP], [KVCache], [DataProcessor], [BugFix], [Docs], [CI], [Optimization], [Feature], [Benchmark], [Others], [XPU], [HPU], [GCU], [DCU], [Iluvatar], [Metax]]
    • You can add new tags based on the PR content, but the semantics must be clear.
  • Format your code, run pre-commit before commit.
  • Add unit tests. Please write the reason in this PR if no unit tests.
  • Provide accuracy results.
  • If the current PR is submitting to the release branch, make sure the PR has been submitted to the develop branch, then cherry-pick it to the release branch with the [Cherry-Pick] PR tag.

Copilot AI review requested due to automatic review settings December 4, 2025 08:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a critical bug in the v1 scheduler where long requests (those exceeding max_num_batched_tokens) could not be processed from the InferScheduler, causing an infinite loop.

Key Changes

  • Added len(reqs) > 0 condition to line 862 in splitwise_scheduler.py to allow the first request to be processed even when it exceeds max_num_batched_tokens
  • This prevents the scheduler from repeatedly pushing back and re-attempting to process the same long request

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@3697110). Learn more about missing BASE report.

Files with missing lines Patch % Lines
fastdeploy/scheduler/splitwise_scheduler.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #5369   +/-   ##
==========================================
  Coverage           ?   59.79%           
==========================================
  Files              ?      325           
  Lines              ?    40286           
  Branches           ?     6100           
==========================================
  Hits               ?    24090           
  Misses             ?    14294           
  Partials           ?     1902           
Flag Coverage Δ
GPU 59.79% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@paddle-bot
Copy link

paddle-bot bot commented Dec 4, 2025

Thanks for your contribution!

@Jiang-Jia-Jun Jiang-Jia-Jun merged commit 7f4fff4 into PaddlePaddle:develop Dec 4, 2025
19 of 25 checks passed
@juncaipeng juncaipeng deleted the fix_sch branch December 5, 2025 01:12
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