[Feature] Add fixed-token prefill scoring (#54335)

Signed-off-by: aoshen02 <aoshen@inferact.ai>
Signed-off-by: aoshen02 <aoshen02@users.noreply.github.com>
Co-authored-by: aoshen02 <aoshen02@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
aoshen02
2026-09-28 07:50:09 -07:00
committed by GitHub
co-authored by aoshen02 Claude Opus 5
parent a7ff44355c
commit b721a4c709
36 changed files with 768 additions and 8 deletions
+12
View File
@@ -5,6 +5,8 @@ import itertools
from collections.abc import Iterable
from dataclasses import dataclass
import numpy as np
from vllm.logger import init_logger
from vllm.logprobs import (
FlatLogprobs,
@@ -38,6 +40,8 @@ class LogprobsProcessor:
cumulative_logprob: float | None
num_logprobs: int | None
num_prompt_logprobs: int | None
# [num_scored_rows, num_token_ids], set once on the final prefill chunk.
prompt_token_id_logprobs: np.ndarray | None = None
@classmethod
def from_new_request(
@@ -204,6 +208,12 @@ class LogprobsProcessor:
self.prompt_logprobs = []
return plp
def pop_prompt_token_id_logprobs(self) -> np.ndarray | None:
"""Pop and return the fixed-ID prompt scores."""
scores = self.prompt_token_id_logprobs
self.prompt_token_id_logprobs = None
return scores
@staticmethod
def _get_sampled_context_ids(
logprobs_source: SampleLogprobs | PromptLogprobs | None,
@@ -352,3 +362,5 @@ class LogprobsProcessor:
self._update_sample_logprobs(output.new_logprobs)
if output.new_prompt_logprobs_tensors is not None:
self._update_prompt_logprobs(output.new_prompt_logprobs_tensors)
if output.prompt_token_id_logprobs is not None:
self.prompt_token_id_logprobs = output.prompt_token_id_logprobs.numpy()