Vision encoder forward pass cost (ViT/SigLIP/CLIP)
Fields
flops/vision-encoder-forward-pass-cost-vit-siglip-clipNotes
THE CENTRAL COST FACT: For a single 224x224 image, the vision encoder forward pass costs MORE total FLOPs than the entire LLM prefill for a typical prompt. ViT-L/16 at 224x224 = 190.7 GFLOPs (source: ViT paper Table 6). A 7B LLM prefill for a 1000-token prompt costs ~2*7e9*1000 = 14 TFLOPs = 14,000 GFLOPs. So the vision encoder is ~1.4% of the LLM prefill at 224x224. Encoder FLOPs scale with the SQUARE of resolution: 224->448 is 4x (~763 GFLOPs) and 224->1024 is (1024/224)^2 = 20.9x (~3,985 GFLOPs). CORRECTION: an earlier draft of this record wrongly reported 12,200 GFLOPs at 1024x1024 (a 64x factor) and that this is 'comparable to or exceeds the LLM prefill'. The 64x factor is wrong; 20.9x is correct. At 3,985 GFLOPs the encoder is ~28.5% of a 7B model's 1000-token prefill and only ~2.8% of a 70B model's. The encoder is NOT comparable to prefill for a large LLM at any tested resolution. The key insight is that vision encoder cost scales with resolution while LLM prefill cost scales with text length, so the ratio is attacker-controlled via image size. SigLIP SO400M at 224x224 = ~41 GFLOPs (source: Google Big Vision repo). CLIP ViT-L/14 at 224x224 = ~17.5 GFLOPs (source: OpenCLIP). DINOv2-L at 224x224 = ~17.5 GFLOPs (same architecture as CLIP ViT-L/14). The FLOP counts are from the original papers or standard calculations; the ViT paper Table 6 is the most authoritative source. The comparison to LLM prefill is derived: 2*params*tokens is the standard prefill FLOP formula.