[Model Runner V2] Support custom logits processors (#56497)

Signed-off-by: David Cheung <d7cheung@gmail.com>
Signed-off-by: Nick Hill <nickhill123@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Nick Hill <nickhill123@gmail.com>
This commit is contained in:
David Cheung
2026-09-19 17:46:49 +00:00
committed by GitHub
co-authored by Claude Nick Hill
parent 751f6807d9
commit 5302d1fe40
32 changed files with 1215 additions and 510 deletions
+8 -4
View File
@@ -143,6 +143,7 @@ from vllm.v1.worker.gpu.sample.batch_shard import (
all_to_all_logits,
gather_sampler_output,
)
from vllm.v1.worker.gpu.sample.logits_processor import build_custom_logits_processors
from vllm.v1.worker.gpu.sample.output import SamplerOutput
from vllm.v1.worker.gpu.sample.prompt_logprob import PromptLogprobsWorker
from vllm.v1.worker.gpu.sample.sampler import Sampler
@@ -447,8 +448,13 @@ class GPUModelRunner(LoRAModelRunnerMixin):
)
# Initialize samplers. Model states may override via custom_sampler().
config_processors = self.model_config.logits_processors or ()
custom_logits_processors = build_custom_logits_processors(
self.vllm_config, self.req_states, self.is_pooling_model, config_processors
)
if self.is_last_pp_rank and not self.is_pooling_model:
sampler_kwargs: dict[str, Any] = {
"vllm_config": self.vllm_config,
"max_num_reqs": self.max_num_reqs,
"vocab_size": self.vocab_size,
"device": self.device,
@@ -457,8 +463,8 @@ class GPUModelRunner(LoRAModelRunnerMixin):
"num_speculative_tokens": self.decode_query_len,
"use_fp64_gumbel": self.model_config.use_fp64_gumbel,
"enable_trace_replay": self.model_config.enable_trace_replay,
"reasoning_config": self.vllm_config.reasoning_config,
"return_sampling_mask": self.model_config.return_sampling_mask,
"custom_logits_processors": custom_logits_processors,
}
if self.vllm_config.watermark_config is None:
self.sampler = Sampler(**sampler_kwargs)
@@ -1147,9 +1153,7 @@ class GPUModelRunner(LoRAModelRunnerMixin):
if self.is_last_pp_rank and new_req_data.sampling_params is not None:
assert self.sampler is not None
self.sampler.add_request(
req_index, prompt_len, new_req_data.sampling_params
)
self.sampler.add_request(req_index, new_req_data.sampling_params)
assert self.prompt_logprobs_worker is not None
self.prompt_logprobs_worker.add_request(
req_id, req_index, new_req_data.sampling_params