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

#16679: K min values support for TopK #16917

Merged
merged 11 commits into from
Jan 24, 2025
Merged

#16679: K min values support for TopK #16917

merged 11 commits into from
Jan 24, 2025

Conversation

atatuzunerTT
Copy link
Contributor

@atatuzunerTT atatuzunerTT commented Jan 20, 2025

Ticket

Link to Github Issue

Problem description

TopK currently supports max sorting, where K max values are returned. We need to add necessary changes to LLKs to support returning the K min values.

What's changed

LLKs were updated to pass down a flag specifying which behavior (largest or smallest k values) is expected. Ckernel updated to place min values into register instead of max values when flag is set, returning k min values as a result.

Checklist

  • Post commit CI passes
  • Blackhole Post commit (if applicable)
  • Model regression CI testing passes (if applicable)
  • Device performance regression CI testing passes (if applicable)
  • (For models and ops writers) Full new models tests passes
  • New/Existing tests provide coverage for changes

@asandhupatlaTT
Copy link
Contributor

@atatuzunerTT : since this PR is editing files topk_local & topk_final which will be used by multi-core, all unit-tests in tests/ttnn/unit_tests/operations/test_topk.py should pass (including multi-core cases where W>=8192). Those cases shouldn't be commented out.

@atatuzunerTT
Copy link
Contributor Author

W >= 8192 tests were failing due to the largest flag not propagating into the multicore case. Should be fixed now

@asandhupatlaTT
Copy link
Contributor

lgtm

Copy link
Contributor

@bbradelTT bbradelTT left a comment

Choose a reason for hiding this comment

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

I only see changes for WH and BH.
What will be the behaviour for GS, does the functionality already exist?

@atatuzunerTT
Copy link
Contributor Author

GS doesn't have support for the topk kernel

@atatuzunerTT atatuzunerTT merged commit 080f063 into main Jan 24, 2025
8 checks passed
@atatuzunerTT atatuzunerTT deleted the atuzuner/topk_k_min branch January 24, 2025 18:42
patrickroberts pushed a commit that referenced this pull request Jan 25, 2025
### Ticket
[Link to Github
Issue](#16679)

### Problem description
TopK currently supports max sorting, where K max values are returned. We
need to add necessary changes to LLKs to support returning the K min
values.

### What's changed
LLKs were updated to pass down a flag specifying which behavior (largest
or smallest k values) is expected. Ckernel updated to place min values
into register instead of max values when flag is set, returning k min
values as a result.

### Checklist
- [x] [Post commit CI
passes](https://github.com/tenstorrent/tt-metal/actions/runs/12932508914)
- [x] [Blackhole Post
commit](https://github.com/tenstorrent/tt-metal/actions/runs/12932523648)
(if applicable)
- [ ] Model regression CI testing passes (if applicable)
- [ ] Device performance regression CI testing passes (if applicable)
- [ ] **(For models and ops writers)** Full [new
models](https://github.com/tenstorrent/tt-metal/actions/workflows/full-new-models-suite.yaml)
tests passes
- [ ] New/Existing tests provide coverage for changes
yieldthought pushed a commit that referenced this pull request Jan 31, 2025
### Ticket
[Link to Github
Issue](#16679)

### Problem description
TopK currently supports max sorting, where K max values are returned. We
need to add necessary changes to LLKs to support returning the K min
values.

### What's changed
LLKs were updated to pass down a flag specifying which behavior (largest
or smallest k values) is expected. Ckernel updated to place min values
into register instead of max values when flag is set, returning k min
values as a result.

### Checklist
- [x] [Post commit CI
passes](https://github.com/tenstorrent/tt-metal/actions/runs/12932508914)
- [x] [Blackhole Post
commit](https://github.com/tenstorrent/tt-metal/actions/runs/12932523648)
(if applicable)
- [ ] Model regression CI testing passes (if applicable)
- [ ] Device performance regression CI testing passes (if applicable)
- [ ] **(For models and ops writers)** Full [new
models](https://github.com/tenstorrent/tt-metal/actions/workflows/full-new-models-suite.yaml)
tests passes
- [ ] New/Existing tests provide coverage for changes
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.

6 participants