You will get a max recursion error, if you have assigned the model to itself somewhere.
This code demonstrates the issue:

class MyModel(nn.Module):
    def __init__(self):
        super(MyModel, self).__init__()
        self.fc1 = nn.Linear(1, 1)
        self.model = self # will create recursion error
        
    def forward(self, x):
        x = self.fc1(x)
        return x

model = MyModel()
model.state_dict()

If you remove the self.model = self assignment, the state_dict can be created.
Could you check your model for such a loop?