Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[V1][Metrics] Add per-request prompt/generation_tokens histograms #12516

Merged

Conversation

markmc
Copy link
Contributor

@markmc markmc commented Jan 28, 2025

Follow on from #12478, part of #10582

Observe these values as requests are finished.

Requires keeping track of generated tokens per-request to handle streaming delta updates.

Observe these values as requests are finished.

Requires keeping track of generated tokens per-request to handle
streaming delta updates.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Copy link

👋 Hi! Thank you for contributing to the vLLM project.
Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can do one of these:

  • Add ready label to the PR
  • Enable auto-merge.

🚀

@@ -116,9 +131,42 @@ def log(self, scheduler_stats: SchedulerStats,
self.counter_generation_tokens.inc(
iteration_stats.num_generation_tokens)

for finished_request in iteration_stats.finished_requests:
self.histogram_num_prompt_tokens_request.observe(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QQ, in V0, we did:

histogram.labels(**self.labels).observe(datum)

histogram.labels(**self.labels).observe(datum)

Do you know why this is or is not needed?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ill hit automerge to unblock you

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

labels() is a pretty expensive factory method and our labels aren't ever changing, so I'm building these labelled metrics in the PrometheusStatLogger constructor

self.histogram_num_generation_tokens_request = \
            prometheus_client.Histogram(
                name="vllm:request_generation_tokens",
                documentation="Number of generation tokens processed.",
                buckets=build_1_2_5_buckets(max_model_len),
                labelnames=labelnames).labels(*labelvalues)

Not so easy to spot it though!

@robertgshaw2-redhat robertgshaw2-redhat added the ready ONLY add when PR is ready to merge/full CI is needed label Jan 28, 2025
@robertgshaw2-redhat robertgshaw2-redhat enabled auto-merge (squash) January 28, 2025 19:55
@robertgshaw2-redhat robertgshaw2-redhat merged commit c386c43 into vllm-project:main Jan 28, 2025
60 checks passed
rasmith pushed a commit to rasmith/vllm that referenced this pull request Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready ONLY add when PR is ready to merge/full CI is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants