Hi @gil_bc,
when i ran your code i got a different error message, because you only return the gradient for one of your input tensors.
I got the following running, but its just a normal matrix multiplication. I am also not sure what type your sparse input is, so if its a normal Tensor or SparseTensor. I tested mine only with normal Tensors.
class SparseMM(torch.autograd.Function):
    @staticmethod
    def forward(ctx, sparse, dense):
        ctx.save_for_backward(sparse, dense)
        return torch.mm(sparse, dense)

    @staticmethod
    def backward(ctx, grad_output):
        sparse, dense = ctx.saved_tensors
        grad_sparse = grad_dense = None
        if ctx.needs_input_grad[0]:
            grad_sparse = torch.mm(grad_output, dense.t())
        if ctx.needs_input_grad[1]:
            grad_dense = torch.mm(sparse.t(), grad_output)
        return grad_sparse, grad_dense


S = torch.randn(3, 2, requires_grad=True)
D = torch.randn(4, 2, requires_grad=True)

sparse_mm = SparseMM.apply
x = sparse_mm(S, D.t())
x.backward(torch.ones_like(x))