[nv] add pcp support in dsv3.2 (#52046)

Signed-off-by: Summer Yang <girasoleyang@gmail.com>
This commit is contained in:
Summer Yang
2026-08-18 14:59:08 -07:00
committed by GitHub
parent d3fafe0c27
commit 5f7a20b316
6 changed files with 376 additions and 119 deletions
@@ -177,3 +177,48 @@ def test_short_prefill_updates_k_cache_before_scoring_decision(
# K cache is always updated before the scoring decision.
torch.testing.assert_close(observed["k"], k[: slot_mapping.numel()])
assert observed["slots"] is slot_mapping
def test_skipped_k_cache_insert_accepts_no_k(
monkeypatch: pytest.MonkeyPatch,
) -> None:
indexer_metadata = make_indexer_metadata(
num_prefills=0,
num_prefill_tokens=0,
slot_mapping=torch.empty(0, dtype=torch.long),
)
monkeypatch.setattr(
sparse_indexer,
"get_forward_context",
lambda: SimpleNamespace(
attn_metadata={INDEXER_LAYER: indexer_metadata},
cudagraph_runtime_mode=CUDAGraphMode.PIECEWISE,
),
)
monkeypatch.setattr(
sparse_indexer.current_platform, "fp8_dtype", lambda: torch.float16
)
topk_indices = torch.full((1, 2048), 17, dtype=torch.int32)
result = sparse_indexer.sparse_attn_indexer(
torch.empty(1, 1),
INDEXER_LAYER,
torch.empty(1),
torch.empty(1, 1),
None,
None,
torch.empty(1, 1),
128,
"ue8m0",
2048,
4,
4096,
4096,
topk_indices,
True,
False,
"",
)
assert result is topk_indices
assert torch.all(topk_indices == -1)