Kernels
kernel
marcsun13 HF Staff commited on
Commit
7476725
·
1 Parent(s): 007a454

revert the f32 router gemv: no end-to-end gain

Browse files
Files changed (1) hide show
  1. 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
- # The router's weight is one of the tensors a GGUF leaves dense, and ggml has a gemv for
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