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

#13204: adjust matmul program config selection for some sharded output scenarios #13819

Merged
merged 3 commits into from
Oct 15, 2024

Conversation

bbradelTT
Copy link
Contributor

@bbradelTT bbradelTT commented Oct 15, 2024

Ticket

Link to Github Issue #13204

Problem description

The matmul program config selection for a single core where Kt is not a multiple of 2 and output is sharded leads to choosing a program config that cannot handle sharded outputs

What's changed

Add checks for if the output is sharded, and choose an appropriate in0_block_w and mcast config

Checklist

T3k frequent tests passes https://github.com/tenstorrent/tt-metal/actions/runs/11351278842

Copy link
Contributor

@TT-BrianLiu TT-BrianLiu left a comment

Choose a reason for hiding this comment

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

Looks good! One suggesion about in0_block_w in create_simple_matmul_program_config

Comment on lines +366 to +375
// MatmulMultiCoreProgramConfig does not support sharded output.
// Reduce in0_block_w if necessary to choose other configs.
if (mem_config.is_sharded() and Kt % in0_block_w != 0) {
in0_block_w = 1;
}

if (num_blocks_x * num_blocks_y <= num_cores_x * num_cores_y and Kt % in0_block_w == 0) {
CoreCoord core_range = get_core_range(num_blocks_y, num_blocks_x, num_cores_y, num_cores_x);
if (core_range.y == 1) {
bool use_mcast_config = mem_config.is_sharded() and core_range.y == 0;
if (core_range.y == 1 or (use_mcast_config and mem_config.memory_layout == TensorMemoryLayout::WIDTH_SHARDED)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be better to do something like this for in0_block_w:

uint32_t in0_block_w = (Kt % 2 == 0) ? 2 : 1;

and remove the code from lines 366-371 and the check for Kt % in0_block_w == 0 on line 372?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it would. Unfortunately, that would require updating the PCCs for models/tests. I'm hoping to refactor this code, and will look at it then.

@bbradelTT bbradelTT merged commit b5ea74f into main Oct 15, 2024
6 of 7 checks passed
@bbradelTT bbradelTT deleted the bbradel-13204_out branch October 15, 2024 21:19
ct-clmsn pushed a commit to ct-clmsn/tt-metal that referenced this pull request Nov 12, 2024
…arded output scenarios (tenstorrent#13819)

* tenstorrent#13204: adjust matmul program config selection for some sharded output scenarios

* tenstorrent#13204: adjust matmul program config selection for some height/block sharded output scenarios

* tenstorrent#13204: add interleaved input sharded output matmul test
azecevicTT added a commit to tenstorrent/tt-mlir that referenced this pull request Nov 13, 2024
Workaround introduced in #894
is not needed anymore. The issue was fixed in metal
tenstorrent/tt-metal#13819.

Closes #891

FYI @odjuricicTT
azecevicTT added a commit to tenstorrent/tt-mlir that referenced this pull request Nov 13, 2024
Workaround introduced in #894
is not needed anymore. The issue was fixed in metal
tenstorrent/tt-metal#13819.

Closes #891

FYI @odjuricicTT
azecevicTT added a commit to tenstorrent/tt-mlir that referenced this pull request Nov 14, 2024
Workaround introduced in #894
is not needed anymore. The issue was fixed in metal
tenstorrent/tt-metal#13819.

Closes #891

FYI @odjuricicTT
azecevicTT added a commit to tenstorrent/tt-mlir that referenced this pull request Nov 14, 2024
Workaround introduced in #894
is not needed anymore. The issue was fixed in metal
tenstorrent/tt-metal#13819.

Closes #891

FYI @odjuricicTT
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