[Bugfix][DSv4.1] Skip SWA bounded replay for KV loads that carry the window (#59197)
Signed-off-by: Yifan Qiao <yifanqiao@inferact.ai> Co-authored-by: Codex <noreply@openai.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Codex
Claude Opus 5.5
parent
d169c5a903
commit
ef63c23d35
@@ -1559,17 +1559,22 @@ def test_failed_load_rezeroes_unwritten_skipped_blocks():
|
||||
|
||||
@pytest.mark.cpu_test
|
||||
@pytest.mark.parametrize(
|
||||
"has_mamba,is_hma_required,expected_count",
|
||||
"has_mamba,is_hma_required,bounded_replay,expected_count",
|
||||
[
|
||||
(True, True, 9),
|
||||
(False, False, 10),
|
||||
(False, True, 10),
|
||||
(True, True, False, 9),
|
||||
(False, False, False, 10),
|
||||
(False, True, False, 10),
|
||||
(False, True, True, 9),
|
||||
],
|
||||
ids=["mamba", "fa_only", "swa_only"],
|
||||
ids=["mamba", "fa_only", "swa_only", "swa_bounded_replay"],
|
||||
)
|
||||
def test_mamba_n1_d_side(has_mamba, is_hma_required, expected_count):
|
||||
"""D-side: Mamba gets N-1 matched tokens, non-Mamba gets N."""
|
||||
sched = make_nixl_scheduler(has_mamba=has_mamba, is_hma_required=is_hma_required)
|
||||
def test_mamba_n1_d_side(has_mamba, is_hma_required, bounded_replay, expected_count):
|
||||
"""D-side: Mamba and SWA bounded replay get N-1 matched tokens, others N."""
|
||||
sched = make_nixl_scheduler(
|
||||
has_mamba=has_mamba,
|
||||
is_hma_required=is_hma_required,
|
||||
bounded_replay=bounded_replay,
|
||||
)
|
||||
req = create_request(num_tokens=10, do_remote_prefill=True)
|
||||
|
||||
count, is_async = sched.get_num_new_matched_tokens(req, num_computed_tokens=0)
|
||||
@@ -1638,6 +1643,20 @@ def test_mamba_n1_p_side_truncation():
|
||||
fa_sched.on_new_request(fa_req)
|
||||
assert len(fa_req.prompt_token_ids) == fa_original
|
||||
|
||||
# SWA bounded replay: the window is not replayed after the load, so the
|
||||
# prefiller stops short of the last token too.
|
||||
swa_sched = make_nixl_scheduler(is_hma_required=True, bounded_replay=True)
|
||||
swa_req = create_request(num_tokens=10, do_remote_decode=True)
|
||||
swa_sched.on_new_request(swa_req)
|
||||
assert len(swa_req.prompt_token_ids) == 9
|
||||
|
||||
# A request that skips reading the prefix cache (prompt logprobs) is not
|
||||
# cut: the decoder loads nothing and recomputes its whole prompt.
|
||||
logprobs_req = create_request(num_tokens=10, do_remote_decode=True)
|
||||
logprobs_req.sampling_params.skip_reading_prefix_cache = True
|
||||
swa_sched.on_new_request(logprobs_req)
|
||||
assert len(logprobs_req.prompt_token_ids) == 10
|
||||
|
||||
|
||||
@pytest.mark.cpu_test
|
||||
@pytest.mark.parametrize(
|
||||
|
||||
@@ -532,6 +532,7 @@ def make_kv_cache_config(
|
||||
def make_nixl_scheduler(
|
||||
has_mamba: bool = False,
|
||||
is_hma_required: bool = False,
|
||||
bounded_replay: bool = False,
|
||||
heartbeat: bool = False,
|
||||
kv_lease_duration: int = 30,
|
||||
):
|
||||
@@ -548,6 +549,7 @@ def make_nixl_scheduler(
|
||||
|
||||
sched = object.__new__(NixlConnectorScheduler)
|
||||
sched._has_mamba = has_mamba
|
||||
sched._bounded_replay = bounded_replay
|
||||
sched._is_hma_required = is_hma_required
|
||||
sched.kv_cache_config = make_kv_cache_config(
|
||||
block_size=16,
|
||||
@@ -615,6 +617,7 @@ def make_nixl_push_scheduler(
|
||||
sched.side_channel_port = 5600
|
||||
sched.is_bidirectional_kv_xfer_enabled = is_bidirectional_kv_xfer_enabled
|
||||
sched._has_mamba = has_mamba
|
||||
sched._bounded_replay = False
|
||||
sched.kv_cache_config = make_kv_cache_config(
|
||||
block_size=16,
|
||||
mamba_enabled=has_mamba,
|
||||
|
||||
Reference in New Issue
Block a user