arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2304.08480cs.CVcs.AIcs.CL
收藏

DisCo-CLIP:一种用于内存高效 CLIP 训练的分布式对比损失

DisCo-CLIP: A Distributed Contrastive Loss for Memory Efficient CLIP Training

International Digital Economy Academy (IDEA)(国际数字经济学院(IDEA))

Yihao Chen, Xianbiao Qi, Jianan Wang, Lei Zhang

AI总结:

DisCo-CLIP 通过将对比损失分解为 GPU 内和 GPU 间梯度计算,把内存复杂度从 O(B²) 降至 O(B²/N),在不损失精度的情况下实现大规模 CLIP 高效训练。

摘要:

我们提出 DisCo-CLIP,一种分布式内存高效的 CLIP 训练方法,以减少训练对比学习模型时对比损失的内存消耗。我们的方法将对比损失及其梯度计算分解为两部分,一部分用于计算 GPU 内梯度,另一部分用于计算 GPU 间梯度。根据我们的分解方式,当前 GPU 上只计算 GPU 内梯度,而 GPU 间梯度通过 all_reduce 从其他 GPU 收集,而不是在每个 GPU 上重复计算。通过这种方式,我们可以将对比损失计算的 GPU 内存消耗从 $\igO(B^2)$ 降低到 $\igO(\ rac{B^2}{N})$,其中 $B$ 和 $N$ 分别是批量大小和用于训练的 GPU 数量。这种分布式解决方案在数学上等价于原始的非分布式对比损失计算,不会牺牲任何计算精度。它对于大批量 CLIP 训练尤其高效。例如,DisCo-CLIP 可以使用 8 或 64 个 A100 40GB GPU 对批量大小为 32K 或 196K 的 ViT-B/32 模型进行对比训练,而原始 CLIP 解决方案需要 128 个 A100 40GB GPU 才能训练批量大小为 32K 的 ViT-B/32 模型。代码将在 https://github.com/IDEA-Research/DisCo-CLIP 发布。

英文摘要:

We propose DisCo-CLIP, a distributed memory-efficient CLIP training approach, to reduce the memory consumption of contrastive loss when training contrastive learning models. Our approach decomposes the contrastive loss and its gradient computation into two parts, one to calculate the intra-GPU gradients and the other to compute the inter-GPU gradients. According to our decomposition, only the intra-GPU gradients are computed on the current GPU, while the inter-GPU gradients are collected via all_reduce from other GPUs instead of being repeatedly computed on every GPU. In this way, we can reduce the GPU memory consumption of contrastive loss computation from $\bigO(B^2)$ to $\bigO(\frac{B^2}{N})$, where $B$ and $N$ are the batch size and the number of GPUs used for training. Such a distributed solution is mathematically equivalent to the original non-distributed contrastive loss computation, without sacrificing any computation accuracy. It is particularly efficient for large-batch CLIP training. For instance, DisCo-CLIP can enable contrastive training of a ViT-B/32 model with a batch size of 32K or 196K using 8 or 64 A100 40GB GPUs, compared with the original CLIP solution which requires 128 A100 40GB GPUs to train a ViT-B/32 model with a batch size of 32K. The code will be released at https://github.com/IDEA-Research/DisCo-CLIP

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