vllm.models.deepseek_v41.nvidia.specialized_decode.runtime.metadata_graphs
¶
CUDA graphs of the attention metadata builds of FULL decode steps.
A FULL CUDA graph replays the forward only: before every replay the runner
still builds the attention metadata on the host, which refreshes the persistent
buffers the graph reads. For small decode batches that build costs about as
much as the replay. AttnMetadataCudaGraphs records, during CUDA graph
capture, the build of every uniform decode batch shape that a FULL decode graph
serves, and replays it on the steps of that shape, returning the metadata
objects captured with it. A step of a shape without a recording builds its
metadata eagerly.
Classes:
-
AttnMetadataCudaGraphs–Records attention metadata builds by graph key during CUDA graph
AttnMetadataCudaGraphs
¶
Records attention metadata builds by graph key during CUDA graph capture, and replays them.
Each key is built once eagerly, warming lazy allocations, kernel compilation and per-stream library state, then recorded with the metadata it returns. The graphs write the builders' buffers at their capture-time addresses: every capture releases and records them again.
Methods:
-
can_record–Whether every metadata builder of
attn_groupsis recordable. -
capture–Record the build of
keyin the global CUDA graph pool, which the -
capture_keys–The keys of the decode steps the FULL decode graphs serve, largest
-
key–The graph key of a step whose metadata build can be recorded, or None.
-
release–Drop the recorded builds.
-
replay–Replay the build of
keyand return its metadata, or None if the
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/runtime/metadata_graphs.py
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 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 | |
_forked_build(attn_groups, block_tables, build_fn)
¶
Build the attention groups as concurrent branches on side streams.
The groups share only read-only inputs, with two exceptions. The sparse
MLA and compressor builders clamp their block table in place, so the
groups of one block table storage build on one branch, in serial order;
the groups that only read the table (_BLOCK_TABLE_READERS) then
build on branches of their own, each started after that branch. And
the first group that needs the token-to-request map builds it into its
own buffer, which later groups reuse. Each branch builds its own map;
the serial build's producer is also the first of its branch to need
one, so it fills the buffer that the FULL forward graphs read.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/runtime/metadata_graphs.py
can_record(attn_groups)
¶
Whether every metadata builder of attn_groups is recordable.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/runtime/metadata_graphs.py
capture(key, attn_groups, block_tables, build_fn)
¶
Record the build of key in the global CUDA graph pool, which the
FULL forward graphs and memory profiling use; returns its metadata.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/runtime/metadata_graphs.py
capture_keys()
¶
The keys of the decode steps the FULL decode graphs serve, largest first.
The graphs are the ones CudaGraphManager captures, and a step runs
the smallest graph that holds its requests. Under dynamic speculative
decoding only the widest query length is recorded; steps of the
narrower tiers build their metadata eagerly.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/runtime/metadata_graphs.py
key(input_batch, cudagraph_mode)
staticmethod
¶
The graph key of a step whose metadata build can be recorded, or None.
Only FULL steps of uniform decodes qualify; their key fixes every host
value the build reads. Under adaptive verification (max_query_len
set) the device splits the drafts, so the host query lengths are only
bounds.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/runtime/metadata_graphs.py
release()
¶
replay(key)
¶
Replay the build of key and return its metadata, or None if the
key was not recorded.