Setting required_grad does not through an error as it just creates a new attribute for the Tensor.
For optimizer only accepting params that requires_grad, I guess that depend on the optimizer but I don’t think there are any strong reason why it cannot. It might use a bit more memory than it should but for most simple optimizer that should be the worst thing that can happen.