I think here are the main options:

Write a c++ extension that does this. https://github.com/pytorch/extension-cpp 18 . I’m not sure how well this will work.
You could add this feature (sum on sparse tensors) to PyTorch.