mlsanityData to 7 Oct 2026

Breaking the Memory Barrier: Near Infinite Batch Size Scaling for Contrastive Loss

arXiv 2410.17243 ↗First posted 22 Oct 2024cs.CVcited by 4

Not on the map. Why?

Abstract (arXiv)

Contrastive loss is a powerful approach for representation learning, where larger batch sizes enhance performance by providing more negative samples to better distinguish between similar and dissimilar data. However, scaling batch sizes is constrained by the quadratic growth in GPU memory consumption, primarily due to the full instantiation of the similarity matrix. To address this, we propose a tile-based computation strategy that partitions the contrastive loss calculation into arbitrary small blocks, avoiding full materialization of the similarity matrix. Furthermore, we introduce a multi-level tiling strategy to leverage the hierarchical structure of distributed systems, employing ring-based communication at the GPU level to optimize synchronization and fused kernels at the CUDA core level to reduce I/O overhead. Experimental results show that the proposed method scales batch sizes to unprecedented levels. For instance, it enables contrastive training of a CLIP-ViT-L/14 model with a batch size of 4M or 12M using 8 or 32 A800 80GB without sacrificing any accuracy. Compared to SOTA memory-efficient solutions, it achieves a two-order-of-magnitude reduction in memory while maintaining comparable speed. The code will be made publicly available.

Key facts. Cited by 4 papers in the map (data through 7 Oct 2026). Builds on 33 of its 41 references that are in the map. First posted on arXiv 22 Oct 2024.

Builds on

33 of 41 references.

References · 33

  1. 2021Learning Transferable Visual Models From Natural Language Supervisioncited by 33,456
  2. 2020A Simple Framework for Contrastive Learning of Visual Representationscited by 11,979
  3. 2018Representation Learning with Contrastive Predictive Codingcited by 7,662
  4. 2019Momentum Contrast for Unsupervised Visual Representation Learningcited by 7,482
  5. 2020Scaling Laws for Neural Language Modelscited by 6,411
  6. 2021Scaling Up Visual and Vision-Language Representation Learning With Noisy Text Supervisioncited by 3,848
  7. 2020Dense Passage Retrieval for Open-Domain Question Answeringcited by 3,779
  8. 2022FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awarenesscited by 3,611
  9. 2023Sigmoid Loss for Language Image Pre-Trainingcited by 3,048
  10. 2021SimCSE: Simple Contrastive Learning of Sentence Embeddingscited by 2,168
  11. 2021LAION-400M: Open Dataset of CLIP-Filtered 400 Million Image-Text Pairscited by 1,544
  12. 2019Do ImageNet Classifiers Generalize to ImageNet?cited by 1,507
21 more
  1. 2017Accurate, Large Minibatch SGD: Training ImageNet in 1 Hourcited by 1,479
  2. 2015Microsoft COCO Captions: Data Collection and Evaluation Servercited by 1,447
  3. 2019Natural Adversarial Examplescited by 1,401
  4. 2020Big Self-Supervised Models are Strong Semi-Supervised Learnerscited by 1,375
  5. 2022Text Embeddings by Weakly-Supervised Contrastive Pre-trainingcited by 1,216
  6. 2023ImageBind: One Embedding Space To Bind Them Allcited by 1,162
  7. 2017Mixed Precision Trainingcited by 1,135
  8. 2021Scaling Vision Transformerscited by 993
  9. 2018Adafactor: Adaptive Learning Rates with Sublinear Memory Costcited by 896
  10. 2021CLIP4Clip: An Empirical Study of CLIP for End to End Video Clip Retrievalcited by 645
  11. 2021LiT: Zero-Shot Transfer with Locked-image text Tuningcited by 572
  12. 2019A Theoretical Analysis of Contrastive Unsupervised Representation Learningcited by 530
  13. 2023Ring Attention with Blockwise Transformers for Near-Infinite Contextcited by 448
  14. 2017Train longer, generalize better: closing the generalization gap in large batch training of neural networkscited by 278
  15. 2021Scaling Deep Contrastive Learning Batch Size under Memory Limited Setupcited by 123
  16. 2022Chinese CLIP: Contrastive Vision-Language Pretraining in Chinesecited by 108
  17. 2023MobileCLIP: Fast Image-Text Models through Multi-Modal Reinforced Trainingcited by 96
  18. 2021Adversarial Retriever-Ranker for dense text retrievalcited by 82
  19. 2019Low-Memory Neural Network Training: A Technical Reportcited by 56
  20. 2023DisCo-CLIP: A Distributed Contrastive Loss for Memory Efficient CLIP Trainingcited by 15
  21. 2023Noisy Pair Corrector for Dense Retrievalcited by 5

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2025: 2; 2026: 2.

4 papers.