[ROCm][Kimi-K3] Optimize low-concurrency speculative KDA (#58045)

Signed-off-by: jiacao-amd <jiahui.cao@amd.com>
Co-authored-by: OpenAI Codex <noreply@openai.com>
Co-authored-by: Andreas Karatzas <akaratza@amd.com>
This commit is contained in:
jiacao-amd
2026-09-25 12:33:30 -05:00
committed by GitHub
co-authored by OpenAI Codex Andreas Karatzas
parent c89b5b4176
commit 1417022c3d
6 changed files with 201 additions and 27 deletions
+19
View File
@@ -49,6 +49,7 @@ PRUNED_METADATA_FIELDS = {
"prefill_state_indices",
"prefill_has_initial_state",
"spec_sequence_masks",
"uniform_spec_sequence_length",
"flashinfer_prefill_query_start_loc",
"flashinfer_prefill_seq_order",
}
@@ -409,6 +410,7 @@ def test_internal_checkpoint_metadata_skips_unaligned_offset():
"num_speculative_tokens",
"full_cuda_graph",
"is_prefilling",
"expected_uniform_spec_sequence_length",
),
[
pytest.param(
@@ -417,6 +419,7 @@ def test_internal_checkpoint_metadata_skips_unaligned_offset():
2,
False,
[False, False],
3,
id="pure-spec-decode",
),
pytest.param(
@@ -425,6 +428,7 @@ def test_internal_checkpoint_metadata_skips_unaligned_offset():
2,
False,
[True, False, False],
3,
id="mixed-prefill-and-spec-decode",
),
pytest.param(
@@ -433,6 +437,7 @@ def test_internal_checkpoint_metadata_skips_unaligned_offset():
0,
False,
[False, False],
None,
id="regular-decode",
),
pytest.param(
@@ -441,8 +446,18 @@ def test_internal_checkpoint_metadata_skips_unaligned_offset():
2,
False,
[False, False],
None,
id="no-scheduled-draft-tokens",
),
pytest.param(
BatchSpec(seq_lens=[50, 30], query_lens=[3, 2]),
[2, 1],
2,
False,
[False, False],
None,
id="ragged-spec-decode",
),
],
)
def test_kimi_k3_kda_metadata_matches_shared_gdn(
@@ -451,6 +466,7 @@ def test_kimi_k3_kda_metadata_matches_shared_gdn(
num_speculative_tokens: int,
full_cuda_graph: bool,
is_prefilling: list[bool],
expected_uniform_spec_sequence_length: int | None,
):
kwargs: dict[str, torch.Tensor] = {}
if num_decode_draft_tokens is not None:
@@ -483,6 +499,9 @@ def test_kimi_k3_kda_metadata_matches_shared_gdn(
assert isinstance(actual, KimiK3KDAMetadata)
_assert_matches_shared_gdn(reference, actual)
assert (
reference.uniform_spec_sequence_length == expected_uniform_spec_sequence_length
)
def test_mixed_regular_and_spec_decode_uses_packed_decode_metadata():