Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@seyeong-han
Copy link
Contributor

Summary

Fixes a critical bug where aggregate_sampling_time_ms in the Stats struct was not initialized, causing it to contain garbage data from uninitialized memory.

Problem

The aggregate_sampling_time_ms member variable was declared without initialization:

long aggregate_sampling_time_ms;  // uninitialized!

This resulted in absurd sampling time reports like:

Sampling time over 68 tokens: 8433599.048000 (seconds)  // ~97.5 days!

The actual sampling time should have been milliseconds, not millions of seconds. Since the code accumulates timing data onto this variable (stats_.aggregate_sampling_time_ms += ...), the garbage initial value propagated through all calculations.

Solution

Initialize the variable to zero in both locations:

long aggregate_sampling_time_ms = 0;

Impact

After this fix, sampling time metrics will report realistic values (e.g., 0.010-0.100 seconds for typical token generation) instead of garbage values.

@pytorch-bot
Copy link

pytorch-bot bot commented Nov 13, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/15820

Note: Links to docs will display an error until the docs builds have been completed.

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 13, 2025
@github-actions
Copy link

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant