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

#13953: Incorrectly handled bfloat16 -0.0 in ttnn.signbit #28

Merged
merged 2 commits into from
Mar 3, 2025

Conversation

atatuzunerTT
Copy link
Contributor

@atatuzunerTT atatuzunerTT commented Feb 26, 2025

Ticket

Link to Github Issue

Problem description

-0.0 Incorrectly handled as 0.0 in ttnn.signbit. bfloat16 data format should preserve -0.0 values through the unpacker, math, packer pipeline. However, -0.0 in bfloat16 format gets passed into the kernel as 0.0 and signbit reads this as a positive value.

The detailed reasoning is as follows. When unpacking to the Dest register, bfloat16 values are first packed into Src registers and then moved to Dest. When moving these values from Src, -0.0 is interpreted as 0.0 and src zero flags are set. This leads to -0.0 values not being moved, but instead, zeroes being written into relevant locations in Dest.

What's changed

Disabled src zero flags for eltwise unary/sfpu operations. -0.0 values are now moved to Dest instead of written with zeroes.

Checklist

@atatuzunerTT atatuzunerTT force-pushed the atuzuner/signbit_neg_zero branch from 0c64f1a to c2c04c4 Compare February 28, 2025 17:01
@atatuzunerTT atatuzunerTT marked this pull request as ready for review February 28, 2025 21:37
@atatuzunerTT atatuzunerTT force-pushed the atuzuner/signbit_neg_zero branch from c2c04c4 to f0f5ca4 Compare March 3, 2025 19:00
@atatuzunerTT atatuzunerTT merged commit b82ac6a into main Mar 3, 2025
1 check passed
@atatuzunerTT atatuzunerTT deleted the atuzuner/signbit_neg_zero branch March 3, 2025 19:01
fvranicTT pushed a commit that referenced this pull request Mar 4, 2025
### Ticket
[Link to Github
Issue](tenstorrent/tt-metal#13953)

### Problem description
`-0.0` Incorrectly handled as `0.0` in `ttnn.signbit`. bfloat16 data
format should preserve `-0.0` values through the unpacker, math, packer
pipeline. However, `-0.0` in bfloat16 format gets passed into the kernel
as `0.0` and `signbit` reads this as a positive value.

The detailed reasoning is as follows. When unpacking to the Dest
register, bfloat16 values are first packed into Src registers and then
moved to Dest. When moving these values from Src, `-0.0` is interpreted
as `0.0` and src zero flags are set. This leads to `-0.0` values not
being moved, but instead, zeroes being written into relevant locations
in Dest.

### What's changed
Disabled src zero flags for eltwise unary/sfpu operations. `-0.0` values
are now moved to Dest instead of written with zeroes.

### Checklist
- [x] [All post
commit](https://github.com/tenstorrent/tt-metal/actions/runs/13592906337)
CI passes
- [x] [Blackhole Post
commit](https://github.com/tenstorrent/tt-metal/actions/runs/13592910095)
CI passes (if applicable)
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