flashinfer.cake_moe_grouped_gemm_nondet_train.cake_moe_grouped_gemm_nondet_train_prepare_dgrad

flashinfer.cake_moe_grouped_gemm_nondet_train.cake_moe_grouped_gemm_nondet_train_prepare_dgrad(g: torch.Tensor, w: torch.Tensor, offs: torch.Tensor, out: torch.Tensor | None = None) → CakeMoEGroupedGemmNondetLaunch

Prepare dX[sum_m, K] = grouped G @ W[e] (W read in place; bf16 in, bf16 out).

g: [sum_m, N] bf16; w: [E, N, K] bf16; offs: int32 [E] device end offsets; K % 256 == 0, N % 64 == 0 (the 512-column tile when K % 512 == 0 on the architectures of wide_dgrad_archs, its L2 evict-first twin where dgrad_evict_first holds for K, sum_m and E, its 3 / 3 head / tail twin where dgrad_wide_ts33 holds). The programs are copies of the deterministic package’s and give its bits.

Parameters:
  • g (torch.Tensor) – BF16 [sum_m, N] packed output-gradient rows.

  • w (torch.Tensor) – BF16 [E, N, K] expert weights, read in place.

  • offs (torch.Tensor) – int32 device cumulative end offsets [E], or leading-zero m_indptr [E + 1].

  • out (torch.Tensor, optional) – Caller-owned BF16 [sum_m, K] output; allocated when omitted.