Skip to content

Conversation

@MMuzzammil1
Copy link

@MMuzzammil1 MMuzzammil1 commented Oct 31, 2025

Described as above in the title. Closes #12459.

Checklist

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @MMuzzammil1, 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 refines the system's metric collection by introducing conditional logging for certain performance indicators. The change ensures that metrics like cache_hit_rate and speculative decoding statistics are only recorded when they are pertinent to the current processing phase (prefill or decode), leading to more accurate and contextually relevant performance data.

Highlights

  • Refined Metric Logging: Implemented conditional logging for specific metrics to ensure they are recorded only during relevant processing stages (prefill or decode).
  • Cache Hit Rate Logging: The cache_hit_rate metric is now logged exclusively during the prefill stage, preventing its logging during decode operations.
  • Speculative Decoding Metrics: Metrics related to speculative decoding (spec_accept_length, spec_accept_rate) are now logged only during the decode stage, aligning with their operational relevance.
  • API Update: The log_stats method in MetricsCollector now accepts an is_decode_stats boolean parameter to control conditional metric logging.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 correctly separates the logging of cache_hit_rate for prefill steps and speculative decoding metrics for decode steps. The changes are logical and well-implemented by introducing an is_decode_stats flag. I've added one suggestion to improve code clarity by using an if/else block for the mutually exclusive conditions, which makes the code more readable and maintainable.

Comment on lines +547 to +553
if not is_decode_stats:
self._log_gauge(self.cache_hit_rate, stats.cache_hit_rate)

# Speculative decoding
self._log_gauge(self.spec_accept_length, stats.spec_accept_length)
self._log_gauge(self.spec_accept_rate, stats.spec_accept_rate)
if is_decode_stats:
self._log_gauge(self.spec_accept_length, stats.spec_accept_length)
self._log_gauge(self.spec_accept_rate, stats.spec_accept_rate)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Since logging cache_hit_rate and speculative decoding metrics are mutually exclusive based on is_decode_stats, you can use a single if/else block. This improves readability and makes the mutually exclusive nature of these logic blocks more explicit.

Suggested change
if not is_decode_stats:
self._log_gauge(self.cache_hit_rate, stats.cache_hit_rate)
# Speculative decoding
self._log_gauge(self.spec_accept_length, stats.spec_accept_length)
self._log_gauge(self.spec_accept_rate, stats.spec_accept_rate)
if is_decode_stats:
self._log_gauge(self.spec_accept_length, stats.spec_accept_length)
self._log_gauge(self.spec_accept_rate, stats.spec_accept_rate)
if not is_decode_stats:
self._log_gauge(self.cache_hit_rate, stats.cache_hit_rate)
else:
# Speculative decoding
self._log_gauge(self.spec_accept_length, stats.spec_accept_length)
self._log_gauge(self.spec_accept_rate, stats.spec_accept_rate)

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.

[Bug] Avoid logging cache_hit_rate metric in the decode step

1 participant