Report latency stats for infeasible baseline
This commit is contained in:
@@ -23,7 +23,32 @@ def _is_empty_config_patch(proposal: Proposal) -> bool:
|
||||
return not proposal.config_patch.env_patch and not proposal.config_patch.flag_patch
|
||||
|
||||
|
||||
def _baseline_all_infeasible_diagnosis(result: dict[str, object]) -> str | None:
|
||||
def _latency_percentiles(summary: object, metric: str) -> dict[str, float]:
|
||||
if not isinstance(summary, dict):
|
||||
return {}
|
||||
payload = summary.get(metric)
|
||||
if not isinstance(payload, dict):
|
||||
return {}
|
||||
selected: dict[str, float] = {}
|
||||
for key in ("mean", "p50", "p95", "p99"):
|
||||
value = payload.get(key)
|
||||
if isinstance(value, (int, float)):
|
||||
selected[key] = float(value)
|
||||
return selected
|
||||
|
||||
|
||||
def _format_latency_percentiles(metric: str, values: dict[str, float]) -> str:
|
||||
if not values:
|
||||
return ""
|
||||
ordered = ", ".join(
|
||||
f"{key}={values[key]:.3f}"
|
||||
for key in ("mean", "p50", "p95", "p99")
|
||||
if key in values
|
||||
)
|
||||
return f"{metric}({ordered})"
|
||||
|
||||
|
||||
def _baseline_all_infeasible_stop(result: dict[str, object]) -> tuple[str, dict[str, object]] | None:
|
||||
if result.get("status") != "completed":
|
||||
return None
|
||||
if isinstance(result.get("best_request_rate"), (int, float)):
|
||||
@@ -41,6 +66,20 @@ def _baseline_all_infeasible_diagnosis(result: dict[str, object]) -> str | None:
|
||||
lowest_threshold = diagnostics.get("threshold")
|
||||
pass_rate = diagnostics.get("pass_rate")
|
||||
early_stop_reason = str(diagnostics.get("early_stop_reason") or "").strip()
|
||||
latency_summary = diagnostics.get("latency_summary")
|
||||
ttft = _latency_percentiles(latency_summary, "ttft_ms")
|
||||
tpot = _latency_percentiles(latency_summary, "tpot_ms")
|
||||
details: dict[str, object] = {
|
||||
"lowest_sampled_request_rate": lowest_rate,
|
||||
"lowest_sampling_u": lowest_threshold,
|
||||
"lowest_probe_pass_rate": pass_rate,
|
||||
"early_stop_reason": early_stop_reason,
|
||||
"lowest_probe_latency_ms": {
|
||||
"ttft": ttft,
|
||||
"tpot": tpot,
|
||||
},
|
||||
"lowest_probe_latency_summary": latency_summary if isinstance(latency_summary, dict) else {},
|
||||
}
|
||||
pieces = [
|
||||
"Baseline configuration has no feasible probe under the current SLO.",
|
||||
"Stopping tuning because even the lowest sampled request rate did not meet the target pass rate.",
|
||||
@@ -53,7 +92,13 @@ def _baseline_all_infeasible_diagnosis(result: dict[str, object]) -> str | None:
|
||||
pieces.append(f"lowest_probe_pass_rate={float(pass_rate):.6g}")
|
||||
if early_stop_reason:
|
||||
pieces.append(f"early_stop_reason={early_stop_reason}")
|
||||
return " ".join(pieces)
|
||||
for item in (
|
||||
_format_latency_percentiles("lowest_probe_ttft_ms", ttft),
|
||||
_format_latency_percentiles("lowest_probe_tpot_ms", tpot),
|
||||
):
|
||||
if item:
|
||||
pieces.append(item)
|
||||
return " ".join(pieces), details
|
||||
|
||||
|
||||
def _study_source_path(study_root: Path) -> Path:
|
||||
@@ -170,6 +215,7 @@ def cmd_study_tune(args: argparse.Namespace) -> int:
|
||||
"stopped": True,
|
||||
"reason": state.tuning_stop_reason,
|
||||
"diagnosis": state.tuning_stop_diagnosis,
|
||||
"details": state.tuning_stop_details,
|
||||
"state_best_trial_id": state.best_trial_id,
|
||||
"state_best_request_rate": state.best_request_rate,
|
||||
}
|
||||
@@ -305,10 +351,12 @@ def cmd_study_tune(args: argparse.Namespace) -> int:
|
||||
}
|
||||
)
|
||||
if is_auto_baseline:
|
||||
diagnosis = _baseline_all_infeasible_diagnosis(result)
|
||||
if diagnosis is not None:
|
||||
stop = _baseline_all_infeasible_stop(result)
|
||||
if stop is not None:
|
||||
diagnosis, details = stop
|
||||
state.tuning_stop_reason = "baseline_all_infeasible"
|
||||
state.tuning_stop_diagnosis = diagnosis
|
||||
state.tuning_stop_details = details
|
||||
store.save_state(state)
|
||||
executed.append(
|
||||
{
|
||||
@@ -316,6 +364,7 @@ def cmd_study_tune(args: argparse.Namespace) -> int:
|
||||
"stopped": True,
|
||||
"reason": state.tuning_stop_reason,
|
||||
"diagnosis": diagnosis,
|
||||
"details": details,
|
||||
"state_best_trial_id": state.best_trial_id,
|
||||
"state_best_request_rate": state.best_request_rate,
|
||||
}
|
||||
@@ -332,6 +381,7 @@ def cmd_study_tune(args: argparse.Namespace) -> int:
|
||||
"best_request_rate": final_state.best_request_rate,
|
||||
"tuning_stop_reason": final_state.tuning_stop_reason,
|
||||
"tuning_stop_diagnosis": final_state.tuning_stop_diagnosis,
|
||||
"tuning_stop_details": final_state.tuning_stop_details,
|
||||
},
|
||||
ensure_ascii=False,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user