ArthurZ HF staff commited on
Commit
77a5cd6
·
1 Parent(s): cda1e7d

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +41 -0
README.md ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This repo shows how to convert a fairseq NLLB-MoE model to transformers and run a forward pass
2
+
3
+ As the `fairseq` repository is not really optimised to run inference out-of-the-box, make sure you have a very very big CPU/GPU RAM.
4
+ Around 600 GB are required to run an inference with the `fairseq` model, as you need to load the checkpoints (~300GB) then build the model (~300GB again), then finally you can load the checkpoints in the model.
5
+
6
+ ## 0. Download the original checkpoints:
7
+ The checkpoints in this repository were obtained using the following command (ased on the instructions given on the fairseq repository):
8
+ ```bash
9
+ wget --trust-remote-name path_to_nllb
10
+ tar -cf model.tar.zf
11
+ ```
12
+
13
+ The NLLB checkpoints should noz
14
+
15
+ ## 1. Install PyTorch
16
+ Use the following command:
17
+ ```bash
18
+ pip3 install torch==1.10.1+cu113 torchvision==0.11.2+cu113 torchaudio==0.10.1+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html
19
+ ```
20
+
21
+ ## 2. Install fairseq
22
+ ```bash
23
+ git clone https://github.com/facebookresearch/fairseq.git
24
+ cd fairscale
25
+ git checkout prefetch_fsdp_params_simple
26
+ pip3 install -e .
27
+ ```
28
+
29
+ ## 3. Clone this repo (click top right on "How to clone")
30
+
31
+ ## 4. Run the inference script:
32
+ Convert the checkpoints on the fly using the conversion script. `transformers` is required to do this:
33
+ ```bash
34
+ cd <path/to/cloned/repo>
35
+ python3 /home/arthur_huggingface_co/fairseq/weights/checkpoints/convert_nllb_moe_sharded_original_checkpoint_to_pytorch.py --pytorch_dump_folder_path <dump_folder> --nllb_moe_checkpoint_path <nllb_checkpoint_path>
36
+ ```
37
+ ## 4. Run the inference script:
38
+ ```bash
39
+ cd <path/to/cloned/repo>
40
+ bash run.sh
41
+ ```