Detach requires hard coding inside the model.
Detach requires knowledge about how layers are connected.
On the other side requires_grad false is external code and does not require any knowledge about model graph.
You can just not to pass  layers to the optimizer, but there are drawbacks too (gradients keep acumulating)