Skip to content

[metrics] Add PoolStats.update_scheduler_stats to deduplicate metrics assignment#22559

Merged
hnyls2002 merged 3 commits intomainfrom
lsyin/pool-stats-v2
Apr 11, 2026
Merged

[metrics] Add PoolStats.update_scheduler_stats to deduplicate metrics assignment#22559
hnyls2002 merged 3 commits intomainfrom
lsyin/pool-stats-v2

Conversation

@hnyls2002
Copy link
Copy Markdown
Collaborator

@hnyls2002 hnyls2002 commented Apr 10, 2026

Summary

  • Add update_scheduler_stats() method to PoolStats — centralizes pool-related stats assignment (num_used_tokens, token_usage, full_token_usage, swa_token_usage, mamba_usage)
  • Replace 3 duplicate assignment blocks in prefill stats, decode stats, and idle check_memory with a single pool_stats.update_scheduler_stats(self.stats) call
  • Add round(..., 2) for token_usage — previously only the idle path rounded, now all 3 paths are consistent

Follows up on #22554.

Test plan

  • test_scheduler_pause_generation.py — CPU, mock PoolStats path
  • test_metrics.py — verifies sglang:token_usage metric
  • test_prefill_delayer.py — uses token_usage for delay
  • test_abort.py — exercises prefill/decode stats paths

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@hnyls2002 hnyls2002 force-pushed the lsyin/pool-stats-v2 branch from 03f33eb to 0cbe25d Compare April 10, 2026 23:49
@hnyls2002 hnyls2002 changed the title [mem] Add protected/session fields to PoolStats [mem] Add PoolStats.update_scheduler_stats to deduplicate metrics assignment Apr 10, 2026
Base automatically changed from lsyin/cleanup-metrics to main April 11, 2026 03:35
@hnyls2002 hnyls2002 force-pushed the lsyin/pool-stats-v2 branch from 0cbe25d to e9aad94 Compare April 11, 2026 03:39
@hnyls2002
Copy link
Copy Markdown
Collaborator Author

/rerun-test test_scheduler_pause_generation.py

@github-actions
Copy link
Copy Markdown
Contributor

ubuntu-latest (1 test): View workflow run

cd test/ && python3 registered/unit/managers/test_scheduler_pause_generation.py

@hnyls2002
Copy link
Copy Markdown
Collaborator Author

/rerun-test test_metrics.py test_prefill_delayer.py test_abort.py

@github-actions
Copy link
Copy Markdown
Contributor

1-gpu-5090 (2 tests): View workflow run

cd test/ && python3 registered/observability/test_metrics.py
cd test/ && python3 registered/scheduler/test_abort.py

8-gpu-h200 (1 test): View workflow run

cd test/ && python3 registered/scheduler/test_prefill_delayer.py

@hnyls2002 hnyls2002 changed the title [mem] Add PoolStats.update_scheduler_stats to deduplicate metrics assignment [metrics] Add PoolStats.update_scheduler_stats to deduplicate metrics assignment Apr 11, 2026
@hnyls2002 hnyls2002 merged commit c7f93a2 into main Apr 11, 2026
60 of 69 checks passed
@hnyls2002 hnyls2002 deleted the lsyin/pool-stats-v2 branch April 11, 2026 04:04
pyc96 pushed a commit to pyc96/sglang that referenced this pull request Apr 14, 2026
yhyang201 pushed a commit to yhyang201/sglang that referenced this pull request Apr 22, 2026
@hnyls2002 hnyls2002 mentioned this pull request Apr 29, 2026
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.

1 participant