Expose CP shared-KV allocation fallback as a warning

The compute-owner allocation path is an intended hot path for CP shared KV. Falling back to legacy page allocation changes the behavior profile enough that INFO/no-marker logging is too easy to miss during profiling.

This makes the fallback warning-visible and gives it the standard CP shared-KV fallback marker while preserving the existing behavior of logging every fallback event.

Constraint: Production fallbacks from intended CP shared-KV hot paths must be visible and grep-able.

Rejected: Keep INFO logging | historical silent or low-visibility fallbacks hid inactive optimized paths.

Confidence: medium

Scope-risk: narrow

Directive: Keep fallback logs warning-level unless the path is proven to be expected steady state and separately observable.

Tested: Local py_compile for common.py and test_cp_shared_kv_layout.py.

Tested: Local extracted assertLogs check for _log_cp_shared_kv_alloc_fallback warning prefix and reason formatting.

Tested: Remote g0034 py_compile for common.py and test_cp_shared_kv_layout.py.

Not-tested: Full remote pytest for test_cp_shared_kv_layout.py; current g0034 container aborts while importing installed sgl_kernel common_ops before test execution.

Co-authored-by: OmX <omx@oh-my-codex.dev>
This commit is contained in:
laoyao0822
2026-05-29 05:59:02 +08:00
parent 38532a1fc9
commit e09c8256d7
3 changed files with 18 additions and 3 deletions

View File

@@ -69,7 +69,7 @@ class TestCPSharedPagedAllocator(CustomTestCase):
def test_compute_owner_alloc_fallback_logs_every_event(self):
from sglang.srt.mem_cache import common
with self.assertLogs("sglang.srt.mem_cache.common", level="INFO") as cm:
with self.assertLogs("sglang.srt.mem_cache.common", level="WARNING") as cm:
common._log_cp_shared_kv_alloc_fallback(
"too_short_for_page_aligned",
"falling back for test event %s",
@@ -82,8 +82,10 @@ class TestCPSharedPagedAllocator(CustomTestCase):
)
self.assertEqual(len(cm.output), 2)
self.assertIn("[CP_SHARED_KV_FALLBACK][compute_owner_alloc]", cm.output[0])
self.assertIn("too_short_for_page_aligned", cm.output[0])
self.assertIn("test event 1", cm.output[0])
self.assertIn("[CP_SHARED_KV_FALLBACK][compute_owner_alloc]", cm.output[1])
self.assertIn("too_short_for_page_aligned", cm.output[1])
self.assertIn("test event 2", cm.output[1])