vllm.v1.spec_decode.draft_model ¶
DraftModelProposer ¶
Bases: SpecDecodeBaseProposer
Source code in vllm/v1/spec_decode/draft_model.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 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 | |
__init__ ¶
__init__(
vllm_config: VllmConfig, device: device, runner=None
)
Source code in vllm/v1/spec_decode/draft_model.py
_raise_if_draft_tp_mismatch ¶
Source code in vllm/v1/spec_decode/draft_model.py
_raise_if_mrope ¶
_raise_if_multimodal ¶
_raise_if_padded_drafter_batch_disabled ¶
Source code in vllm/v1/spec_decode/draft_model.py
_raise_if_vocab_size_mismatch ¶
load_model ¶
load_model(target_model: Any) -> None
Takes target_model to satisfy the type checker.
Source code in vllm/v1/spec_decode/draft_model.py
set_inputs_first_pass ¶
set_inputs_first_pass(
target_token_ids: Tensor,
next_token_ids: Tensor,
target_positions: Tensor,
last_token_indices: Tensor | None,
cad: CommonAttentionMetadata,
num_rejected_tokens_gpu: Tensor | None,
) -> tuple[int, Tensor, CommonAttentionMetadata]
Source code in vllm/v1/spec_decode/draft_model.py
compute_new_slot_mapping ¶
compute_new_slot_mapping(
cad: CommonAttentionMetadata,
new_positions: Tensor,
is_rejected_token_mask: Tensor,
block_size: int,
max_model_len: int,
)
Source code in vllm/v1/spec_decode/draft_model.py
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 draft model. The vllm_config is useful when loading the draft model with get_model().
Source code in vllm/v1/spec_decode/draft_model.py
merge_toks_kernel ¶
merge_toks_kernel(
target_toks_ptr,
next_toks_ptr,
query_start_locs_ptr,
query_end_locs_ptr,
out_ptr_merged_toks,
out_ptr_is_rejected_tok,
target_toks_size,
rejected_tok_fill,
)
Merges the target_toks_ptr and the next_toks_ptr into a new tensor called out_ptr_merged_toks. Rejected tokens are those after the query_end_locs_ptr and before the next query_start_locs_ptr. Fills the rejected tokens positions with the value rejected_tok_fill. Also fills a mask of the rejected tokens in out_ptr_is_rejected_tok.