TRI-ML / prismatic-vlms

A flexible and efficient codebase for training visually-conditioned language models (VLMs)
MIT License
327 stars 93 forks source link

Improved Documentation for Launching Training Runs #31

Open RylanSchaeffer opened 1 month ago

RylanSchaeffer commented 1 month ago

As background, I'm working on training more VLMs using this code base (with @siddk 's helpful guidance). I'm going to use this issue to list ways documentation can be improved for pretraining.

  1. The default run command uses W&B projects and entities specific to TRI and this project. It then causes an error if you run the suggested command:
(prismatic) rschaef@ampere1 /lfs/ampere1/0/rschaef/prismatic-vlms$ torchrun --standalone --nnodes 1 --nproc-per-node 2 scripts/pretrain.py   --model.type "one-stage+7b"   --model.model_id "rylan_attempt_1"   --model.vision_backbone_id "dinosiglip-vit-so-384px"   --model.image_resize_strategy "letterbox"   --model.llm_backbone_id "vicuna-v15-7b" 
W0510 09:34:35.219000 139790815588736 torch/distributed/run.py:757] 
W0510 09:34:35.219000 139790815588736 torch/distributed/run.py:757] *****************************************
W0510 09:34:35.219000 139790815588736 torch/distributed/run.py:757] Setting OMP_NUM_THREADS environment variable for each process to be 1 in default, to avoid your system being overloaded, please further tune the variable for optimal performance in your application as needed. 
W0510 09:34:35.219000 139790815588736 torch/distributed/run.py:757] *****************************************
05/10 [09:34:52] INFO     | >> [*] Prismatic VLM Training :: Gathering Light                                                                                                                                                                                                                                                                                                                                                                                                     pretrain.py:122
                 INFO     | >>     |=> "Life is like a prism; what you see depends on how you turn the glass."                                                                                                                                                                                                                                                                                                                                                                   pretrain.py:136
                 INFO     | >> [*] Loading Vision Backbone dinosiglip-vit-so-384px via TIMM                                                                                                                                                                                                                                                                                                                                                                                      pretrain.py:149
05/10 [09:34:56] INFO     | >> Loading pretrained weights from Hugging Face hub (timm/vit_large_patch14_reg4_dinov2.lvd142m)                                                                                                                                                                                                                                                                                                                                                     _builder.py:186
                 INFO     | >>  Safe alternative available for 'pytorch_model.bin' (as 'model.safetensors'). Loading weights using safetensors.                                                                                                                                                                                                                                                                                                                                      _hub.py:180
05/10 [09:34:57] INFO     | >> Resized position embedding: (37, 37) to (27, 27).                                                                                                                                                                                                                                                                                                                                                                                                 pos_embed.py:55
05/10 [09:34:57] INFO     | >> Loading pretrained weights from Hugging Face hub (timm/vit_large_patch14_reg4_dinov2.lvd142m)                                                                                                                                                                                                                                                                                                                                                     _builder.py:186
                 INFO     | >>  Safe alternative available for 'pytorch_model.bin' (as 'model.safetensors'). Loading weights using safetensors.                                                                                                                                                                                                                                                                                                                                      _hub.py:180
                 INFO     | >> Resized position embedding: (37, 37) to (27, 27).                                                                                                                                                                                                                                                                                                                                                                                                 pos_embed.py:55
05/10 [09:35:02] INFO     | >> Loading pretrained weights from Hugging Face hub (('timm/ViT-SO400M-14-SigLIP-384', 'open_clip_pytorch_model.bin'))                                                                                                                                                                                                                                                                                                                               _builder.py:186
                 INFO     | >>  Safe alternative available for 'open_clip_pytorch_model.bin' (as 'open_clip_model.safetensors'). Loading weights using safetensors.                                                                                                                                                                                                                                                                                                                  _hub.py:180
05/10 [09:35:02] INFO     | >> Loading pretrained weights from Hugging Face hub (('timm/ViT-SO400M-14-SigLIP-384', 'open_clip_pytorch_model.bin'))                                                                                                                                                                                                                                                                                                                               _builder.py:186
                 INFO     | >>  Safe alternative available for 'open_clip_pytorch_model.bin' (as 'open_clip_model.safetensors'). Loading weights using safetensors.                                                                                                                                                                                                                                                                                                                  _hub.py:180
05/10 [09:35:04] INFO     | >> [*] Loading Pretrained LLM vicuna-v15-7b via HF Transformers                                                                                                                                                                                                                                                                                                                                                                                      pretrain.py:155
                 INFO     | >>     |=> Loading llama2 LLM from `lmsys/vicuna-7b-v1.5`                                                                                                                                                                                                                                                                                                                                                                                            base_llm.py:117
