grad_down = _gmm(activated_q, grad_q, counts, ctx.dtype, "TN") if needs_down else None
grad_input = grad_gate = None
if needs_input or needs_gate:
grad_activated = _gmm(grad_q, down_q, counts, ctx.dtype, "NT")
grad_projected_q = _fused_quant(projected, ctx.quantizer, counts, grad_activated, ctx.clamp_limit)
if needs_input:
grad_input = _gmm(grad_projected_q, gate_up_q, counts, ctx.dtype, "NT")
if needs_gate:
grad_gate = _gmm(input_q, grad_projected_q, counts, ctx.dtype, "TN")
return grad_input, grad_gate, grad_down, None, None, None
def fused_grouped_swiglu(
inputs: torch.Tensor, gate_up: torch.Tensor, down: torch.Tensor,