Skip to content

Conversation

@liyonghua0910
Copy link
Collaborator

@liyonghua0910 liyonghua0910 commented Nov 10, 2025

Motivation

当前的 metrics 接口,只返回了 main_process_metrics 的信息,而没有返回 work_process_metrics 中包含的指标。排查到是因为 PROMETHEUS_MULTIPROC_DIR 环境变量的设置晚于 work_process_metrics 的实例化导致的,work_process_metrics 中的指标没有以多进程的模式被初始化,从而 multiprocess.MultiProcessCollector 没有到收集相关信息。

Modifications

将环境变量 PROMETHEUS_MULTIPROC_DIR 的初始化提前到 fastdeploy/__init__.py 文件中,这样通过 python -m fastdeploy.entrypoints.openai.api_server 启动服务时立即初始化该环境变量。

Usage or Command

python -m fastdeploy.entrypoints.openai.api_server \
    --model baidu/ERNIE-4.5-0.3B-Paddle \
    --port 8580 \
    --metrics-port 8581 \
    --engine-worker-queue-port 8582 \
    --cache-queue-port 8583 \
    --max-model-len 65536

Accuracy Tests

$ curl -X POST "http://0.0.0.0:8580/v1/completions" -H "Content-Type: application/json" -d '{
  "prompt": "鲁迅是谁"
}'
{"id":"cmpl-67fb8a8d-3f03-464c-b9a3-ef97ecd8e89e","object":"text_completion","created":1762757964,"model":"/root/PaddlePaddle/ERNIE-4.5-0.3B-Paddle","choices":[{"index":0,"text":"?\n\nA.阿基米德\nB.巴比伦人\nC.伊拉克人\nD.埃及人\n\n请解答这个问题。\n\n**答案**:A.阿基米德\n\n**解析**:阿基米德是古希腊数学家、哲学家,被认为是西方数学和哲学之父,是古希腊“三贤”之一。","prompt_token_ids":null,"completion_token_ids":null,"prompt_tokens":null,"completion_tokens":null,"arrival_time":null,"logprobs":null,"draft_logprobs":null,"reasoning_content":null,"finish_reason":"stop","tool_calls":null}],"usage":{"prompt_tokens":2,"total_tokens":80,"completion_tokens":78,"prompt_tokens_details":{"cached_tokens":0,"image_tokens":null,"video_tokens":null},"completion_tokens_details":{"reasoning_tokens":0,"image_tokens":0}}}

$ curl -i http://0.0.0.0:8581/metrics | grep prompt_tokens_total
# HELP fastdeploy:prompt_tokens_total Total number of prompt tokens processed
# TYPE fastdeploy:prompt_tokens_total counter
fastdeploy:prompt_tokens_total 2.0

Checklist

  • Add at least a tag in the PR title.
    • Tag list: [[FDConfig],[APIServer],[Engine], [Scheduler], [PD Disaggregation], [Executor], [Graph Optimization], [Speculative Decoding], [RL], [Models], [Quantization], [Loader], [OP], [KVCache], [DataProcessor], [BugFix], [Docs], [CI], [Optimization], [Feature], [Benchmark], [Others], [XPU], [HPU], [GCU], [DCU], [Iluvatar], [Metax]]
    • You can add new tags based on the PR content, but the semantics must be clear.
  • Format your code, run pre-commit before commit.
  • Add unit tests. Please write the reason in this PR if no unit tests.
  • Provide accuracy results.
  • If the current PR is submitting to the release branch, make sure the PR has been submitted to the develop branch, then cherry-pick it to the release branch with the [Cherry-Pick] PR tag.

@paddle-bot
Copy link

paddle-bot bot commented Nov 10, 2025

Thanks for your contribution!

@codecov-commenter
Copy link

codecov-commenter commented Nov 25, 2025

Codecov Report

❌ Patch coverage is 71.42857% with 2 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@b9bdf82). Learn more about missing BASE report.

Files with missing lines Patch % Lines
fastdeploy/__init__.py 71.42% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #4912   +/-   ##
==========================================
  Coverage           ?   59.73%           
==========================================
  Files              ?      317           
  Lines              ?    38683           
  Branches           ?     5815           
==========================================
  Hits               ?    23106           
  Misses             ?    13750           
  Partials           ?     1827           
Flag Coverage Δ
GPU 59.73% <71.42%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Jiang-Jia-Jun Jiang-Jia-Jun merged commit 0937918 into PaddlePaddle:develop Nov 25, 2025
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants