vllm.v1.worker.gpu.spec_decode.draft_logits
¶
Classes:
-
DraftLogitsCache–Pre-temperature draft logits, cached by a draft step for the next
Functions:
-
draft_logits_row–Row of a request in this rank's draft logits cache, or -1 if no row.
DraftLogitsCache
¶
Pre-temperature draft logits, cached by a draft step for the next verification.
A replicated cache holds every request on every TP rank, at row req_state_idx.
A sharded cache (batch-sharded sampling) holds on each TP rank only the requests that rank verifies. Every draft step gives the request at batch position i to rank i % tp, at row i // tp of its cache, so no rank caches more than cdiv(num_reqs, tp) requests however the request slots are spread.
Rows are reused every step. A request that the scheduler skips for a step
keeps its drafts, but its row may since have been given to another
request. inverse_row_mapping detects this, and stale_drafts marks those
drafts invalid, so verification rejects them and samples from the target.
Methods:
-
assign–Give a sharded cache's rows out by batch position. Call after
-
owners_of–The TP rank that verifies each of a batch's requests: the rank that
-
stale_drafts–Mark the drafts whose draft logits were overwritten since drafting.
Source code in vllm/v1/worker/gpu/spec_decode/draft_logits.py
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 | |
assign(idx_mapping, idx_mapping_np)
¶
Give a sharded cache's rows out by batch position. Call after verification and before the draft step writes the draft logits.
Source code in vllm/v1/worker/gpu/spec_decode/draft_logits.py
owners_of(idx_mapping_np)
¶
The TP rank that verifies each of a batch's requests: the rank that cached its draft logits, or for a replicated cache, round-robin over batch positions.
Returns:
-
ndarray–[num_reqs] each request's owner, and the [max_num_reqs] device owner
-
Tensor | None–table, or None for a replicated cache.
Source code in vllm/v1/worker/gpu/spec_decode/draft_logits.py
stale_drafts(input_batch)
¶
Mark the drafts whose draft logits were overwritten since drafting. Only valid for requests this rank owns.
Returns:
-
Tensor | None–[num_logits] True for each stale draft, or None for a replicated
-
Tensor | None–cache, whose rows are never reused.
Source code in vllm/v1/worker/gpu/spec_decode/draft_logits.py
draft_logits_row(req_state_idx, row_mapping_ptr)
¶
Row of a request in this rank's draft logits cache, or -1 if no row.
row_mapping_ptr is None for a replicated cache, which is indexed by request
state. Otherwise it is DraftLogitsCache.row_mapping.