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

Add signed int32 data type support end to end #2272

Merged
merged 1 commit into from
Feb 27, 2025

Conversation

jnie-TT
Copy link
Contributor

@jnie-TT jnie-TT commented Feb 24, 2025

Problem description

We don't support signed integers in tt-mlir, and we've been shifting to uint32 when encountering signed/signless integers. With newest metal uplift, binary ops will assert on uint32 (they used to run with uint32 but produce garbage data), therefore we need to add int32 support in our stack.

What's changed

  • Added int32 data type end to end
  • Convert signed and signless integers to TT_Int32
  • Added workarounds for full op and reshape op to typecast to uint32 if input/output datatypes are int32.

Checklist

  • New/Existing tests provide coverage for changes
  • Remove TODO 2272 workaround in ops to force INT32

FYI @brataTT @kmabeeTT please try the uplift on top of my branch and see if the asserts go away. If needed we might want to merge this branch before the 24 hour limit to support the uplift.

Copy link
Contributor

@azecevicTT azecevicTT left a comment

Choose a reason for hiding this comment

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

Dialect changes looks good!

Copy link
Contributor

@nsmithtt nsmithtt left a comment

Choose a reason for hiding this comment

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

TT dialect / flatbuffer / runtime changes lgtm

@sgligorijevicTT
Copy link
Contributor

sgligorijevicTT commented Feb 25, 2025

I manually uplifted tt-xla to this branch and now I'm getting

error: Redundant ttnn::ToLayoutOp - no ttnn layout ops needed, this may be due to the forcing of tile/row major layouts.

during compilation on models which used to compile successfully but fail in runtime due to lack of int32 buffer support.

Minimal repro .mlir : https://gist.github.com/sgligorijevicTT/35394562e16a3a0958fbfed4839cc2a7

@mtopalovicTT
Copy link
Contributor

@sgligorijevicTT @jnie-TT Seems that we are missing folder on to layout op

@jnie-TT
Copy link
Contributor Author

jnie-TT commented Feb 25, 2025

@sgligorijevicTT @mtopalovicTT yeah we've seen this issue with the workaround pass, where redundant to_layout ops aren't removed. This change adds a couple of workarounds so it adds up. Issue tracking this here: #2102, I'll hold off from merging this until it's resolved.

Marking this blocked by #2102

@kmabeeTT
Copy link
Contributor

Small update - We merged tt-metal uplift to tt-mlir just now (#2256) without waiting for this to be merged (pending on #2102 resolution from @sdjordjevicTT I believe) by instead using a ~localized tt-mlir runtime op hack to convert uint32 to int32 for binary ops.

@sdjordjevicTT
Copy link
Contributor

sdjordjevicTT commented Feb 26, 2025

I have been working on #2102 and had some issues with MeshShardOp once I introduced ToLayoutOp folding, hence I extracted the ToLayoutOp folding logic in a separate review:
#2292

And created a separate issue for MeshShardOp handling:
#2292

@sdjordjevicTT
Copy link
Contributor

I have been working on #2102 and had some issues with MeshShardOp once I introduced ToLayoutOp folding, hence I extracted the ToLayoutOp folding logic in a separate review: #2292

And created a separate issue for MeshShardOp handling: #2292

The change to fold ToLayoutOp has now been merged. :)

@jnie-TT jnie-TT force-pushed the jnie/signed_int32_support branch from db818b2 to 3893bb2 Compare February 27, 2025 15:57
@jnie-TT
Copy link
Contributor Author

jnie-TT commented Feb 27, 2025

Ran https://gist.github.com/sgligorijevicTT/35394562e16a3a0958fbfed4839cc2a7 after rebasing on top of #2292, redundant to_layout op issue is fixed

@jnie-TT jnie-TT merged commit a1af497 into main Feb 27, 2025
31 checks passed
@jnie-TT jnie-TT deleted the jnie/signed_int32_support branch February 27, 2025 17:19
@sdjordjevicTT
Copy link
Contributor

Ran https://gist.github.com/sgligorijevicTT/35394562e16a3a0958fbfed4839cc2a7 after rebasing on top of #2292, redundant to_layout op issue is fixed

Great! 😊

jserbedzijaTT pushed a commit that referenced this pull request Mar 1, 2025
### Problem description
We don't support signed integers in tt-mlir, and we've been shifting to
uint32 when encountering signed/signless integers. With newest metal
uplift, binary ops will assert on uint32 (they used to run with uint32
but produce garbage data), therefore we need to add int32 support in our
stack.

### What's changed
* Added int32 data type end to end
* Convert signed and signless integers to `TT_Int32`
* Added workarounds for full op and reshape op to typecast to uint32 if
input/output datatypes are int32.

### Checklist
- [X] New/Existing tests provide coverage for changes
- [x] Remove TODO 2272 workaround in ops to force INT32

FYI @brataTT @kmabeeTT please try the uplift on top of my branch and see
if the asserts go away. If needed we might want to merge this branch
before the 24 hour limit to support the uplift.
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.

9 participants