vllm.worker.cpu_enc_dec_model_runner
CPUEncoderDecoderModelRunner
¶
Bases: CPUModelRunnerBase[EncoderDecoderModelInputForCPU]
Source code in vllm/worker/cpu_enc_dec_model_runner.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 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 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
|
_builder_cls
class-attribute
instance-attribute
¶
_builder_cls: Type[ModelInputForCPUBuilder] = (
ModelInputForCPUBuilder
)
_model_input_cls
class-attribute
instance-attribute
¶
_model_input_cls: Type[EncoderDecoderModelInputForCPU] = (
EncoderDecoderModelInputForCPU
)
_list_to_int32_tensor
¶
_list_to_long_tensor
¶
_prepare_encoder_model_input_tensors
¶
_prepare_encoder_model_input_tensors(
seq_group_metadata_list: List[SequenceGroupMetadata],
model_input: EncoderDecoderModelInputForCPU,
) -> Tuple[
AttentionMetadata, Optional[Tensor], Optional[Tensor]
]
Helper method to prepare the encoder- and cross-attn-related
model inputs based on a given sequence group. These additional inputs
are used to augment an already-computed EncoderDecoderModelInput
data structure which already has decoder-related model inputs
populated.
Sets the following attn_metadata fields:
* num_encoder_tokens
* encoder_seq_lens
* encoder_seq_lens_tensor
* max_encoder_seq_len
* cross_slot_mapping
* cross_block_tables
Constructs a new model inputs data structure, based on
(1) the existing fields in the model_inputs
argument,
and (2) the following additional fields which are
computed (or in the case of attn_metadata
, updated)
by this function:
* attn_metadata
* encoder_input_tokens
* encoder_input_positions
Arguments:
- seq_group_metadata_list: list of sequence groups for which to compute inputs
- model_inputs: model inputs data structure with decoder-oriented fields already computed.
Return:
- Updated model inputs data structure
Source code in vllm/worker/cpu_enc_dec_model_runner.py
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 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
|
execute_model
¶
execute_model(
model_input: EncoderDecoderModelInputForCPU,
kv_caches: List[Tensor],
intermediate_tensors: Optional[
IntermediateTensors
] = None,
num_steps: int = 1,
) -> Optional[List[SamplerOutput]]
Source code in vllm/worker/cpu_enc_dec_model_runner.py
make_model_input_from_broadcasted_tensor_dict
¶
make_model_input_from_broadcasted_tensor_dict(
tensor_dict: Dict[str, Any],
) -> EncoderDecoderModelInputForCPU
Source code in vllm/worker/cpu_enc_dec_model_runner.py
prepare_model_input
¶
prepare_model_input(
seq_group_metadata_list: List[SequenceGroupMetadata],
virtual_engine: int = 0,
finished_requests_ids: Optional[List[str]] = None,
) -> EncoderDecoderModelInputForCPU
Source code in vllm/worker/cpu_enc_dec_model_runner.py
EncoderDecoderModelInputForCPU
dataclass
¶
Bases: ModelInputForCPUWithSamplingMetadata
Used by the EncoderDecoderModelRunner.
Source code in vllm/worker/cpu_enc_dec_model_runner.py
encoder_input_positions
class-attribute
instance-attribute
¶
encoder_input_tokens
class-attribute
instance-attribute
¶
__init__
¶
__init__(
input_tokens: Optional[Tensor] = None,
input_positions: Optional[Tensor] = None,
token_type_ids: Optional[Tensor] = None,
attn_metadata: Optional[AttentionMetadata] = None,
multi_modal_kwargs: Optional[
BatchedTensorInputs
] = None,
virtual_engine: Optional[int] = None,
seq_lens: Optional[List[int]] = None,
query_lens: Optional[List[int]] = None,
lora_mapping: Optional[LoRAMapping] = None,
lora_requests: Optional[Set[LoRARequest]] = None,
sampling_metadata: Optional[SamplingMetadata] = None,
is_prompt: Optional[bool] = None,
encoder_input_tokens: Optional[Tensor] = None,
encoder_input_positions: Optional[Tensor] = None,
) -> None
as_broadcastable_tensor_dict
¶
Source code in vllm/worker/cpu_enc_dec_model_runner.py
from_broadcasted_tensor_dict
classmethod
¶
from_broadcasted_tensor_dict(
tensor_dict: Dict[str, Any],
attn_backend: Optional[AttentionBackend] = None,
) -> EncoderDecoderModelInputForCPU