[Bugfix] Wire log_stats to AsyncOmni and add missing token metrics for non-text requests (#4482)
Signed-off-by: blonde <164845202+blondeCS@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
ed37d8e7a2
commit
8fa0394d29
4 files changed
+36
-3
No files matched your search
@@ -530,6 +530,15 @@ class OmniBase(PDDisaggregationMixin):
|
||||
finished_reason=fr,
|
||||
)
|
||||
|
||||
# Token counters — aggregate across all stages for this request.
|
||||
_prompt_tok = 0
|
||||
_gen_tok = 0
|
||||
for evt in metrics.stage_events.get(rid_key, []):
|
||||
if evt.stage_id == 0:
|
||||
_prompt_tok += int(evt.num_tokens_in)
|
||||
_gen_tok += int(evt.num_tokens_out)
|
||||
self.prom_metrics.observe_tokens(_prompt_tok, _gen_tok)
|
||||
|
||||
# Modality observe inside the same finalize guard so it fires
|
||||
# once per request and inherits the try/except isolation.
|
||||
observe_modality_at_finalize(
|
||||
@@ -578,9 +587,8 @@ class OmniBase(PDDisaggregationMixin):
|
||||
if current_stage_metrics is not None:
|
||||
response_metrics["stage_id"] = current_stage_metrics["stage_id"]
|
||||
response_metrics["final_output_type"] = current_stage_metrics["final_output_type"]
|
||||
if current_stage_metrics["final_output_type"] == "text":
|
||||
response_metrics["num_tokens_in"] = current_stage_metrics["num_tokens_in"]
|
||||
response_metrics["num_tokens_out"] = current_stage_metrics["num_tokens_out"]
|
||||
response_metrics["num_tokens_in"] = current_stage_metrics["num_tokens_in"]
|
||||
response_metrics["num_tokens_out"] = current_stage_metrics["num_tokens_out"]
|
||||
return OmniRequestOutput(
|
||||
request_id=req_id or "",
|
||||
stage_id=stage_id,
|
||||
|
||||
@@ -646,6 +646,7 @@ async def build_async_omni_from_stage_config(
|
||||
try:
|
||||
kwargs = args.get_explicit_kwargs_dict()
|
||||
model = kwargs.pop("model", None) or args.model
|
||||
kwargs.setdefault("log_stats", not args.disable_log_stats)
|
||||
async_omni = AsyncOmni(model=model, **kwargs)
|
||||
|
||||
# # Don't keep the dummy data in memory
|
||||
|
||||
Reference in new issue
Block a user