vllm.models.nemotron_shortcut.nvidia.sdsa.attention
¶
Classes:
-
SdsaAttention–The indexer selects each query's Top-K keys into
topk_indices, an -
SdsaBuffers–The selection buffers that the SDSA layers of a model share: each query
-
SdsaIndexerCache–The indexer's key cache, a key's value and scale bytes per key. It shares the
Functions:
-
allocate_sdsa_buffers–The buffers of a model's SDSA layers, for K =
top_k. The union core's
SdsaAttention
¶
Bases: Module
The indexer selects each query's Top-K keys into topk_indices, an
int32 buffer of top_k-slot rows shared by all SDSA layers: a decode token's
as key positions, prefill tokens' as their groups' unions of core cache
slots (SdsaPrefillPlan.run); the core attends to them.
Methods:
-
load_weights–Load the KV cache scales into the core attention, which holds the KV
-
select–Cache the key and write the query rows in the keys' format, then
Source code in vllm/models/nemotron_shortcut/nvidia/sdsa/attention.py
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 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 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 | |
_fused_decode(metadata, mine, query, query_scales, key_cache, key_scales, out, workspace)
¶
The fused selector on decode requests mine (query: their rows), one
128-row tile each, into the rows of out of the requests it routes.
Source code in vllm/models/nemotron_shortcut/nvidia/sdsa/attention.py
load_weights(weights)
¶
Load the KV cache scales into the core attention, which holds the KV
cache; vLLM's loader names them after this module (attn.k_scale).
Scales the core lacks are skipped. Without a checkpoint query scale, a
quantized cache quantizes the query with the key scale. The loader may
hand the scales over in several calls, in any order, so the query scale
follows the key scale only while it is still unset (negative): a
checkpoint query scale loaded before or after replaces it.
Source code in vllm/models/nemotron_shortcut/nvidia/sdsa/attention.py
select(query, key)
¶
Cache the key and write the query rows in the keys' format, then select every row's Top-K keys: the decode rows', as key positions, then the prefill rows', as their groups' unions. The profiling run instead reserves the scratch memory and gvr_2's tables.
Source code in vllm/models/nemotron_shortcut/nvidia/sdsa/attention.py
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 | |
SdsaBuffers
dataclass
¶
The selection buffers that the SDSA layers of a model share: each query
row's Top-K slots (topk_indices) and the union core's mask rows (mask).
They are zeroed: trtllm-gen loads the slots past a prefill union's size in
its last key tile (masked), so they must never point outside the KV cache.
Source code in vllm/models/nemotron_shortcut/nvidia/sdsa/attention.py
SdsaIndexerCache
¶
Bases: DeepseekV32IndexerCache
The indexer's key cache, a key's value and scale bytes per key. It shares the
core's KV cache group, so one block table and one slot mapping locate both.
Each PAGE-key page holds its keys, then their scales (indexer_pages).
This class is vLLM's indexer key cache (DeepseekV32IndexerCache). Thus vLLM
sizes, allocates and binds it as it does there. It holds the layer's
SdsaConfig, which the indexer's metadata builder reads.
Source code in vllm/models/nemotron_shortcut/nvidia/sdsa/attention.py
_split_at_indexer(vllm_config)
¶
Refuse a compilation config that does not split at the indexer op: an Inductor graph partition, stock torch.compile, or splitting_ops without the op (one full graph) cannot order the core after the indexer.
Source code in vllm/models/nemotron_shortcut/nvidia/sdsa/attention.py
allocate_sdsa_buffers(vllm_config, top_k)
¶
The buffers of a model's SDSA layers, for K = top_k. The union core's
groups are the largest. A request's last group may be partial, hence the
extra rows, as are the last TP rank's decode rows (select), 1 + k per
request with k drafts.