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

ValueError : Attemting to unscale fp16 Gradients #6

Open
ADKoishi opened this issue Jan 16, 2024 · 1 comment
Open

ValueError : Attemting to unscale fp16 Gradients #6

ADKoishi opened this issue Jan 16, 2024 · 1 comment

Comments

@ADKoishi
Copy link
Contributor

Fine-tuning the u-net with LoRA disabled and fp16 AMP will trigger a “[ValueError : Attemting to unscale fp16 Gradients]” error.
Obviously, this is caused by the dtype of the parameters and gradients in the u-net module being fp16, and the scaler failed to scale those gradients.
This could be fixed with:
[train_with_rm.py]
pipeline.vae.to(accelerator.device, dtype=inference_dtype)
pipeline.text_encoder.to(accelerator.device, dtype=inference_dtype)
[NEW] -> unet_dtype = inference_dtype if config.use_lora else torch.float32
pipeline.unet.to(accelerator.device, dtype=unet_dtype)
🤔 Is there any better solutions?

@AHHHZ975
Copy link

I had the same issue and this resolved it.

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