Loading mBART Large 50 MMT (many-to-many) is slow
Author: xhluca
Pull request: no

## Environment info

I'm installing the library directly from `master` and running it in a kaggle notebook.

<!-- You can run the command `transformers-cli env` and copy-and-paste its output below.
     Don't forget to fill out the missing fields in that output! -->

- `transformers` version: 4.4.0.dev0
- Platform: Linux-5.4.89+-x86_64-with-debian-buster-sid
- Python version: 3.7.9
- PyTorch version (GPU?): 1.7.0 (False)
- Tensorflow version (GPU?): 2.4.1 (False)
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No

### Who can help
<!-- Your issue will be replied to more quickly if you can figure out the right person to tag with @
 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

Models:

- bart: @patrickvonplaten, @patil-suraj

Library:

- text generation: @patrickvonplaten


HF projects:

- nlp datasets: [different repo](https://github.com/huggingface/nlp)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Examples:

- maintained examples (not research project or legacy): @sgugger, @patil-suraj
- research_projects/bert-loses-patience: @JetRunner
- research_projects/distillation: @VictorSanh

 -->

## Information

Model I am using (Bert, XLNet ...): mBART-Large 50 MMT (many-to-many)

The problem arises when using:
* [ ] the official example scripts: (give details below)
* [x] my own modified scripts: (give details below)

After caching the weights of the model, load it with `from_pretrained` is significantly slower compared with `torch.load`.

The tasks I am working on is:
* [ ] an official GLUE/SQUaD task: (give the name)
* [x] my own task or dataset: (give details below)

Machine Translation

## To reproduce

Here's the [kaggle notebook](https://www.kaggle.com/xhlulu/reproducing-speed-issues-with-mbart-large-50) reproducing the issue. Here's a [colab notebook](https://colab.research.google.com/drive/1fKuLG_U6uw4x8LqcIQFEFjQYjnc1nBzQ?usp=sharing) showing essentially the same thing.

Steps to reproduce the behavior:

1. Load model with `model = MBartForConditionalGeneration.load_pretrained("facebook/mbart-large-50-many-to-many-mmt")`
2. Save model with `model.save_pretrained('./my-model')`
3. Save model with `torch.save(model, 'model.pt')`
4. Reload and time with `MBartForConditionalGeneration.load_pretrained('./my-model')`
5. Load with `torch.load('model.pt')`

The step above can be reproduced inside a kaggle notebook:
```python
model = MBartForConditionalGeneration.load_pretrained("facebook/mbart-large-50-many-to-many-mmt")
model.save_pretrained('./my-model/')
torch.save(model, 'model.pt')
%time model = MBartForConditionalGeneration.from_pretrained("./my-model/")
%time torch_model = torch.load('model.pt')
```

We will notice that loading with `from_pretrained` (step 4) is significantly slower than `torch.load` (step 5); the former takes over 1 minute and the latter just a few seconds (or around 20s if it hasn't been previously loaded in memory; see [notebook](https://www.kaggle.com/xhlulu/use-saved-torch-model)).

<!-- If you have code snippets, error messages, stack traces please provide them here as well.
     Important! Use code tags to correctly format your code. See https://help.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks#syntax-highlighting
     Do not use screenshots, as they are hard to read and (more importantly) don't allow others to copy-and-paste your code.-->

## Expected behavior

<!-- A clear and concise description of what you would expect to happen. -->

The model should take less than 1 minute to load if it has already been cached (see step 1)


Comments:
Related: https://github.com/huggingface/transformers/issues/9205

Thanks. I'll rerun the benchmarks once patrick makes the changes.

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md) are likely to be ignored.

Has there been an updated to https://github.com/huggingface/transformers/issues/9205's timeline?

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md) are likely to be ignored.