Skip to content

finegrained-fp8: [bugfix] add epsilon to act_quant scale to avoid NaNs.#680

Open
wz-ml wants to merge 2 commits into
huggingface:mainfrom
wz-ml:main
Open

finegrained-fp8: [bugfix] add epsilon to act_quant scale to avoid NaNs.#680
wz-ml wants to merge 2 commits into
huggingface:mainfrom
wz-ml:main

Conversation

@wz-ml
Copy link
Copy Markdown

@wz-ml wz-ml commented Apr 30, 2026

A quick single-line change to fix this issue I was running into with this FP8 kernel:
When an X block is all zeros, the scale factor's also zero, which causes the kernel to return 0/0 = NaN.

…s are 0 have a scale factor of 0 (yielding 0/0 = NaN)
@wz-ml wz-ml requested review from danieldk and drbh as code owners April 30, 2026 21:41
@github-actions
Copy link
Copy Markdown

Hi @wz-ml, thanks for your interest in contributing!

This project requires that pull request authors are vouched, and you are not in the list of vouched users.

This PR will be closed automatically. See https://github.com/huggingface/kernels-community/blob/main/CONTRIBUTING.md for more details.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

Hi @wz-ml, thanks for your interest in contributing!

This project requires that pull request authors are vouched, and you are not in the list of vouched users.

This PR will be closed automatically. See https://github.com/huggingface/kernels-community/blob/main/CONTRIBUTING.md for more details.

@github-actions github-actions Bot closed this May 8, 2026
@danieldk danieldk self-assigned this May 8, 2026
@danieldk
Copy link
Copy Markdown
Member

danieldk commented May 8, 2026

@IlyasMoutawwakil could you do a review?

offs = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)
x = tl.load(x_ptr + offs).to(tl.float32)
s = tl.max(tl.abs(x)) / 448.0 # float8_e4m3fn max
s = tl.maximum(s, 1e-12)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yes this actually needed, thanks for the fix.

@IlyasMoutawwakil
Copy link
Copy Markdown
Member

it seems i can't approve the pr 🥲

@sayakpaul sayakpaul reopened this May 29, 2026
@sayakpaul
Copy link
Copy Markdown
Member

@IlyasMoutawwakil this looks good to you?

@sayakpaul sayakpaul linked an issue May 29, 2026 that may be closed by this pull request
@IlyasMoutawwakil
Copy link
Copy Markdown
Member

@sayakpaul yes i couldn't approve it before

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: finegrained-fp8 act_quant produces NaNs on zero blocks

4 participants