075#12
Closed
Jassicia wants to merge 1 commit into
Closed
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a new MLU/BANG implementation for the TopK operator (task 075) and updates the repository config to run evaluation for that task.
Changes:
- Introduces
TopK.mluwith an MLU kernel that computes top-k alongdim=1for 2D FP16 tensors. - Adds argument validation and launches the kernel via the current MLU stream.
- Updates
configto evaluate task075instead of070.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| TopK.mlu | Adds a TopK kernel + bang_func entrypoint for task 075. |
| config | Switches the evaluation target to task 075. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+24
to
+39
| for (int i = 0; i < k; ++i) { | ||
| half best = row_buf[0]; | ||
| int best_idx = 0; | ||
|
|
||
| for (int j = 1; j < cols; ++j) { | ||
| half cur = row_buf[j]; | ||
| if (cur > best || (cur == best && j < best_idx)) { | ||
| best = cur; | ||
| best_idx = j; | ||
| } | ||
| } | ||
|
|
||
| top_vals[i] = best; | ||
| top_idx[i] = best_idx; | ||
| row_buf[best_idx] = (half)-65504.0f; | ||
| } |
Comment on lines
+56
to
+59
| int batch = x.size(0); | ||
| int cols = x.size(1); | ||
| TORCH_CHECK(cols <= BLOCK_SIZE, "cols must be <= BLOCK_SIZE"); | ||
| TORCH_CHECK(k <= cols, "k must be <= cols"); |
Comment on lines
+53
to
+54
| TORCH_CHECK(dim == 1 || dim == -1, "only dim=1 is supported"); | ||
| TORCH_CHECK(k > 0 && k <= K_MAX, "k must be in (0, K_MAX]"); |
| } | ||
| } | ||
|
|
||
| std::vector<torch::Tensor> bang_func(torch::Tensor x, int k, int dim) { |
Comment on lines
+6
to
+9
| #define BLOCK_SIZE 1024 | ||
| #define K_MAX 128 | ||
| #define TASKS 16 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.