Fix prefill delayer wait histograms always observing 0 (#25975)

Co-authored-by: kingjameschan <170807154+kingjameschan@users.noreply.github.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Humphrey <181440142+humphreysun98@users.noreply.github.com>
This commit is contained in:
Kingjameschan
2026-06-14 00:35:29 -07:00
committed by GitHub
co-authored by kingjameschan Claude Opus 4.7 Humphrey
parent 8c5320b37e
commit b796338271
2 changed files with 46 additions and 7 deletions
@@ -66,6 +66,9 @@ class NegotiateTestCase:
# to exercise the legacy slot-only code paths.
queue_min_ratio: Optional[float] = None
max_delay_ms: Optional[float] = None
# Expected accumulated wait surfaced on the final (release) outcome. When
# set, asserts the wait histograms would observe this value instead of 0.
expected_wait_forward_passes: Optional[int] = None
def _run_negotiate_test(rank, test_cases):
@@ -113,6 +116,17 @@ def _run_negotiate_test(rank, test_cases):
case.expected_reason,
), f"Case {case.name} rank {rank}"
if case.expected_wait_forward_passes is not None:
assert result.wait_forward_passes == case.expected_wait_forward_passes, (
f"Case {case.name} rank {rank}: wait_forward_passes "
f"{result.wait_forward_passes} != {case.expected_wait_forward_passes}"
)
# On a release after a real wait, seconds must be observed too.
if case.expected_wait_forward_passes > 0:
assert (
result.wait_seconds > 0.0
), f"Case {case.name} rank {rank}: wait_seconds not surfaced"
_NEGOTIATE_TEST_CASES = [
NegotiateTestCase(
@@ -127,6 +141,8 @@ _NEGOTIATE_TEST_CASES = [
],
expected_allow=True,
expected_reason="no_wait",
# No prior wait, so the histograms legitimately observe 0.
expected_wait_forward_passes=0,
),
NegotiateTestCase(
name="all_prefillable_with_previous_wait",
@@ -144,6 +160,9 @@ _NEGOTIATE_TEST_CASES = [
],
expected_allow=True,
expected_reason="wait_success",
# One mixed delay preceded the release, so the wait histograms must
# observe 1 forward pass (regression guard for #25949).
expected_wait_forward_passes=1,
),
NegotiateTestCase(
name="none_prefillable",
@@ -230,6 +249,9 @@ _NEGOTIATE_TEST_CASES = [
],
expected_allow=True,
expected_reason="wait_timeout",
# Two delays accumulated before timing out; the timeout release must
# still surface that wait to the histograms.
expected_wait_forward_passes=2,
),
# Queue-based trigger: waiting queue below queue_min = min(running * R,
# max_prefill_bs) should defer prefill. With R=0.5, running=100 and
@@ -346,6 +368,8 @@ _NEGOTIATE_TEST_CASES = [
],
expected_allow=True,
expected_reason="wait_success",
# One queue-trigger delay was recorded before the wall-clock release.
expected_wait_forward_passes=1,
),
]