Avoid index prefetch fallback noise when disabled
The missing index prefetcher state is expected when MLA/index prefetch is disabled. Logging it as an index-prefetch fallback made the normal synchronous materialize path look like a failed fast path and created noisy reports. This keeps consume-miss warnings for enabled prefetchers, but suppresses missing-prefetcher warnings when the prefetch feature gate is off. Constraint: Index prefetch is controlled by the same MLA prefetch enable gate in the current pipeline. Rejected: Suppress all index prefetch fallback warnings | consume misses still indicate an enabled prefetch pipeline failed to serve a requested buffer. Confidence: high Scope-risk: narrow Directive: Missing prefetcher is not a fallback when SGLANG_CP_SHARED_KV_ENABLE_MLA_PREFETCH=0; do not re-add warning noise without a separate enable gate. Tested: Local py_compile for nsa_indexer.py and test_cp_shared_kv_runtime.py. Tested: Remote g0034 targeted regression set passed 4 tests: disabled sync materialize no warning, consume miss warning, first-layer no-warning, enabled create-skip warning. Not-tested: Full CUDA ETE run with logs.
This commit is contained in:
@@ -3658,6 +3658,50 @@ class TestCpSharedKVTaiMaterializeIntegration(unittest.TestCase):
|
||||
)
|
||||
self.assertIn("cuda_unavailable_or_stream_capturing", logger.call_args.args[1])
|
||||
|
||||
def test_index_sync_materialize_does_not_warn_when_prefetch_disabled(self):
|
||||
from sglang.srt.environ import envs
|
||||
from sglang.srt.layers.attention.nsa import nsa_indexer
|
||||
|
||||
class FakePool:
|
||||
page_size = 4
|
||||
|
||||
def get_index_k_with_scale_buffer(self, layer_id):
|
||||
return torch.arange(0, 12, dtype=torch.float32).view(4, 3)
|
||||
|
||||
class FakeLayout:
|
||||
page_size = 4
|
||||
cp_size = 1
|
||||
cp_rank = 0
|
||||
|
||||
fallback_buffer = torch.full((3, 3), 9.0)
|
||||
fallback_pages = torch.tensor([[1, 2]], dtype=torch.int32)
|
||||
forward_batch = SimpleNamespace(
|
||||
token_to_kv_pool=FakePool(),
|
||||
uses_cp_shared_kv=True,
|
||||
cp_shared_kv_layout=FakeLayout(),
|
||||
cp_shared_kv_index_prefetcher=None,
|
||||
)
|
||||
logical_pages = torch.tensor([[1, 2]], dtype=torch.int32)
|
||||
indexer = object.__new__(nsa_indexer.Indexer)
|
||||
|
||||
with envs.SGLANG_CP_SHARED_KV_ENABLE_MLA_PREFETCH.override(False), patch.object(
|
||||
nsa_indexer,
|
||||
"materialize_shared_paged_buffer",
|
||||
return_value=(fallback_buffer, fallback_pages),
|
||||
), patch(
|
||||
"sglang.srt.layers.attention.nsa.nsa_indexer.logger",
|
||||
create=True,
|
||||
) as logger:
|
||||
dense_buffer, dense_pages = indexer._maybe_materialize_shared_index_buffer(
|
||||
forward_batch,
|
||||
layer_id=7,
|
||||
logical_page_table=logical_pages,
|
||||
)
|
||||
|
||||
self.assertIs(dense_buffer, fallback_buffer)
|
||||
self.assertIs(dense_pages, fallback_pages)
|
||||
logger.warning.assert_not_called()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user