test: cover async SWA state-payload call chain; clarify CP gate

Review follow-up for the v2 async state payload:

- P2: new tests use CustomTestCase (with a local fallback when sglang is not
  importable), matching the disaggregation/Mooncake test convention.
- P3: CP gate docstring now says all-CP-rank transfer *without DSA cache
  layer split* keeps the synchronous path.
- Add real call-chain coverage:
  * _send_kv_chunk -> sender.send -> add_transfer_request -> transfer_worker
    -> materialize_state_indices -> maybe_send_extra, with DSV4's four
    components (DSV4_REQUEST_STATE, REQUEST_ROW, SWA, SWA);
  * the worker materializes pinned tensors only after indices_event and
    fails loudly when a tensor has no event;
  * a second materialization without an event (staging retry) is a no-op;
  * real CUDA ordering: the pinned helper returns before a long kernel and
    the event-protected values match kv_to_page_indices.
- Verified on b300 (P container, overlay source): 9 passed in
  test_async_state_payload.py, 2 passed in the new
  TestMooncakeAsyncStateMaterialization class; the old batching suite has
  11 pre-existing failures that also fail on the image source.

The test-only batching suite requires the detail envs to be off when run in
the live pod (the inherited SGLANG_TRACE_MOONCAKE_DETAIL=1 exposes an existing
test fixture omission); noted, not changed here.
This commit is contained in:
ymk
2026-11-07 00:22:57 +08:00
parent 3b0baa3455
commit 7b3f34cbc0
3 changed files with 350 additions and 8 deletions
+4 -4
View File
@@ -575,10 +575,10 @@ def should_async_state_payload(
) -> bool:
"""Gate for the first async state-payload version (SWA-only).
``kv_shard_size > 1`` and the all-CP-rank transfer mode keep the old
synchronous path: their indices are filtered before the transfer event,
and deferring that to the worker would widen the pre-event shard-filter
risk tracked by #45492.
``kv_shard_size > 1`` and all-CP-rank transfer **without DSA cache layer
split** keep the old synchronous path: their indices are filtered before
the transfer event, and deferring that to the worker would widen the
pre-event shard-filter risk tracked by #45492.
"""
if not last_chunk or not supports_async_state_indices:
return False