Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change dtype on inference #171

Closed
MaxKochanov opened this issue Nov 2, 2021 · 1 comment
Closed

Change dtype on inference #171

MaxKochanov opened this issue Nov 2, 2021 · 1 comment

Comments

@MaxKochanov
Copy link

MaxKochanov commented Nov 2, 2021

Hello!

In the issue #30 you answered: "Empirically, we have been doing CLIP inference in fp16 without much problem, and that's how the model was trained for anyway".

In this case I have two questions:

  1. Is there any chance to change dtype of CLIP weights from float32 to float16 and use it on GPU? You said "without much problem", and I`ve already dived into the code, but I have not succeed to change the dtype correctly.

  2. Do I understand right that you trained CLIP on float32?

@jongwook
Copy link
Collaborator

  1. For most of weights it's safe to convert the parameter dtypes to float16, but some operations like LayerNorm needs to be done in fp32 for stable training. We convert some of the weights depending on the layer's type; see convert_weights().

  2. We used mixed precision training for training CLIP, as mentioned in Section 2.5 of the paper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants