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