Instructions to use marcsun13/topk with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Kernels
How to use marcsun13/topk with Kernels:
# !pip install kernels from kernels import get_kernel # a version (or an explicit revision) is required; see the "Files and versions" tab for the available ones kernel = get_kernel("marcsun13/topk", version=1) - Notebooks
- Google Colab
- Kaggle
revert the f32 router gemv: no end-to-end gain
Browse files- torch-ext/topk/layers.py +1 -5
torch-ext/topk/layers.py
CHANGED
|
@@ -34,10 +34,6 @@ class SoftmaxTopKRouter(nn.Module):
|
|
| 34 |
|
| 35 |
def forward(self, hidden_states: torch.Tensor):
|
| 36 |
hidden_states = hidden_states.reshape(-1, self.hidden_dim)
|
| 37 |
-
|
| 38 |
-
# those -- 8.8us against 14.5 for `F.linear` at 256x2048. The loader attaches it when it can;
|
| 39 |
-
# without it this is the model's own spelling.
|
| 40 |
-
f32_matmul = getattr(self, "_ggml_f32_matmul", None)
|
| 41 |
-
router_logits = f32_matmul(hidden_states) if f32_matmul is not None else F.linear(hidden_states, self.weight)
|
| 42 |
scores, indices = ops.top_k(router_logits, self.top_k, True)
|
| 43 |
return router_logits, scores.to(router_logits.dtype), indices
|
|
|
|
| 34 |
|
| 35 |
def forward(self, hidden_states: torch.Tensor):
|
| 36 |
hidden_states = hidden_states.reshape(-1, self.hidden_dim)
|
| 37 |
+
router_logits = F.linear(hidden_states, self.weight)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
scores, indices = ops.top_k(router_logits, self.top_k, True)
|
| 39 |
return router_logits, scores.to(router_logits.dtype), indices
|