Your code snippet should work, even if you return a zero in your custom loss function as seen here:
output = torch.randn(10, 10, requires_grad=True)
target = torch.randint(0, 10, (10,))

criterion = nn.CrossEntropyLoss()

loss = 0 + criterion(output, target)
loss.backward()
print(output.grad)

Could you check the value of ce before calling total_loss.backward()?