vllm.v1.outputs ¶
Classes:
-
AsyncModelRunnerOutput– -
LogprobsTensors– -
ModelRunnerOutput– -
RoutedExpertsLists–CPU-side routed experts, the form :meth:
RoutedExpertsManager.store_batch -
RoutedExpertsTensors–Device-side snapshot of routed experts data, pending async D2H.
-
SamplingMaskLists–
Functions:
-
make_empty_encoder_model_runner_output–Create a ModelRunnerOutput stub that contains the correct
AsyncModelRunnerOutput ¶
Bases: ABC
Methods:
-
get_output–Get the ModelRunnerOutput for this async output.
Source code in vllm/v1/outputs.py
get_output() abstractmethod ¶
Get the ModelRunnerOutput for this async output.
This is a blocking call that waits until the results are ready, which might involve copying device tensors to the host. This method should only be called once per AsyncModelRunnerOutput.
Source code in vllm/v1/outputs.py
LogprobsTensors ¶
Bases: NamedTuple
Methods:
-
cat–Concatenate flattened logprob tensors.
-
empty_cpu–Create empty LogprobsTensors on CPU.
-
filter–Filter the logprobs tensors with the given bool mask.
Source code in vllm/v1/outputs.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | |
cat(tensors, cu_num_generated_tokens=None) staticmethod ¶
Concatenate flattened logprob tensors.
Source code in vllm/v1/outputs.py
empty_cpu(num_positions, num_tokens_per_position) staticmethod ¶
Create empty LogprobsTensors on CPU.
Source code in vllm/v1/outputs.py
filter(mask) ¶
Filter the logprobs tensors with the given bool mask.
Source code in vllm/v1/outputs.py
ModelRunnerOutput dataclass ¶
Methods:
-
with_ec_conn_output–Return
outputcarryingec_connector_output. -
with_ec_conn_output_only–Return an otherwise-empty output carrying
ec_connector_output. -
with_kv_conn_output_only–Return ModelRunnerOutput containing the provided KVConnectorOutput,
Source code in vllm/v1/outputs.py
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 | |
with_ec_conn_output(output, ec_connector_output) staticmethod ¶
Return output carrying ec_connector_output.
The shared empty output is copied rather than written to, so callers must use the return value.
Source code in vllm/v1/outputs.py
with_ec_conn_output_only(ec_connector_output) staticmethod ¶
Return an otherwise-empty output carrying ec_connector_output.
Source code in vllm/v1/outputs.py
with_kv_conn_output_only(kv_connector_output) staticmethod ¶
Return ModelRunnerOutput containing the provided KVConnectorOutput, otherwise empty. Returns None if kv_connector_output is passed as None.
Source code in vllm/v1/outputs.py
RoutedExpertsLists ¶
Bases: NamedTuple
CPU-side routed experts, the form :meth:RoutedExpertsManager.store_batch consumes.
Batched per scheduler step: the leading dim is the number of tokens scheduled across all requests in this step (total_num_scheduled_tokens), not per-request tokens. slot_mapping[i] tells the scheduler which physical KV-cache slot row i of routing_data belongs to.
Source code in vllm/v1/outputs.py
RoutedExpertsTensors ¶
Bases: NamedTuple
Device-side snapshot of routed experts data, pending async D2H.
Produced by :class:GPUModelRunner at the end of each async-scheduled step. The copy stream waits on the default stream, then issues non-blocking D2H via :meth:to_cpu_nonblocking into a pinned CPU buffer; :class:AsyncGPUModelRunnerOutput.get_output synchronizes the copy before the scheduler reads it.
Sliced to total_num_scheduled_tokens (step-level, across all requests — NOT per-request). Both routing_data and slot_mapping must be private clones when sourced from shared capturer / prepare-input buffers, so the next forward pass / _prepare_inputs on the default stream does not race with a D2H still pending on the copy stream.
Methods:
-
to_cpu_nonblocking–Issue non-blocking D2H on the current stream.
-
tolists–Convert to the numpy-backed form consumed by the scheduler.
Source code in vllm/v1/outputs.py
to_cpu_nonblocking() ¶
Issue non-blocking D2H on the current stream.
NOTE: non_blocking=True only delivers true overlap when the CPU target is pinned. The current fallback here allocates a new pageable CPU tensor per call, which silently degrades to a synchronous copy; acceptable because the sync happens on the dedicated copy stream, not the default stream.
Source code in vllm/v1/outputs.py
tolists() ¶
Convert to the numpy-backed form consumed by the scheduler.
.cpu() is a no-op when the tensor is already on CPU, so this is cheap for the post-D2H case; for raw device tensors it will synchronously block, which is only reached in tests.
Source code in vllm/v1/outputs.py
SamplingMaskLists ¶
Bases: NamedTuple
Methods:
-
to_nested_list–Convert CSR representation to
list[list[int]].
Source code in vllm/v1/outputs.py
to_nested_list() ¶
Convert CSR representation to list[list[int]].
make_empty_encoder_model_runner_output(scheduler_output) ¶
Create a ModelRunnerOutput stub that contains the correct per-request bookkeeping but no generated data yet.