torch_bindings.cpp 950 Bytes
Newer Older
1
#include "core/registration.h"
2
3
4
5
6
7
8
9
#include "moe_ops.h"

TORCH_LIBRARY_EXPAND(TORCH_EXTENSION_NAME, m) {
  // Apply topk softmax to the gating outputs.
  m.def(
      "topk_softmax(Tensor! topk_weights, Tensor! topk_indices, Tensor! "
      "token_expert_indices, Tensor gating_output) -> ()");
  m.impl("topk_softmax", torch::kCUDA, &topk_softmax);
10
11
12
13
14

#ifndef USE_ROCM
  m.def(
      "marlin_gemm_moe(Tensor! a, Tensor! b_q_weights, Tensor! sorted_ids, "
      "Tensor! topk_weights, Tensor! topk_ids, Tensor! b_scales, Tensor! "
15
      "b_zeros, Tensor! g_idx, Tensor! perm, Tensor! workspace, "
16
17
18
19
      "__torch__.torch.classes._core_C.ScalarType b_q_type, int size_m, "
      "int size_n, int size_k, bool is_k_full, int num_experts, int topk, "
      "int moe_block_size, bool replicate_input, bool apply_weights)"
      " -> Tensor");
20
  // conditionally compiled so impl registration is in source file
21
#endif
22
23
24
}

REGISTER_EXTENSION(TORCH_EXTENSION_NAME)