Skip to content

Commit

Permalink
refactor topk to use mlx (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
Blaizzy authored Jan 8, 2025
1 parent 71a3f66 commit 1e4579a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mlx_vlm/models/deepseek_vl_v2/language.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,9 @@ def __call__(self, x):

# Calculate group scores using top-2 sum per group
scores_reshaped = scores_for_choice.reshape(bsz * seq_len, self.n_group, -1)
k = 2
group_scores_topk = mx.sort(scores_reshaped, axis=-1)[..., -k:]
group_scores = group_scores_topk.sum(axis=-1)

# Get top 2 scores per group
group_scores = mx.topk(scores_reshaped, 2, axis=-1).sum(axis=-1)

# Get top groups
k = self.n_group - self.topk_group
Expand Down

0 comments on commit 1e4579a

Please sign in to comment.