Breaking the Memory Barrier of Contrastive Loss via Tile-Based Strategy

Zesen Cheng, Hang Zhang, Kehan Li, Sicong Leng, Zhiqiang Hu +4 more
2/10/2026

No confident code implementation found for this paper.

Abstract

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, the full instantiation of the similarity matrix demands substantial GPU memory, making large batch training highly resource-intensive. To address this, we propose a tile-based computation strategy that partitions the contrastive loss calculation into small blocks, avoiding full materialization of the similarity matrix. Additionally, we introduce a multi-level tiling implementation to leverage the hierarchical structure of distributed systems, using 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 significantly reduces GPU memory usage in contrastive loss. For instance, it enables contrastive training of a CLIP-ViT-L/14 model with a batch size of 4M using only 8 A800 80GB GPUs, without sacrificing accuracy. Compared to state-of-the-art memory-efficient solutions, it achieves a two-order-of-magnitude reduction in memory while maintaining comparable speed. The code will be made publicly available.1

DOISemantic Scholar

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Cite this paper

@article{cheng2026breaking,
  title  = {Breaking the Memory Barrier of Contrastive Loss via Tile-Based Strategy},
  author = {Zesen Cheng and Hang Zhang and Kehan Li and Sicong Leng and Zhiqiang Hu and Fei Wu and Deli Zhao and Xin Li and Li Bing},
  year   = {2026},
  doi    = {10.1109/CVPR52734.2025.00938},
  url    = {https://doi.org/10.1109/CVPR52734.2025.00938},
  journal = {CVPR 2025 2025}
}

Discussion