vllm.models.deepseek_v41.nvidia.specialized_decode.runtime.draft
¶
The specialized decode of the DSpark draft model.
With DSpark speculative decoding, a few extra DeepSeek-V4.1 decoder layers
(DSparkDeepseekV4Model) draft the next tokens from the target's hidden
states after every target step, in CUDA graphs of their own. DraftDecode
runs those layers for the FULL-graph pure decode steps, as SpecializedDecode
runs the target's, through the same per-layer steps and on the kernels and
streams the target's executor owns: the fused all-reduce + mHC kernel and its
Lamport mailbox, the publishing wo_b GEMM and the mHC side stream. The
draft runs between target steps on the same stream, so sharing them needs no
synchronization beyond the stream order.
The draft's layers differ from the target's in ways the steps take as parameters:
- the first layer takes
[n, hc, H]streams, the embedding expanded to the hc copies, through its own mHC pre (Boundaries.first); - the layers are built as stock layers, which reduce
wo_band the MoE themselves;AttentionStepprojectswo_bwithout that all-reduce andMoEStepruns the runner's body, so both stay TP-partial for the next boundary's fused kernel; - each layer finalizes its MoE (the fused kernel's finalize is built for the
target's top-k): up to
LOW_BATCH_MAX_ROWSrows on the low-batch GEMMs, without the target's fused front, and the finalize kernel; - the last boundary reduces that plain tensor in the fused kernel's
residual-only variant, and the streams are collapsed with the last pre-mix,
before the final norm, which
compute_logitsapplies.
The layers are sliding-window only: they share each SWA KV-cache group's
sparse-index table (SparseIndexTables), and the sparse MLA keeps the stock
decode's wide non-causal window of the draft tokens.
The target's model state builds this executor after the target's, on every TP
rank in the same order, and warms its GEMMs up with the target's. Every
forward that plan refuses runs the stock layers.
Classes:
-
DraftDecode–The decode executor over the DSpark draft model's layers.
Functions:
-
check_low_batch_graph–Log when no DSpark draft CUDA graph is small enough for the low-batch
DraftDecode
¶
The decode executor over the DSpark draft model's layers.
Methods:
-
plan–The step this forward runs, or None to run the stock layers: as for
-
run–The draft layers and the collapse of the step on the hc streams
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/runtime/draft.py
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 | |
plan(positions)
¶
The step this forward runs, or None to run the stock layers: as for
the target, only FULL CUDA graph captures of pure decode steps of up to
FUSED_MHC_MAX_ROWS rows run the executor.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/runtime/draft.py
run(step, x, positions, input_ids, engram_hashes=None, engram_mask=None, streams=None)
¶
The draft layers and the collapse of the step on the hc streams
x ([n, hc, H]); returns the pre-norm hidden state, as
DSparkDeepseekV4Model.forward does. The draft has no Engram
layers and no executor embedding, so engram_hashes,
engram_mask and streams stay None.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/runtime/draft.py
check_low_batch_graph(vllm_config)
¶
Log when no DSpark draft CUDA graph is small enough for the low-batch
GEMMs: the drafter captures its FULL graphs per request count, n requests
of draft rows for each n in decode_cudagraph_capture_request_sizes, so a
one-request graph needs 1 in that list.