I’m not completely sure why are are unable to use the last code snippet, but also the first one seems to work:
class MyModel(nn.Module):
    def __init__(self):
        super(MyModel, self).__init__()
        self.w0 = nn.Parameter(torch.randn(1))
        
    def forward(self, x):
        return x + self.w0

model = MyModel()
print(model.state_dict())
OrderedDict([('w0', tensor([0.4342]))])

delattr(model, 'w0')
print(model.state_dict())
> OrderedDict()

setattr(model, 'w1', nn.Parameter(torch.randn(1)))
print(model.state_dict())
> OrderedDict([('w1', tensor([0.9621]))])