[DSA] k-pool: 256-token logical page so index page id = logical page id (#42178)

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Ke Bao <ispobaoke@gmail.com>
This commit is contained in:
Khoa Pham
2026-10-05 15:02:44 -07:00
committed by GitHub
co-authored by Cursor Ke Bao
parent c765f8818a
commit 61ba98443d
17 changed files with 122 additions and 74 deletions
@@ -24,7 +24,7 @@ register_cuda_ci(est_time=15, stage="base-b-kernel-unit", runner_config="1-gpu-l
@unittest.skipUnless(torch.cuda.is_available(), "Test requires CUDA")
class TestDsaKpoolMultiPool(CustomTestCase):
POOL_SIZE = 4
PAGE_SIZE = 64
PAGE_SIZE = 256
SLOTS_PER_PAGE = 64
NUM_DRAFT_TOKENS = 6
@@ -64,10 +64,10 @@ class TestDsaKpoolMultiPool(CustomTestCase):
dtype=torch.int32,
device="cuda",
)
real_page_table[:num_draft_tokens, 0] = 2
real_page_table[:num_draft_tokens, 4] = 3
real_page_table[num_draft_tokens:, 0] = 5
real_page_table[num_draft_tokens:, 4] = 6
real_page_table[:num_draft_tokens, 0] = 2 * self.POOL_SIZE
real_page_table[:num_draft_tokens, 4] = 3 * self.POOL_SIZE
real_page_table[num_draft_tokens:, 0] = 5 * self.POOL_SIZE
real_page_table[num_draft_tokens:, 4] = 6 * self.POOL_SIZE
update_kpool_write_plan_cuda_graph(
write_start=write_start,
@@ -24,7 +24,7 @@ class TestKpoolPreshuffledCacheLayout(CustomTestCase):
"""A layout mismatch between the two writers never raises; it silently
returns the wrong top-k."""
torch.manual_seed(0)
pool = SimpleNamespace(page_size=PAGE_SIZE)
pool = SimpleNamespace(page_size=4 * PAGE_SIZE, slots_per_page=PAGE_SIZE)
num_pages, seq_len = 2, PAGE_SIZE + 5
buf = torch.zeros(
num_pages,
@@ -671,6 +671,7 @@ class TestKPoolPerRequestChunking(CustomTestCase):
get_seqlens_expanded=lambda: seqlens_expanded,
topk_transform_method=TopkTransformMethod.RAGGED,
attn_metadata=SimpleNamespace(
page_size=64,
topk_indices_offset=torch.arange(token_nums, dtype=torch.int32) + 100,
),
)
@@ -689,7 +690,8 @@ class TestKPoolPerRequestChunking(CustomTestCase):
index_kpool=self.POOL,
)
with _chunking_patches(
rows_per_chunk=rows_per_chunk, kv_pool=SimpleNamespace(page_size=64)
rows_per_chunk=rows_per_chunk,
kv_pool=SimpleNamespace(page_size=256, slots_per_page=64),
):
result = IndexerKPool._get_topk_ragged_kpool(
backend,
@@ -268,6 +268,8 @@ class TestDraftSidecarPoolDispatch(CustomTestCase):
draft_kv_pool.layer_num = 1
draft_kv_pool.size = 800
draft_kv_pool.index_head_dim = 128
draft_kv_pool.page_size = 64
draft_kv_pool.slots_per_page = 64
draft_kv_pool.skip_topk_layers = [False]
draft_kv_pool.index_key_cache = SimpleNamespace(buffer=[object()])
draft_host_pool = SimpleNamespace(layer_num=1)
@@ -333,6 +335,8 @@ def _dsa_pool_stub(*, layer_num: int, size: int = 4096, shard: tuple | None = No
pool.qk_rope_head_dim = 64
pool.kv_cache_dim = 576
pool.index_head_dim = 128
pool.page_size = 64
pool.slots_per_page = 64
pool.skip_topk_layers = [False] * layer_num
pool.index_key_cache = SimpleNamespace(buffer=[object()] * layer_num)
pool.layer_shard_enabled = shard is not None
@@ -483,6 +483,8 @@ class TestDSAIndexerPoolDecl(CustomTestCase):
qk_rope_head_dim=64,
index_head_dim=128,
quant_block_size=128,
page_size=64,
slots_per_page=64,
skip_topk_layers=[False] * 5,
)
@@ -83,6 +83,8 @@ class TestMLAHostDedupPrimitives(unittest.TestCase):
end_layer=2,
index_head_dim=8,
quant_block_size=4,
page_size=2,
slots_per_page=2,
skip_topk_layers=[False] * 2,
)
indexer_host = DSAIndexerPoolHost(