Fix token_indices: repeat each token ID top_k times, not arange
This commit is contained in:
@@ -70,7 +70,7 @@ def main():
|
||||
flat_ids = safe_ids.reshape(-1)
|
||||
flat_weights = safe_weights.reshape(-1)
|
||||
num_slots = NUM_TOKENS * TOP_K
|
||||
token_indices = torch.arange(num_slots, device=DEVICE)
|
||||
token_indices = torch.arange(NUM_TOKENS, device=DEVICE).unsqueeze(1).expand(-1, TOP_K).reshape(-1)
|
||||
|
||||
sort_idx = flat_ids.argsort(stable=True)
|
||||
sorted_ids = flat_ids[sort_idx]
|
||||
|
||||
Reference in New Issue
Block a user