Fix flaky decode cache-hit check in Inkling test (#34405)

This commit is contained in:
Ke Bao
2026-08-11 21:47:01 +08:00
committed by GitHub
parent f148eb6e6e
commit b20c375c10
2 changed files with 18 additions and 3 deletions
@@ -58,6 +58,12 @@ KL_DIV_THRESHOLD = 1e-9
# checkpoint or a mis-restored prefix would surface.
KL_MAX_NEW_TOKENS = 1024
# Equal to the page size below. Out-of-window SWA slots are freed a page at a
# time, so only a checkpoint sitting on a page boundary still has a full window
# of SWA data below it -- at the default 256 half the sequence lengths land off
# that boundary and lose their decode prefix entirely.
KL_TRACK_INTERVAL = 128
class TestInklingSmallNvfp4(CustomTestCase):
@classmethod
@@ -162,6 +168,8 @@ class TestInklingSmallNvfp4Deterministic(CustomTestCase):
"0.1",
"--mem-fraction-static",
"0.85",
"--mamba-track-interval",
str(KL_TRACK_INTERVAL),
"--enable-deterministic-inference",
],
env={**os.environ, "SGLANG_ENABLE_UNIFIED_RADIX_TREE": "1"},
@@ -172,7 +180,7 @@ class TestInklingSmallNvfp4Deterministic(CustomTestCase):
if getattr(cls, "process", None) is not None:
kill_process_tree(cls.process.pid)
def _run(self, helper):
def _run(self, helper, **kwargs):
helper(
self.base_url,
{self.model: {"kl_div": KL_DIV_THRESHOLD}},
@@ -180,6 +188,7 @@ class TestInklingSmallNvfp4Deterministic(CustomTestCase):
max_samples=32,
max_new_tokens=KL_MAX_NEW_TOKENS,
trust_remote_code=True,
**kwargs,
)
def test_input_output_logprobs_match(self):
@@ -189,7 +198,9 @@ class TestInklingSmallNvfp4Deterministic(CustomTestCase):
self._run(assert_logprobs_match_prefill_cache_hit)
def test_input_output_logprobs_match_decode_cache_hit(self):
self._run(assert_logprobs_match_decode_cache_hit)
# 0.99 is every prompt: the interval above makes the reuse unconditional, so
# a single miss is a state-reuse regression rather than a geometry coincidence.
self._run(assert_logprobs_match_decode_cache_hit, min_cache_hit_ratio=0.99)
if __name__ == "__main__":