@@ -19,8 +19,8 @@ template <typename DataType, typename BiasType, TopkFuncType TopkFunc = TopkFunc
1919__global__ void fused_topk_with_score_function_forward_kernel (
2020 const DataType *logits, int num_tokens, int num_experts, int topk, bool use_pre_softmax,
2121 int num_groups, int group_topk, float scaling_factor, int score_function,
22- const BiasType *expert_bias, DataType *probs, uint8_t *routing_map, NVTERoutingMapFormat routing_map_format,
23- CompType *intermediate_output) {
22+ const BiasType *expert_bias, DataType *probs, uint8_t *routing_map,
23+ NVTERoutingMapFormat routing_map_format, CompType *intermediate_output) {
2424 /* **
2525 * Section: Global Variables/Addresses init
2626 * - Each warp is responsible for one token, and has own shared memory buffer.
@@ -282,8 +282,8 @@ template <typename DataType, typename BiasType>
282282void fused_topk_with_score_function_forward_kernel_launcher (
283283 const DataType *logits, int num_tokens, int num_experts, int topk, bool use_pre_softmax,
284284 int num_groups, int group_topk, float scaling_factor, int score_function,
285- const BiasType *expert_bias, DataType *probs, uint8_t *routing_map, NVTERoutingMapFormat routing_map_format,
286- CompType *intermediate_output, cudaStream_t stream) {
285+ const BiasType *expert_bias, DataType *probs, uint8_t *routing_map,
286+ NVTERoutingMapFormat routing_map_format, CompType *intermediate_output, cudaStream_t stream) {
287287 size_t num_token_per_block = kThreadsPerBlock / kThreadsPerWarp ;
288288 size_t grid_size = (num_tokens + num_token_per_block - 1 ) / num_token_per_block;
289289 size_t shared_memory_size = num_experts * num_token_per_block * sizeof (CompType) // scores
@@ -328,8 +328,8 @@ void fused_topk_with_score_function_forward(const Tensor logits, int num_tokens,
328328 int group_topk, float scaling_factor,
329329 int score_function, const Tensor expert_bias,
330330 Tensor probs, Tensor routing_map,
331- NVTERoutingMapFormat routing_map_format, Tensor intermediate_output,
332- cudaStream_t stream) {
331+ NVTERoutingMapFormat routing_map_format,
332+ Tensor intermediate_output, cudaStream_t stream) {
333333 TE_ROUTER_PROBS_TYPE_SWITCH_ALL (
334334 logits.data .dtype , DataType,
335335 TE_ROUTER_PROBS_TYPE_SWITCH_ALL (
@@ -346,8 +346,8 @@ void fused_topk_with_score_function_forward(const Tensor logits, int num_tokens,
346346template <typename DataType>
347347__global__ void fused_topk_with_score_function_backward_kernel (
348348 // Inputs tensor
349- const uint8_t *routing_map, NVTERoutingMapFormat routing_map_format, const CompType *intermediate_output,
350- const DataType *grad_probs,
349+ const uint8_t *routing_map, NVTERoutingMapFormat routing_map_format,
350+ const CompType *intermediate_output, const DataType *grad_probs,
351351 // Other parameters
352352 int num_tokens, int num_experts, int topk, bool use_pre_softmax, float scaling_factor,
353353 int score_function,
@@ -528,9 +528,10 @@ __global__ void fused_topk_with_score_function_backward_kernel(
528528
529529template <typename DataType>
530530void fused_topk_with_score_function_backward_kernel_launcher (
531- const uint8_t *routing_map, NVTERoutingMapFormat routing_map_format, const CompType *intermediate_output,
532- const DataType *grad_probs, int num_tokens, int num_experts, int topk, bool use_pre_softmax,
533- float scaling_factor, int score_function, DataType *grad_logits, cudaStream_t stream) {
531+ const uint8_t *routing_map, NVTERoutingMapFormat routing_map_format,
532+ const CompType *intermediate_output, const DataType *grad_probs, int num_tokens,
533+ int num_experts, int topk, bool use_pre_softmax, float scaling_factor, int score_function,
534+ DataType *grad_logits, cudaStream_t stream) {
534535 // Meta data for the kernel
535536 size_t num_token_per_block = kThreadsPerBlock / kThreadsPerWarp ;
536537 size_t grid_size = (num_tokens + num_token_per_block - 1 ) / num_token_per_block;
@@ -550,7 +551,8 @@ void fused_topk_with_score_function_backward_kernel_launcher(
550551 NVTE_CHECK_CUDA (cudaGetLastError ());
551552}
552553
553- void fused_topk_with_score_function_backward (const Tensor &routing_map, NVTERoutingMapFormat routing_map_format,
554+ void fused_topk_with_score_function_backward (const Tensor &routing_map,
555+ NVTERoutingMapFormat routing_map_format,
554556 const Tensor &intermediate_output,
555557 const Tensor &grad_probs, int num_tokens,
556558 int num_experts, int topk, bool use_pre_softmax,
@@ -584,11 +586,13 @@ void nvte_fused_topk_with_score_function_forward(
584586 *convertNVTETensorCheck (intermediate_output), stream);
585587}
586588
587- void nvte_fused_topk_with_score_function_backward (
588- const NVTETensor routing_map, NVTERoutingMapFormat routing_map_format,
589- const NVTETensor intermediate_output, const NVTETensor grad_probs, int num_tokens,
590- int num_experts, int topk, int use_pre_softmax, float scaling_factor, int score_function,
591- NVTETensor grad_logits, cudaStream_t stream) {
589+ void nvte_fused_topk_with_score_function_backward (const NVTETensor routing_map,
590+ NVTERoutingMapFormat routing_map_format,
591+ const NVTETensor intermediate_output,
592+ const NVTETensor grad_probs, int num_tokens,
593+ int num_experts, int topk, int use_pre_softmax,
594+ float scaling_factor, int score_function,
595+ NVTETensor grad_logits, cudaStream_t stream) {
592596 NVTE_API_CALL (nvte_fused_topk_with_score_function_backward);
593597 using namespace transformer_engine ;
594598 fused_router::fused_topk_with_score_function_backward (
0 commit comments