fused_paged_tq4_int8_prefill
turboquant_vllm.triton.fused_paged_tq4_int8_prefill ¶
Fused paged TQ4 INT8 prefill attention -- IMMA tensor core path.
Phase 3b of the D9 kernel roadmap. This kernel reads TQ4-compressed
blocks directly from vLLM's paged block table, decompresses in SRAM,
re-quantizes Q and K to INT8 per-tile, and computes Q@K^T via IMMA
tensor cores (mma.sync.aligned.m16n8k32.s8.s8.s32). P@V
accumulation stays in FP16 HMMA.
Designed for prefill (BLOCK_M=64, compute-bound) where INT8 tensor
cores provide 1.3-2x speedup over FP16. Decode uses the separate
FP16 kernel (fused_paged_tq4_attention.py, BLOCK_M=1,
memory-bound where INT8 provides no benefit).
The kernel operates in rotated space: caller pre-rotates Q by
Pi^T and post-rotates the output by Pi. QJL correction is
deferred (placeholders in signature, compiled out via constexpr).
Autotune: 4 configs (BLOCK_N in {16, 32} x stages=1 x warps {4, 8}). Stages {2, 3} dropped after Experiment 021 profiling showed them 3-5x slower than single-stage at 1K-2K prefill on RTX 4090.
Attributes:
| Name | Type | Description |
|---|---|---|
fused_paged_tq4_int8_prefill |
Tensor
|
Python wrapper that pre-rotates Q, launches the INT8 prefill kernel, and post-rotates the output. |
Examples:
from turboquant_vllm.triton.fused_paged_tq4_int8_prefill import (
fused_paged_tq4_int8_prefill,
)
out = fused_paged_tq4_int8_prefill(
q,
kv_cache,
block_table,
seq_lens,
centroids,
rotation,
num_kv_heads=4,
head_dim=128,
block_size=16,
)
See Also
:mod:turboquant_vllm.triton.fused_paged_tq4_attention: FP16
decode kernel (BLOCK_M=1).
:mod:turboquant_vllm.triton.tq4_decompress: Standalone decompress.
Functions¶
fused_paged_tq4_int8_prefill ¶
fused_paged_tq4_int8_prefill(
q: Tensor,
kv_cache: Tensor,
block_table: Tensor,
seq_lens: Tensor,
centroids: Tensor,
rotation: Tensor,
num_kv_heads: int,
head_dim: int,
block_size: int,
sm_scale: float | None = None,
out: Tensor | None = None,
) -> Tensor
Fused paged TQ4 INT8 prefill attention.
Pre-rotates Q by rotation^T, launches the INT8 prefill kernel
that decompresses TQ4 blocks in-tile and uses IMMA tensor cores for
Q@K^T, then post-rotates the output to return to original space.
Designed for prefill (multiple queries per sequence, compute-bound).
For decode (single query, memory-bound), use
:func:fused_paged_tq4_decode instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
q
|
Tensor
|
Query |
required |
kv_cache
|
Tensor
|
Packed paged cache |
required |
block_table
|
Tensor
|
Page table |
required |
seq_lens
|
Tensor
|
Sequence lengths |
required |
centroids
|
Tensor
|
TQ4 codebook |
required |
rotation
|
Tensor
|
Orthogonal rotation |
required |
num_kv_heads
|
int
|
Number of KV heads. |
required |
head_dim
|
int
|
Head dimension (e.g. 128). |
required |
block_size
|
int
|
vLLM page size (tokens per block). |
required |
sm_scale
|
float | None
|
Softmax scale. Defaults to |
None
|
out
|
Tensor | None
|
Optional pre-allocated output |
None
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Attention output |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/turboquant_vllm/triton/fused_paged_tq4_int8_prefill.py
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 | |