pytorch_model.bin.index.json: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 26.8k/26.8k [00:00<00:00, 105MB/s]
pytorch_model-00001-of-00002.bin: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 9.98G/9.98G [00:47<00:00, 210MB/s]
pytorch_model-00002-of-00002.bin: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 3.50G/3.50G [00:16<00:00, 210MB/s]
Downloading shards: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [01:04<00:00, 32.19s/it]
Downloading shards: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [01:04<00:00, 32.18s/it]
Loading checkpoint shards: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:09<00:00,  4.79s/it]
generation_config.json: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 162/162 [00:00<00:00, 1.55MB/s]
Loading checkpoint shards: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:12<00:00,  6.12s/it]
05/10 [09:36:21] INFO     | >>     |=> Loading llama2 (Fast) Tokenizer via the AutoTokenizer API                                                                                                                                                                                                                                                                                                                                                                                 base_llm.py:147
05/10 [09:36:25] INFO     | >> [*] Instantiating PrismaticVLM `rylan_attempt_1` for Training Stage = `finetune`                                                                                                                                                                                                                                                                                                                                                                  pretrain.py:161
                 INFO     | >> [*] Invoking `VLM.freeze_backbones()` for `rylan_attempt_1` => Training Stage: `finetune`                                                                                                                                                                                                                                                                                                                                                         pretrain.py:171
                 INFO     | >>     |=> [Frozen]    🥶 =>> Vision Backbone `dinosiglip-vit-so-384px`                                                                                                                                                                                                                                                                                                                                                                             prismatic.py:160
                 INFO     | >>     |=> [TRAINABLE] 🔥 =>> LLM Backbone `vicuna-v15-7b`                                                                                                                                                                                                                                                                                                                                                                                          prismatic.py:161
                 INFO     | >>     |=> [TRAINABLE] 🔥 =>> Projector `no-align+gelu-mlp`                                                                                                                                                                                                                                                                                                                                                                                         prismatic.py:162
                 INFO     | >> [*] Invoking `VLM.load_checkpoint()` for `rylan_attempt_1` => Training Stage: `finetune`                                                                                                                                                                                                                                                                                                                                                          pretrain.py:175
                 INFO     | >>     |=> PrismaticVLM with `self.arch_specifier = 'no-align+gelu-mlp'` does not require pretrained weights!                                                                                                                                                                                                                                                                                                                                       prismatic.py:190
                 INFO     | >> [*] Creating Dataset `llava-v15` => Stage: `finetune`                                                                                                                                                                                                                                                                                                                                                                                             pretrain.py:179
05/10 [09:36:32] INFO     | >> [*] Initializing Train Strategy `fsdp-full-shard`                                                                                                                                                                                                                                                                                                                                                                                                 pretrain.py:191
                 INFO     | >> [*] Casting Vision Backbone to *Half Precision* via `.to(dtype=...)`                                                                                                                                                                                                                                                                                                                                                                                  fsdp.py:146
05/10 [09:36:43] INFO     | >> [*] FSDP Full-Shard Strategy =>> Finalized Training Setup:                                                                                                                                                                                                                                                                                                                                                                                            fsdp.py:222
                                   |-> Global (Effective) Batch Size = 128                                                                                                                                                                                                                                                                                                                                                                                                                      
                                   |-> Per-Device Batch Size = 16                                                                                                                                                                                                                                                                                                                                                                                                                               
                                   |-> Distributed World Size = 2                                                                                                                                                                                                                                                                                                                                                                                                                               
                                   |-> Gradient Accumulation Steps = 4                                                                                                                                                                                                                                                                                                                                                                                                                          

                                   |-> LLM Backbone FSDP Gradient Checkpointing = True                                                                                                                                                                                                                                                                                                                                                                                                          
                                   |-> Use FSDP Mixed Precision = True                                                                                                                                                                                                                                                                                                                                                                                                                          
                                           |-> Parameter Precision = torch.bfloat16                                                                                                                                                                                                                                                                                                                                                                                                             
                                           |-> Reduction Precision = torch.bfloat16                                                                                                                                                                                                                                                                                                                                                                                                             
                                           |-> Buffer Precision = torch.bfloat16                                                                                                                                                                                                                                                                                                                                                                                                                

                                   |-> Default AdamW LR = 2e-05                                                                                                                                                                                                                                                                                                                                                                                                                                 
                                   |-> AdamW Weight Decay = 0.1                                                                                                                                                                                                                                                                                                                                                                                                                                 
                                   |-> LR Scheduler Type = linear-warmup+cosine-decay                                                                                                                                                                                                                                                                                                                                                                                                           
                                   |-> LR Scheduler Warmup Steps (Ratio) = 155 (0.03)                                                                                                                                                                                                                                                                                                                                                                                                           
                                   |-> Dataset Size = 665344 Examples                                                                                                                                                                                                                                                                                                                                                                                                                           
                                   |-> Max Steps = 5198                                                                                                                                                                                                                                                                                                                                                                                                                                         

                 INFO     | >> [*] Creating Metrics with Active Trackers => `('jsonl', 'wandb')`                                                                                                                                                                                                                                                                                                                                                                                 pretrain.py:213
wandb: Currently logged in as: rylan. Use `wandb login --relogin` to force relogin
wandb: ERROR Error while calling W&B API: project not found (<Response [404]>)
wandb: ERROR It appears that you do not have permission to access the requested resource. Please reach out to the project owner to grant you access. If you have the correct permissions, verify that there are no issues with your networking setup.(Error 404: Not Found)

Adding --wandb_entity <your entity name> --wandb_project <your project name> to the command fixes this error. I've included these in the README.md on my fork that I'll try to later merge back in .