The code looks alright code-wise and you should be able to see valid gradients in model.attention1.grad and model.attention2.grad after a backward() call.
nn.Softmax should work like F.softmax, but you might have forgotten to create the module before calling it via:
nn.Softmax(dim=1)(input)

What kind of error are you seeing with nn.Softmax?