Continue gmu hill-climb after topology validation

This commit is contained in:
2026-06-24 19:09:35 +08:00
parent 8fa758797e
commit b075afe6f2
2 changed files with 187 additions and 24 deletions

View File

@@ -1396,36 +1396,75 @@ def _runtime_candidate_actions(
if (
"gpu-memory-utilization" in tunable
and topology_settled
and top_bottleneck in {"decode_tpot", "admission_or_queueing"}
and top_bottleneck in {"decode_tpot", "admission_or_queueing", "ttft_prefill"}
):
current_gmu = _parse_float_like(
anchor_flags.get("gpu-memory-utilization"), default=0.9
target = _next_gpu_memory_utilization_target(
study,
anchor_flags,
recent_diagnostics,
)
if 0.0 < current_gmu < _GMU_SAFE_CEILING:
target = round(min(_GMU_SAFE_CEILING, current_gmu + _GMU_STEP), 4)
if target > current_gmu:
patch = {**runtime_base_patch, "gpu-memory-utilization": target}
signature = _config_signature({"env_patch": {}, "flag_patch": patch})
if signature not in tested_signatures:
actions.append(
_runtime_action(
action_id="raise_gpu_memory_utilization",
knob_family="gpu-memory-utilization",
score=0.4 + _information_gain(bottleneck_hypotheses, "runtime"),
patch=patch,
hypothesis=(
"Raise gpu-memory-utilization to add KV-cache headroom so the "
"decode-bound incumbent can sustain more concurrent decode."
),
expected_effects=[
"add KV-cache blocks for higher decode concurrency on the incumbent topology",
"reject if the higher memory target regresses request_rate_per_gpu or fails to launch",
],
)
if target is not None:
patch = {**runtime_base_patch, "gpu-memory-utilization": target}
signature = _config_signature({"env_patch": {}, "flag_patch": patch})
if signature not in tested_signatures:
actions.append(
_runtime_action(
action_id="raise_gpu_memory_utilization",
knob_family="gpu-memory-utilization",
score=0.5 + _information_gain(bottleneck_hypotheses, "runtime"),
patch=patch,
hypothesis=(
"Raise gpu-memory-utilization on the settled incumbent topology "
"to test whether extra KV-cache headroom moves the SLO frontier."
),
expected_effects=[
"add KV-cache blocks for higher concurrency on the incumbent topology",
"reject if the higher memory target regresses request_rate_per_gpu or fails to launch",
],
)
)
return actions
def _next_gpu_memory_utilization_target(
study: StudySpec,
anchor_flags: dict[str, Any],
recent_diagnostics: list[dict[str, Any]],
) -> float | None:
current_gmu = _parse_float_like(
anchor_flags.get("gpu-memory-utilization"), default=0.9
)
if current_gmu <= 0 or current_gmu >= _GMU_SAFE_CEILING:
return None
anchor_topology = _normalized_topology_flags(anchor_flags)
successful_gmus: list[float] = [current_gmu]
failed_gmus: list[float] = []
for item in recent_diagnostics:
patch = item.get("config_patch")
if not isinstance(patch, dict):
continue
flag_patch = patch.get("flag_patch")
if not isinstance(flag_patch, dict) or "gpu-memory-utilization" not in flag_patch:
continue
flags = _effective_flags_for_item(study, item)
if _normalized_topology_flags(flags) != anchor_topology:
continue
gmu = _parse_float_like(flag_patch.get("gpu-memory-utilization"), default=0.0)
if gmu <= 0:
continue
if item.get("status") == "completed":
successful_gmus.append(gmu)
elif item.get("status") == "failed":
failed_gmus.append(gmu)
climb_from = max(successful_gmus)
target = round(min(_GMU_SAFE_CEILING, climb_from + _GMU_STEP), 4)
if target <= climb_from:
return None
if any(failed <= target + EPSILON for failed in failed_gmus):
return None
return target
def _runtime_action(
*,
action_id: str,