[Feature] PD-Multiplexing Context and Scheduler, lazy import spatial. (#12275)

This commit is contained in:
ykcombat
2025-11-01 00:40:01 +08:00
committed by GitHub
parent 70562969b9
commit 41efcaeb45
9 changed files with 458 additions and 24 deletions
+24 -1
View File
@@ -35,7 +35,7 @@ from sglang.srt.managers.io_struct import (
UpdateWeightsFromIPCReqInput,
UpdateWeightsFromTensorReqInput,
)
from sglang.srt.managers.schedule_batch import ModelWorkerBatch
from sglang.srt.managers.schedule_batch import ModelWorkerBatch, ScheduleBatch
from sglang.srt.managers.scheduler import GenerationBatchResult
from sglang.srt.mem_cache.allocator import BaseTokenToKVPoolAllocator
from sglang.srt.mem_cache.memory_pool import ReqToTokenPool
@@ -425,3 +425,26 @@ class TpModelWorker(BaseTpWorker):
pp_hidden_states_proxy_tensors=pp_proxy_tensors,
can_run_cuda_graph=can_run_cuda_graph,
)
def forward_batch_split_prefill(self, batch: ScheduleBatch):
if batch.split_index == 0:
model_worker_batch = batch.get_model_worker_batch()
forward_batch = ForwardBatch.init_new(model_worker_batch, self.model_runner)
batch.split_forward_batch = forward_batch
batch.seq_lens_cpu_cache = model_worker_batch.seq_lens_cpu
else:
model_worker_batch = batch.get_model_worker_batch(batch.seq_lens_cpu_cache)
logits_output, can_run_cuda_graph = self.model_runner.forward(
batch.split_forward_batch, split_forward_count=batch.split_forward_count
)
if logits_output:
next_token_ids = self.model_runner.sample(logits_output, model_worker_batch)
else:
next_token_ids = None
batch_result = GenerationBatchResult(
logits_output=logits_output,
can_run_cuda_graph=can_run_cuda_graph,
)
batch_result.next_token_ids = next_token_ids
return batch_result