vllm.model_executor.models.qwen3_dspark ¶
Qwen3 DSpark draft model for semi-autoregressive drafting.
DSpark drafts a whole block in one parallel pass (DFlash-style: context-KV precompute + a non-causal query-block forward) and then injects intra-block dependency with a lightweight sequential Markov head.
The parallel backbone is a standard Qwen3 decoder stack reused from the DFlash Qwen3 draft (see qwen3_dflash.py). DSpark adds: * markov_head: low-rank V x r / r x V transition bias added to the base logits, sampled left-to-right by the speculator (the sequential stage). * confidence_head: per-position acceptance-probability estimate.
DSparkMarkovHead and DSparkConfidenceHead are shared with the DSV4-style DSpark model.
Classes:
-
DSparkConfidenceHead–DSpark acceptance-confidence head.
-
DSparkMarkovHead–Sequential transition-bias head (low-rank V x r, r x V).
-
Qwen3DSparkForCausalLM– -
Qwen3DSparkModel–DFlash Qwen3 backbone + DSpark Markov / confidence heads.
DSparkConfidenceHead ¶
Bases: Module
DSpark acceptance-confidence head.
Source code in vllm/model_executor/models/qwen3_dspark.py
DSparkMarkovHead ¶
Bases: Module
Sequential transition-bias head (low-rank V x r, r x V).
markov_w1[token] embeds the previously sampled token (target vocab, vocab_size); markov_w2 projects it to a draft-vocab bias (draft_vocab_size) added to the base draft logits. The two sizes coincide for full-vocab drafts.
Both weights are replicated because the head runs sequentially for every draft position. Sharding them would add an all-reduce and a full-vocab gather to each position.
Methods:
-
apply_bias_gathered–Apply the Markov bias only to selected rows of
logits. -
bias–Vocab-size transition bias from a Markov embedding ([B, r] -> [B, V]).
-
embed–r-dim Markov embedding of
token_ids([B] -> [B, r]).
Source code in vllm/model_executor/models/qwen3_dspark.py
apply_bias_gathered(markov_embed, logits, values, index, scale=1.0) ¶
Apply the Markov bias only to selected rows of logits.
The caller initializes logits to -inf once for all draft positions. This method scatters the corrected candidate values into that dense buffer so the normal sampler sees the truncated proposal.
Source code in vllm/model_executor/models/qwen3_dspark.py
bias(markov_embed, logits_processor) ¶
Vocab-size transition bias from a Markov embedding ([B, r] -> [B, V]).
Source code in vllm/model_executor/models/qwen3_dspark.py
Qwen3DSparkForCausalLM ¶
Bases: DFlashQwen3ForCausalLM
Methods:
-
compute_confidence–Per-position acceptance probability for each drafted token.
Source code in vllm/model_executor/models/qwen3_dspark.py
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 | |
compute_confidence(head_hidden, markov_embed) ¶
Per-position acceptance probability for each drafted token.
Source code in vllm/model_executor/models/qwen3_dspark.py
Qwen3DSparkModel ¶
Bases: DFlashQwen3Model
DFlash Qwen3 backbone + DSpark Markov / confidence heads.