-
Notifications
You must be signed in to change notification settings - Fork 13
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
Support for memRef of L1 Interleaved tensors (#1292) #1607
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Let's open this up as ready for review!
std::accumulate(logicalTiledShape.begin(), logicalTiledShape.end(), 1, | ||
std::multiplies<std::int64_t>()); | ||
uint64_t numOfGridUnits = | ||
std::accumulate(grid.getShape().begin(), grid.getShape().end(), 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe leave an assert here that grid is equal to device max grid? Or at least a comment. I'm not sure that l1 interleaved is supported for non max grid configurations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to check this, but I suspect that l1 is supported for non max grid configuration.
lib/Dialect/TTNN/IR/TTNNOpsAttrs.cpp
Outdated
shardShape.push_back(1); | ||
shardShape.push_back((numOfTiles + numOfGridUnits - 1) / numOfGridUnits); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is always 2D. Is there a case when it needs more dimensions? Maybe just leave an assert that this is the desired number of dims, so when we introduce 3D this fails in a friendly manner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of asserting, we can add n-1
ones at the beginning of merRef so its dimension corresponds to the grid dimension.
3a99432
to
5158f8b
Compare
5158f8b
to
94028e1
Compare
Will continue tmrw. |
…ardShapeForInterleaved
94028e1
to
0e1fc7a
Compare
This PR fixes the issue of incorrect
memRef
for L1 Interleaved layouts.In the previous implementation of
TTNNLayoutAttr
we were modellingmemRef
as its memory layout isBlockSharded
. By modelling everything asBlockSharded
we hit the error of incorrect memory usage for tensors with the given layout.For example, if we wanted to create a L1 Interleaved
TTNNLayout
oftensor<1x1024xbf16>
, we would get amemref<1x4x!tt.tile<32x32, bf16>, #l1_>
. This was incorrect since the whole tensor can be tiled into 32 tiles and if grid shape is8x8
we could assign only one tile per grid unit. There is no need for 4 tiles to be placed in one grid unit.This PR adds workaround for this issue by using different logic for calculating logical shard shape for L1 Interleaved layouts. This workaround creates a
memref<1x1x!tt.tile<32x32, bf16>, #l1_>
fortensor<1x1024xbf16>
.Closes issue: #1292