Skip to content

075#12

Closed
Jassicia wants to merge 1 commit into
mainfrom
chenzhiyuan-operator
Closed

075#12
Jassicia wants to merge 1 commit into
mainfrom
chenzhiyuan-operator

Conversation

@Jassicia

@Jassicia Jassicia commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings June 8, 2026 11:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.mlu with an MLU kernel that computes top-k along dim=1 for 2D FP16 tensors.
  • Adds argument validation and launches the kernel via the current MLU stream.
  • Updates config to evaluate task 075 instead of 070.

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 thread TopK.mlu
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 thread TopK.mlu
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 thread TopK.mlu
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]");
Comment thread TopK.mlu
}
}

std::vector<torch::Tensor> bang_func(torch::Tensor x, int k, int dim) {
Comment thread TopK.mlu
Comment on lines +6 to +9
#define BLOCK_SIZE 1024
#define K_MAX 128
#define TASKS 16

@Jassicia Jassicia closed this Jun 8, 2026
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