You could use some dummy data and target, calculate the loss and gradients, and compare the gradients of (some) layers using something like this:
print(torch.allclose(modelA.model.features[0].weight.grad),
      modelB.features[0].weight.grad))

I would recommend using the second approach, since the first one is not defined as an nn.Module, which will yield errors, e.g. if you try to call model.parameters() etc.