vllm.v1.engine.output_processor
¶
Classes:
-
OutputProcessor–Process EngineCoreOutputs into RequestOutputs.
-
RequestOutputCollector–Collects streamed RequestOutputs per individual request,
-
RequestState– -
StreamingInputOutputCollector–Collector for streaming-input requests. Doesn't merge across input
-
StreamingUpdate–Streaming input update data for output processor.
OutputProcessor
¶
Process EngineCoreOutputs into RequestOutputs.
Methods:
-
abort_requests–Abort a list of requests.
-
get_num_queued_tokens–Total prompt tokens of requests currently in the prefill phase.
-
process_outputs–Process the EngineCoreOutputs:
-
propagate_error–Propagate error to all generate() tasks.
_trim_surplus_tokens(req_state, output, num_prev_tokens)
staticmethod
¶
Drop new tokens generated past a stop string matched by the detokenizer, e.g. when multiple tokens are accepted in one step.
_update_streaming_request_state(req_state, request, prompt)
¶
Queue a streaming update instead of immediately applying it.
abort_requests(request_ids, internal)
¶
Abort a list of requests.
The request_ids may be either external request IDs (those passed to InputProcessor.process_inputs()) or internal request IDs (those randomly generated when creating the EngineCoreRequest).
If an external request ID is provided, and that external request ID was used for multiple requests, all requests associated with that external request ID are aborted.
In the case of parallel sampling, a request ID may be used to identify a parent request, in which case the associated child requests are aborted also.
get_num_queued_tokens()
¶
Total prompt tokens of requests currently in the prefill phase.
Uses prompt_len rather than remaining prefill work because the
scheduler's num_computed_tokens is not propagated to the API
server until prefill completes. See SchedulerConfig docs.
process_outputs(engine_core_outputs, engine_core_timestamp=None, iteration_stats=None, weight_version=None)
¶
Process the EngineCoreOutputs: 1) Compute stats for logging 2) Detokenize 3) Create and handle RequestOutput objects: * If there is a queue (for usage with AsyncLLM), put the RequestOutput objects into the queue for handling by the per-request generate() tasks.
* If there is no queue (for usage with LLMEngine),
return a list of RequestOutput objects.
NOTE FOR DEVELOPERS
vLLM V1 minimizes the number of python loops over the full batch to ensure system overheads are minimized. This is the only function that should loop over EngineCoreOutputs.
If you need to touch every element of the batch, do it from within the loop below.
propagate_error(e)
¶
Propagate error to all generate() tasks.
RequestOutputCollector
¶
Collects streamed RequestOutputs per individual request, for hand-off to the consuming asyncio generate task.
When streaming deltas, RequestOutputs are merged if the producer gets ahead of the consumer.
Methods:
-
get–Get operation blocks on put event.
-
get_nowait–Non-blocking get operation.
-
put–Non-blocking put operation.
RequestState
¶
Methods:
-
track_weight_version–Start a span when the weight version changes.
track_weight_version(weight_version)
¶
Start a span when the weight version changes.
StreamingInputOutputCollector
¶
Bases: RequestOutputCollector
Collector for streaming-input requests. Doesn't merge across input chunk boundaries (a finish_reason on a non-finished output).
StreamingUpdate
dataclass
¶
Streaming input update data for output processor.
Contains the incremental prompt data to be applied to a request state when the current sub-request completes.
_is_chunk_boundary(output)
¶
Whether the output marks the end of a streaming-input chunk: a finish_reason on a request that has not finished.