Skip to content
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

bugfix: Ensure Loop Termination by Enforcing IEEE-754 Compliance in Sampling Kernels #774

Merged
merged 1 commit into from
Feb 1, 2025

Conversation

yzh119
Copy link
Collaborator

@yzh119 yzh119 commented Feb 1, 2025

This PR addresses issue #769.

As discussed in this comment, the use of the approximate division instruction div.approx.ftz.f32 can break the loop invariant, preventing the loop from terminating. To resolve this, this PR changes the data types of low, high, and mid to double, ensuring that the compiler maintains IEEE-754 compliance and preserves numerical stability.

@dskhudia
Copy link

dskhudia commented Feb 2, 2025

@yzh119 : Thanks a lot for the fix. Wouldn't it still be an issue with loop terminating for some other inputs esp since we have an exact floating-point comparison (} while (min_gt_low != max_le_high);)? Isn't an eps-based solution better here?

@yzh119
Copy link
Collaborator Author

yzh119 commented Feb 2, 2025

Our initial design uses eps and it might introduce some errors (especially when there are a lot of similar prob values around the top-k boundary) so that some of the values outside of top-k might be incorporated.

Wouldn't it still be an issue with loop terminating for some other inputs esp since we have an exact floating-point comparison

This would not happen if the mid = (low + high) / 2 follows IEEE-754.

@zhyncs zhyncs deleted the hotfix--769 branch February 4, 2025 09:14
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.

2 participants