Repository: pytorch
Issue: Parametrization silently disables RNN weight updates 
Labels: module: nn,module: rnn,triaged

## 🐛 Bug

The parametrization API applied to the weights of an RNN circumvents updates to the underlying flattened parameter buffers and hence they do not get updated.

This causes the effect on the loss to be the same as if the weights were frozen (`.requires_grad = False`).   

This can be quite painful to debug if the user not aware of the RNN internals because the non-flattened parameters do update and hence appear to be training but the flattened weights remain constant. 

I'm assuming this circumvention happens because the parameters become renamed and hence do not trigger this line:

https://github.com/pytorch/pytorch/blob/83878e19ff2af39443016beb31952476c9f049d0/torch/nn/modules/rnn.py#L127

## To Reproduce

Steps to reproduce the behavior:

1. Add arbitrary `torch.nn.utils.parametrize` to LSTM weight matrices.
1. Train model.

<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->

Environment setup:

```
$ conda create -n param_bug_report python=3.8
$ conda activate param_bug_report
$ conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch
$ pip install tqdm matplotlib
```

Example [notebook](https://gist.github.com/samgd/cf0a9c5607d0dc269b23c15f716873c3). This fits a model consisting of an LSTM followed by a Linear layer to noisy sinusoidal data with varying amplitude/phase/periods. The model is trained four times: 

1. "normal" training 
2. training with LSTM weights frozen
3. training with an identity parametrization on the LSTM weights
4. same as 3. but updating the flattened parameters between steps in the training loop

As can be seen at the bottom of the notebook, the loss of 1 and 4 are the same and the loss of 2 and 3 are the same. 

However, the weights of 3 appear to be updating!

## Expected behavior

Parametrization of RNNs should update flatten parameters or warn users that they need to handle this.

## Environment

```
$ python collect_env.py 
Collecting environment information...
PyTorch version: 1.9.1+cu102
Is debug build: False
CUDA used to build PyTorch: 10.2
ROCM used to build PyTorch: N/A

OS: Ubuntu 16.04.6 LTS (x86_64)
GCC version: (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609
Clang version: Could not collect
CMake version: version 3.18.4
Libc version: glibc-2.23

Python version: 3.8.0 (default, Nov  6 2019, 21:49:08)  [GCC 7.3.0] (64-bit runtime)
Python platform: Linux-4.15.0-29-generic-x86_64-with-glibc2.10
Is CUDA available: True
CUDA runtime version: 11.0.167
GPU models and configuration: 
GPU 0: Tesla V100-PCIE-16GB
GPU 1: Tesla V100-PCIE-16GB
GPU 2: Tesla V100-PCIE-16GB
GPU 3: Tesla V100-PCIE-16GB

Nvidia driver version: 450.36.06
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] numpy==1.17.5
[pip3] torch==1.9.1
[conda] numpy                     1.17.5                   pypi_0    pypi
[conda] torch                     1.9.1                    pypi_0    pypi
```

## Additional context

We were actually (abusing) this API to experiment with weight QAT in LSTMs so would love that feature to land in master!

cc @albanD @mruberry @jbschlosser @walterddr @zou3519 @Lezcano