Skip to content

Use reporter-generated Report as source for final metrics#43

Merged
arekay-nv merged 16 commits intomainfrom
fix/use_reported_generated_results
Dec 31, 2025
Merged

Use reporter-generated Report as source for final metrics#43
arekay-nv merged 16 commits intomainfrom
fix/use_reported_generated_results

Conversation

@anandhu-eng
Copy link
Copy Markdown
Contributor

@anandhu-eng anandhu-eng commented Dec 5, 2025

What does this PR do?

Type of change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor/cleanup

Related issues

Testing

  • Tests added/updated
  • All tests pass locally
  • Manual testing completed

Checklist

  • Code follows project style
  • Pre-commit hooks pass
  • Documentation updated (if needed)

Copilot AI review requested due to automatic review settings December 5, 2025 12:30
@anandhu-eng anandhu-eng requested a review from a team as a code owner December 5, 2025 12:30
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Dec 5, 2025

MLCommons CLA bot All contributors have signed the MLCommons CLA ✍️ ✅

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @anandhu-eng, 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 refactors the benchmark command to standardize how performance metrics are collected and reported. Instead of calculating metrics ad-hoc, it now leverages a dedicated report object generated by the session's load generator. This change aims to improve the accuracy and reliability of benchmark results by using a single, authoritative source for all key performance indicators, while also adding error handling for missing reports.

Highlights

  • Centralized Metric Source: The benchmark command now uses a report object, generated by the session's reporter, as the authoritative source for all final metrics such as elapsed time, total samples, successful samples, and estimated QPS.
  • Enhanced Metric Accuracy: By relying on the reporter-generated report, the system ensures more accurate and consistent metrics. The estimated QPS now prioritizes the report's value and falls back to a computed value if necessary.
  • Robust Error Handling: A check has been introduced to verify the presence of the session.report object. If the report is missing, an ExecutionError is raised, preventing the benchmark from proceeding with incomplete data.
  • Session Report Storage: The Session class now includes a report attribute, which is populated after the test finishes, allowing external callers (like the benchmark command) to access the comprehensive test report.
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
Copy Markdown

@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 refactors the benchmark command to use the reporter-generated Report object as the authoritative source for final metrics. This is a good change that centralizes metric calculation and improves accuracy. The changes in BenchmarkSession to store the report and in _run_benchmark to consume it are correct. My review includes a suggestion to simplify the metric-gathering logic in benchmark.py for better readability and maintainability.

Comment thread src/inference_endpoint/commands/benchmark.py Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the benchmark command to use the reporter-generated Report object as the authoritative source for final metrics, rather than manually tracking timing and sample counts. This improves consistency and reduces redundancy by leveraging the comprehensive metrics already computed by the MetricsReporter.

Key changes:

  • Store the generated report on the BenchmarkSession object for external access
  • Replace manual timing (start_time/elapsed_time) and counting (scheduler.total_samples_to_issue) with values from the report
  • Add error handling to ensure the report is available before extracting metrics

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/inference_endpoint/load_generator/session.py Added self.report attribute to store the generated report after test completion, enabling external callers to access authoritative metrics
src/inference_endpoint/commands/benchmark.py Refactored metrics calculation to use report fields (duration_ns, n_samples_issued, n_samples_completed, qps) instead of manual tracking, with error handling for missing reports

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@anandhu-eng anandhu-eng linked an issue Dec 5, 2025 that may be closed by this pull request
Copilot AI review requested due to automatic review settings December 5, 2025 13:01
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/inference_endpoint/commands/benchmark.py
@arekay-nv arekay-nv requested a review from nv-alicheng December 5, 2025 15:36
Comment thread src/inference_endpoint/commands/benchmark.py Outdated
Copilot AI review requested due to automatic review settings December 11, 2025 07:17
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/inference_endpoint/commands/benchmark.py Outdated
Comment thread src/inference_endpoint/commands/benchmark.py Outdated
Comment thread src/inference_endpoint/commands/benchmark.py
Comment thread src/inference_endpoint/commands/benchmark.py Outdated
@anandhu-eng anandhu-eng marked this pull request as draft December 11, 2025 15:07
Copilot AI review requested due to automatic review settings December 11, 2025 18:02
@anandhu-eng anandhu-eng marked this pull request as ready for review December 13, 2025 20:07
Copilot AI review requested due to automatic review settings December 13, 2025 20:07
@github-actions github-actions Bot requested a review from arekay-nv December 13, 2025 20:07
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/inference_endpoint/commands/benchmark.py Outdated
Comment thread src/inference_endpoint/commands/benchmark.py Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings December 13, 2025 20:14
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings December 19, 2025 12:04
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/inference_endpoint/commands/benchmark.py Outdated
Comment thread src/inference_endpoint/cli.py
Copilot AI review requested due to automatic review settings December 21, 2025 13:03
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

tests/unit/commands/test_utils.py:194

  • This test creates multiple template files in the current working directory without cleanup. Each iteration creates a file like "offline_template.yaml", "online_template.yaml", etc., which remain after the test completes. This pollutes the workspace and can cause issues across test runs. Consider adding cleanup logic to remove generated files after assertions, or use tmp_path to create files in a temporary directory that pytest automatically cleans up.
    async def test_init_all_templates(self):
        """Test generating all template types."""
        templates = ["offline", "online", "eval", "submission"]

        for template_type in templates:
            output_file = Path(f"{template_type}_template.yaml")
            args = MagicMock()
            args.template = template_type

            await run_init_command(args)

            assert output_file.exists()
            assert output_file.stat().st_size > 0

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/inference_endpoint/commands/benchmark.py Outdated
Copy link
Copy Markdown
Collaborator

@arekay-nv arekay-nv left a comment

Choose a reason for hiding this comment

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

LGTM - Thanks!

Copilot AI review requested due to automatic review settings December 31, 2025 17:45
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/inference_endpoint/commands/benchmark.py
Comment thread src/inference_endpoint/commands/benchmark.py
Comment thread src/inference_endpoint/commands/utils.py Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings December 31, 2025 17:50
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/unit/commands/test_utils.py
@arekay-nv arekay-nv merged commit ba36ac4 into main Dec 31, 2025
4 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Dec 31, 2025
@arekay-nv arekay-nv deleted the fix/use_reported_generated_results branch January 5, 2026 23:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Ensure CLI report and json report use same data

3 participants