I just looked at the tutorial again, I think part, possibly a large part, of the speed-up might well be from the forward not creating a graph, so a more fair C++ vs. Python comparison would be to use with torch.no_grad() in Python or implement forward and backward as an autograd function in Python.