-
-
Notifications
You must be signed in to change notification settings - Fork 768
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
Any specific reason sampling is not in FP16? #377
Comments
how to run this code, please provide the step for text to image , please |
When training neural networks, especially large models, it's common to use mixed precision training to save memory and speed up computations. This involves using FP16 (half-precision) for certain operations while retaining FP32 (full-precision) for others where higher precision is necessary. The code snippet you provided shows the use of mixed precision during training but not during sampling. This is because sampling (inference) typically doesn't require the same precision optimization as training, but it can still benefit from FP16 for memory efficiency. To ensure that your sampling loop also benefits from FP16 precision, you can add the necessary casting.
simplified code for cast_torch_tensor decorator that supports FP16 casting:
Hope this helps, |
During training the forward method casts to FP16 but during sampling no
I tried casting to FP16 and something in the loop changes to
float32
even if the inputs arefloat16
I wonder if you have already encountered that and if that's the reason there's no casting to FP16 during sampling
Best regards and thanks for the great repo,
The text was updated successfully, but these errors were encountered: