Minor code style fix for dllm (#14836)

This commit is contained in:
Liangsheng Yin
2025-12-11 10:35:42 +09:00
committed by GitHub
parent 312df1d6c0
commit bd7824b24d
3 changed files with 43 additions and 35 deletions
+17 -9
View File
@@ -239,8 +239,11 @@ class TpModelWorker(BaseTpWorker):
is_draft_model=is_draft_worker,
)
# Init DLLM algorithm
if server_args.dllm_algorithm is not None:
self.dllm_algorithm = DllmAlgorithm.from_server_args(server_args)
else:
self.dllm_algorithm = None
self._model_runner = ModelRunner(
model_config=self.model_config,
@@ -349,7 +352,19 @@ class TpModelWorker(BaseTpWorker):
)
def is_dllm(self):
return hasattr(self, "dllm_algorithm")
return self.dllm_algorithm is not None
def _forward_batch_generation_dllm(
self, forward_batch: ForwardBatch
) -> GenerationBatchResult:
logits_output, next_token_ids, can_run_cuda_graph = self.dllm_algorithm.run(
self.model_runner, forward_batch
)
return GenerationBatchResult(
logits_output=logits_output,
next_token_ids=next_token_ids,
can_run_cuda_graph=can_run_cuda_graph,
)
def forward_batch_generation(
self,
@@ -380,14 +395,7 @@ class TpModelWorker(BaseTpWorker):
if self.pp_group.is_last_rank:
if self.is_dllm():
logits_output, next_token_ids, can_run_cuda_graph = (
self.dllm_algorithm.run(self.model_runner, forward_batch)
)
return GenerationBatchResult(
logits_output=logits_output,
next_token_ids=next_token_ids,
can_run_cuda_graph=can_run_cuda_graph,
)
return self._forward_batch_generation_dllm(forward_batch)
logits_output, can_run_cuda_graph = self.model_runner.forward(
forward_batch,