vllm.v1.spec_decode.utils ¶
copy_and_expand_eagle_inputs_kernel ¶
copy_and_expand_eagle_inputs_kernel(
target_token_ids_ptr,
target_positions_ptr,
next_token_ids_ptr,
out_input_ids_ptr,
out_positions_ptr,
out_is_rejected_token_mask_ptr,
out_is_masked_token_mask_ptr,
out_new_token_indices_ptr,
out_hidden_state_mapping_ptr,
query_start_loc_ptr,
query_end_loc_ptr,
padding_token_id,
parallel_drafting_token_id,
total_input_tokens,
num_padding_slots_per_request,
shift_input_ids,
BLOCK_SIZE_TOKENS: constexpr,
)
Copy and expand inputs from the target model to the drafting buffers for Eagle speculative decoding. This kernel handles padding slots and parallel drafting tokens, if enabled.
Source code in vllm/v1/spec_decode/utils.py
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 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 | |
create_vllm_config_for_draft_model ¶
create_vllm_config_for_draft_model(
target_model_vllm_config: VllmConfig,
) -> VllmConfig
The vllm_config is configured for the target model, e.g. its quant_config and parallel_config. But the draft model is potentially quantized differently, and has potentially different tensor_parallel_size. This function creates a new vllm_config configured for the drafter. The vllm_config is useful when loading the draft model with get_model().
Source code in vllm/v1/spec_decode/utils.py
eagle_prepare_inputs_padded_kernel ¶
eagle_prepare_inputs_padded_kernel(
cu_num_draft_tokens_ptr,
valid_sampled_tokens_count_ptr,
query_start_loc_gpu_ptr,
token_indices_to_sample_ptr,
num_rejected_tokens_gpu_ptr,
num_reqs,
)
Fused kernel for Eagle prepare_input_padded. This kernel computes the token index to sample for each request, taking into account the number of draft tokens and the number of valid sampled tokens (which is one more than the number of accepted tokens).
Source code in vllm/v1/spec_decode/utils.py
eagle_prepare_next_token_padded_kernel ¶
eagle_prepare_next_token_padded_kernel(
sampled_token_ids_ptr,
discard_request_mask_ptr,
backup_next_token_ids_ptr,
next_token_ids_ptr,
valid_sampled_tokens_count_ptr,
vocab_size,
num_sampled_tokens_per_req,
num_reqs,
stride_sampled_token_ids,
BLOCK_SIZE_TOKENS: constexpr,
)
Fused kernel for Eagle prepare_next_token_ids_padded. This kernel computes the number of valid (1 + accepted) tokens for each request, and the corresponding "next" token id to sample from during speculative decoding. This is the "last accepted token" from the sampled tokens, or the backup token if no tokens were accepted or if the request is marked as discarded.
Source code in vllm/v1/spec_decode/utils.py
extend_all_queries_by_N ¶
extend_all_queries_by_N(
common_attn_metadata: CommonAttentionMetadata,
N: int,
arange: Tensor,
new_slot_mapping: Tensor,
) -> CommonAttentionMetadata
Creates a new CommonAttentionMetadata with all query lengths increased by N. Also all seq lens are increased by N. This is useful e.g. in speculative decoding with parallel drafting, where we extend each sequence by N tokens and predict all tokens in one pass. The slot mapping is computed externally, as it requires more information.