vllm.models.step5.nvidia.ops.sparse_prefill_pages
¶
Compact eight-token pages for sparse prefill attention.
Classes:
-
CompactPagedPrefill–One native attention plan for a full prefill step, shared by DSA layers.
-
StagedPrefillPages–Request pages remapped into a contiguous single-group BF16 buffer.
Functions:
-
fill_prefill_pages–Emit compact pages and copy
queryintocontiguous_query. -
kv_page_stride–Eight-token pages between consecutive blocks of a
[B, H, N, C]cache. -
plan_staged_prefill_pages–Map every live page of each request to a dense staging page.
-
stage_prefill_pages–Copy one KV group's pages into
[pages, 1, block, 2 * dim]dtype. -
view_sparse_kv_pages–View eight-token pages, retaining gaps between blocks and KV groups.
CompactPagedPrefill
¶
One native attention plan for a full prefill step, shared by DSA layers.
Methods:
-
fixup_positions–Replace upper-bound page ranges with exact device positions.
-
plan–Plan from host positions, which may be per-row upper bounds.
Source code in vllm/models/step5/nvidia/ops/sparse_prefill_pages.py
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 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | |
fixup_positions(positions)
¶
Replace upper-bound page ranges with exact device positions.
With split KV disabled each FA2 CTA reads its row's range from these device buffers at run time, so shorter exact ranges are safe.
Source code in vllm/models/step5/nvidia/ops/sparse_prefill_pages.py
plan(query_shape, dtype, device, positions, region_count, scale, block_size, *, contiguous_query=True)
¶
Plan from host positions, which may be per-row upper bounds.
Runs before the forward (in the metadata builder) and issues no
blocking copies; see fixup_positions for exact device positions.
Source code in vllm/models/step5/nvidia/ops/sparse_prefill_pages.py
StagedPrefillPages
¶
Bases: NamedTuple
Request pages remapped into a contiguous single-group BF16 buffer.
Source code in vllm/models/step5/nvidia/ops/sparse_prefill_pages.py
fill_prefill_pages(regions, table, owners, indptr, pages, block_size, query, contiguous_query, page_stride)
¶
Emit compact pages and copy query into contiguous_query.
Source code in vllm/models/step5/nvidia/ops/sparse_prefill_pages.py
kv_page_stride(cache)
¶
Eight-token pages between consecutive blocks of a [B, H, N, C] cache.
Blocks may be strided (sliced KV groups, block-outer layouts) as long as the block stride is a whole number of eight-token pages.
Source code in vllm/models/step5/nvidia/ops/sparse_prefill_pages.py
plan_staged_prefill_pages(table, lengths, block_size)
¶
Map every live page of each request to a dense staging page.
Source code in vllm/models/step5/nvidia/ops/sparse_prefill_pages.py
stage_prefill_pages(cache, staged, dtype, k_scale=None, v_scale=None)
¶
Copy one KV group's pages into [pages, 1, block, 2 * dim] dtype.
This lets FP8 and multi-group (strided) caches use the paged prefill kernels, which need contiguous model-dtype pages.
Source code in vllm/models/step5/nvidia/ops/sparse_prefill_pages.py
view_sparse_kv_pages(cache)
¶
View eight-token pages, retaining gaps between blocks and KV groups.