[feature] Initial block diffusion language model support (#12588)
Co-authored-by: Tiwei Bie <tiwei.btw@antgroup.com>
This commit is contained in:
@@ -60,6 +60,7 @@ from sglang.srt.disaggregation.utils import (
|
||||
prepare_abort,
|
||||
)
|
||||
from sglang.srt.distributed import get_pp_group, get_world_group
|
||||
from sglang.srt.dllm.config import DllmConfig
|
||||
from sglang.srt.environ import envs
|
||||
from sglang.srt.eplb.expert_distribution import get_global_expert_distribution_recorder
|
||||
from sglang.srt.layers.dp_attention import compute_dp_attention_world_info
|
||||
@@ -287,6 +288,9 @@ class Scheduler(
|
||||
# Init model config
|
||||
self.model_config = ModelConfig.from_server_args(server_args)
|
||||
|
||||
# Init diffusion LLM config
|
||||
self.dllm_config = DllmConfig.from_server_args(server_args)
|
||||
|
||||
# Init inter-process communication
|
||||
self.init_sockets(server_args, port_args)
|
||||
|
||||
@@ -449,6 +453,10 @@ class Scheduler(
|
||||
|
||||
# Init chunked prefill
|
||||
self.chunked_prefill_size = server_args.chunked_prefill_size
|
||||
if self.dllm_config is not None:
|
||||
# We currently leverage chunked prefill to implement block diffusion
|
||||
# for diffusion LLM.
|
||||
self.chunked_prefill_size = self.dllm_config.block_size
|
||||
if self.chunked_prefill_size <= 0: # -1 means disable
|
||||
self.chunked_prefill_size = None
|
||||
self.chunked_req = None
|
||||
@@ -1284,6 +1292,7 @@ class Scheduler(
|
||||
self.metrics_collector if self.enable_metrics else None
|
||||
),
|
||||
http_worker_ipc=recv_req.http_worker_ipc,
|
||||
dllm_config=self.dllm_config,
|
||||
)
|
||||
req.tokenizer = self.tokenizer
|
||||
|
||||
@@ -1600,6 +1609,10 @@ class Scheduler(
|
||||
self.handle_embedding_request(tokenized_req)
|
||||
|
||||
def get_next_batch_to_run(self) -> Optional[ScheduleBatch]:
|
||||
if self.dllm_config is not None:
|
||||
if self.chunked_req is not None and self.chunked_req.finished():
|
||||
self.chunked_req = None
|
||||
|
||||
# Merge the prefill batch into the running batch
|
||||
chunked_req_to_exclude = set()
|
||||
if self.chunked_req:
|
||||
@@ -1832,6 +1845,7 @@ class Scheduler(
|
||||
self.enable_overlap,
|
||||
self.spec_algorithm,
|
||||
chunked_req=self.chunked_req,
|
||||
dllm_config=self.dllm_config,
|
||||
)
|
||||
if self.enable_hierarchical_cache:
|
||||
# todo (zhiqiang): disable cuda graph execution if hicache loading triggered
|
||||
@@ -2064,7 +2078,10 @@ class Scheduler(
|
||||
self.process_batch_result_decode(batch, result)
|
||||
trace_slice_batch(RequestStage.DECODE_LOOP, batch.reqs)
|
||||
elif batch.forward_mode.is_extend():
|
||||
self.process_batch_result_prefill(batch, result)
|
||||
if batch.is_dllm():
|
||||
self.process_batch_result_dllm(batch, result)
|
||||
else:
|
||||
self.process_batch_result_prefill(batch, result)
|
||||
elif batch.forward_mode.is_prebuilt():
|
||||
self.process_batch_result_prebuilt(batch)
|
||||
elif batch.forward_mode.is_idle():
|
||||
|
||||
Reference in New Issue
Block a user