Skip to content

Microbenchmark - Fix precision loss in kernel launch overhead benchmark#773

Open
alephpiece wants to merge 5 commits intomicrosoft:mainfrom
alephpiece:one/fix-kernel-launch-overhead
Open

Microbenchmark - Fix precision loss in kernel launch overhead benchmark#773
alephpiece wants to merge 5 commits intomicrosoft:mainfrom
alephpiece:one/fix-kernel-launch-overhead

Conversation

@alephpiece
Copy link
Copy Markdown

Description

The original code uses integer division in the time calculation: (end_tv.tv_usec) / 1000. Since an empty kernel launch overhead is typically very small (often less than 1ms), this integer division truncates the microsecond component to 0, leading to significant precision loss and incorrect results.

image

Major Revision

  • Changed the divisor from 1000 to 1000. (floating-point literal). This forces floating-point arithmetic, preserving the microsecond precision required for accurate overhead measurement.

@alephpiece alephpiece requested a review from a team as a code owner January 16, 2026 02:21
@guoshzhao guoshzhao self-assigned this Jan 21, 2026
@guoshzhao guoshzhao requested review from guoshzhao and polarG January 21, 2026 04:49
@guoshzhao guoshzhao added bug Something isn't working benchmarks SuperBench Benchmarks micro-benchmarks Micro Benchmark Test for SuperBench Benchmarks labels Jan 21, 2026
@guoshzhao
Copy link
Copy Markdown
Contributor

Thanks @alephpiece for pointing out this issue. We will verify and review this PR.

Copy link
Copy Markdown
Contributor

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 fixes a precision loss bug in the kernel launch overhead microbenchmark where integer division was causing microsecond components to be truncated to zero for sub-millisecond measurements.

Changes:

  • Refactored time calculation from expanding then subtracting to subtracting then expanding, using floating-point arithmetic throughout

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

@polarG polarG enabled auto-merge (squash) March 5, 2026 19:24
@guoshzhao
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.69%. Comparing base (036c471) to head (0557744).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #773   +/-   ##
=======================================
  Coverage   85.69%   85.69%           
=======================================
  Files         103      103           
  Lines        7890     7890           
=======================================
  Hits         6761     6761           
  Misses       1129     1129           
Flag Coverage Δ
cpu-python3.10-unit-test 70.42% <ø> (ø)
cpu-python3.7-unit-test 69.85% <ø> (ø)
cuda-unit-test 83.60% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@guoshzhao
Copy link
Copy Markdown
Contributor

@alephpiece could you please run python3 setup.py format and python3 setup.py lint to fix the lint check?

@alephpiece
Copy link
Copy Markdown
Author

@guoshzhao
I may be missing something, but I’m not sure why python3 setup.py format and python3 setup.py lint would help for this PR. The change here is only a one-line fix in a .cu file, and there are no Python file changes. Also, CPP code lint is already passing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

benchmarks SuperBench Benchmarks bug Something isn't working micro-benchmarks Micro Benchmark Test for SuperBench Benchmarks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants