Could you check, if your BERT model gets valid gradients after the loss.backward() call?
You can print the .grad attributes of some layers or of all parameters:
...
loss.backward()
print(model.bert_model.some_layer.weight.grad)
# or
for name, param in model.named_parameters():
    print(name, param.grad)

If you don’t see any gradients, this would mean that the computation graph was detached somewhere.