mirror of
https://github.com/openai/CLIP.git
synced 2026-11-05 01:37:26 +00:00
[GH-ISSUE #29] Clarification of training details #26
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
openai/CLIP#26
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jwyang on GitHub (Jan 30, 2021).
Original GitHub issue: https://github.com/openai/CLIP/issues/29
Dear CLIP Authors,
Recently, I am reading the training details in the paper:
To save additional memory, gradient checkpointing (Griewank & Walther, 2000; Chen et al., 2016), half-precision Adam statistics (Dhariwal et al., 2020), and half-precision stochastically rounded text encoder weights were used. The calculation of embedding
similarities was also sharded with individual GPUs computing only the subset of the pairwise similarities necessary for their local batch of embeddings.
I have two questions:
thanks,
Jianwei
@jongwook commented on GitHub (Jan 30, 2021):
When the fp32 encoder weights are cast to fp16, rather than deterministically rounding to the nearest fp16 point, stochastic rounding casts the value pseudorandomly to either ⌈x⌉ or ⌊x⌋ according to some probability. This reference mentions two modes for doing this, in (1.1) and (1.2).
Say there are N GPUs and each GPU gets M input pairs. When calculating similarities (and thus the logit scores across text inputs for each image) a GPU only needs to hold M image features, which needs to be matmul'ed with NM text features, resulting in an M×NM matrix. This computation is distributed (i.e. sharded) across N GPUs, and overall we have calculated NM×NM similarities across the GPUs. The loss we use is symmetric and the same happens w.r.t. text inputs.
@jwyang commented on GitHub (Jan 30, 2021):
Hi, Jongwook,
thanks a lot for your quick reply! The explanations are very helpful to understand the training procedure!
@KeremTurgutlu commented on GitHub (Feb 20, 2021):
Thanks for the explanation, is there a sample code in pytorch on how to do that? Is it similar to this or is there a more efficient way that was used during CLIP training? Thanks!