Skip to content

[BugFix] fix speculative gauge metrics in multi api server#7082

Merged
Jiang-Jia-Jun merged 1 commit intoPaddlePaddle:developfrom
liyonghua0910:develop+20260330_fix_metrics
Mar 31, 2026
Merged

[BugFix] fix speculative gauge metrics in multi api server#7082
Jiang-Jia-Jun merged 1 commit intoPaddlePaddle:developfrom
liyonghua0910:develop+20260330_fix_metrics

Conversation

@liyonghua0910
Copy link
Copy Markdown
Collaborator

@liyonghua0910 liyonghua0910 commented Mar 30, 2026

Motivation

This PR fixes duplicated/incorrect speculative gauge metrics export under MultiAPIServer in multi-DP scenarios.

There are two issues:

  1. speculative gauge metrics were not fully filtered and re-registered during multiprocess metrics export, which could expose duplicated values or stale values from the multiprocess collector.
  2. MultiAPIServer did not isolate PROMETHEUS_MULTIPROC_DIR across DP instances, which could cause metric file collisions between different DP processes.

Modifications

  1. Fix the speculative metrics export logic in multiprocess mode:

    • correctly filter speculative gauge metrics from the multiprocess collector output
    • re-register speculative gauge metrics from in-memory main_process_metrics
    • cover both scalar speculative gauges and single-head speculative gauge metrics
  2. Isolate PROMETHEUS_MULTIPROC_DIR for each DP instance under MultiAPIServer:

    • ensure each DP process uses an independent multiprocess metrics directory
    • avoid cross-DP metric pollution and duplicated gauge samples
  3. Add unit tests for multiprocess gauge export:

    • regular gauge returns a single value without pid
    • speculative gauge returns a single value without pid
    • speculative single-head gauge returns a single value without pid

Usage or Command

Run unit tests:

pytest -q tests/metrics/test_metrics.py

Accuracy Tests

N/A. This PR does not change model computation or model outputs. It only fixes metrics export behavior.

Checklist

  • Add at least a tag in the PR title.
  • 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
Copy Markdown

paddle-bot bot commented Mar 30, 2026

Thanks for your contribution!

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.87879% with 4 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@76cf5e9). Learn more about missing BASE report.

Files with missing lines Patch % Lines
fastdeploy/metrics/metrics.py 88.46% 0 Missing and 3 partials ⚠️
fastdeploy/entrypoints/openai/multi_api_server.py 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #7082   +/-   ##
==========================================
  Coverage           ?   73.07%           
==========================================
  Files              ?      402           
  Lines              ?    56470           
  Branches           ?     8917           
==========================================
  Hits               ?    41266           
  Misses             ?    12289           
  Partials           ?     2915           
Flag Coverage Δ
GPU 73.07% <87.87%> (?)

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 6d9739f into PaddlePaddle:develop Mar 31, 2026
36 of 39 checks passed
@EmmonsCurse
Copy link
Copy Markdown
Collaborator

❌ Cherry-pick failed: Conflicts detected when cherry-picking to release/2.5. Please resolve manually.

Jiang-Jia-Jun pushed a commit that referenced this pull request Mar 31, 2026
…ver (#7082) (#7100)

* [BugFix] fix speculative gauge metrics in multi api server

* [fix] fix test_metrics
mattheliu pushed a commit to mattheliu/FastDeploy that referenced this pull request Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants