-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
[Config] Make prefix cache metrics interval configurable #19634
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
base: main
Are you sure you want to change the base?
[Config] Make prefix cache metrics interval configurable #19634
Conversation
👋 Hi! Thank you for contributing to the vLLM project. 💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels. Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run 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 either: Add 🚀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @jeremyeder, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request addresses a long-standing TODO by making the window size for prefix cache hit rate metrics configurable. This allows users to tune the trade-off between the stability of the reported metrics and the memory overhead required to track recent requests. The change introduces a new configuration parameter and CLI argument, adds validation, and updates the relevant logging component to respect the user's setting.
Highlights
- Configuration: I've added a new parameter
prefix_cache_metrics_max_requests
to theObservabilityConfig
dataclass. This parameter controls the number of recent requests used for calculating prefix cache hit rates, defaulting to 1000. - CLI Argument: A corresponding command-line argument
--prefix-cache-metrics-max-requests
has been added toEngineArgs
to allow users to configure this setting via the CLI. - Validation: I've implemented validation in
ObservabilityConfig.__post_init__
to ensure theprefix_cache_metrics_max_requests
value is within a reasonable range (1 to 100000) to prevent excessive memory usage. - Integration: The
LoggingStatLogger
has been updated to read the configuredprefix_cache_metrics_max_requests
from theVllmConfig
and pass it to thePrefixCachingMetrics
instance, falling back to the default 1000 if no config is provided. - Testing: I've added a new test file
tests/test_prefix_cache_metrics_config.py
with comprehensive tests covering the validation logic, the correct instantiation ofPrefixCachingMetrics
with the configured value, and the end-to-end integration withinLoggingStatLogger
.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configureGemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request effectively introduces configurability for the prefix cache metrics interval, enhancing flexibility for users. The changes are well-implemented across the configuration, argument parsing, and logging components, and are accompanied by comprehensive tests. The code is clear and addresses the TODO appropriately.
I have one minor suggestion to improve the robustness of the default value handling in LoggingStatLogger
by referencing the default directly from ObservabilityConfig
.
d31f8ca
to
fb761dc
Compare
The prefix cache metrics currently use a hardcoded limit of 1000 recent requests to calculate hit rates. This adds a configurable parameter to let users adjust this based on their memory vs stability preferences. - Add prefix_cache_metrics_max_requests to ObservabilityConfig (default: 1000) - Add --prefix-cache-metrics-max-requests CLI argument - Validate range 1-100000 to prevent excessive memory usage - Update LoggingStatLogger to respect the configured value - Resolves TODO left by @comaniac in vllm/v1/metrics/loggers.py:58 Higher values give more stable hit rate metrics but use more memory. Lower values are more memory-efficient but metrics may be noisier. Example: --prefix-cache-metrics-max-requests=2000 Signed-off-by: Jeremy Eder <jeder@redhat.com>
9826a7b
to
2e0a000
Compare
Purpose
Resolves TODO left by @comaniac in vllm/v1/metrics/loggers.py:58 - makes the prefix cache metrics interval configurable instead of hardcoded to 1000 requests.
The prefix cache metrics currently use a hardcoded limit of 1000 recent requests to calculate hit rates. This adds a configurable parameter to let users adjust this based on their memory vs stability preferences.
Changes
prefix_cache_metrics_max_requests
to ObservabilityConfig (default: 1000)--prefix-cache-metrics-max-requests
CLI argumentHigher values give more stable hit rate metrics but use more memory.
Lower values are more memory-efficient but metrics may be noisier.
Test Plan
Test Results
✅ Default value (1000): Works correctly, maintains backward compatibility
✅ Custom values: Accepted and properly used by PrefixCachingMetrics
✅ Validation: Invalid values (0, negative, >100000) properly rejected with clear error messages
✅ Integration: LoggingStatLogger correctly uses configured value or falls back to 1000
✅ All tests pass: 3 test functions covering validation, metrics behavior, and end-to-end integration
Example usage:
--prefix-cache-metrics-max-requests=2000