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

Fix latents.dtype before vae.decode() at ROCm devices in StableDiffusionPipelines #7886

Closed
wants to merge 13 commits into from

Conversation

tolgacangoz
Copy link
Contributor

@tolgacangoz tolgacangoz commented May 8, 2024

Co-authored-by: Bagheera [email protected]

What does this PR do?

This was talked about at a previous PR: #7858.

Before submitting

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
@yiyixuxu @bghira

@tolgacangoz tolgacangoz changed the title Fix latents.dtype before vae.decode() at ROCm Fix latents.dtype before vae.decode() at ROCm in StableDiffusionPipelines May 8, 2024
@tolgacangoz tolgacangoz changed the title Fix latents.dtype before vae.decode() at ROCm in StableDiffusionPipelines Fix latents.dtype before vae.decode() at ROCm devices in StableDiffusionPipelines May 8, 2024
@bghira
Copy link
Contributor

bghira commented May 8, 2024

so i can actually hit this one on CUDA, but it only happens during training without autocast 🤔

the weights are in bf16 precision, not fp32. maybe this is what causes it?

@tolgacangoz
Copy link
Contributor Author

tolgacangoz commented May 31, 2024

Since I don't have a ROCm device, I can't work on this PR directly :/ What to do here?
Doesn't inferencing with bf16 produce a casting error?

@bghira
Copy link
Contributor

bghira commented May 31, 2024

inferencing is when the error occurs, but that's generally during training time, as the components can be initialised with different weight dtypes. it's not really clear why the scheduler can change the dtype other than certain calculations end up with the default torch dtype of float32 when one isn't specified, and i think autocast takes care of this. but we can't rely on autocast existing or being in use, because not all platforms support it - and future training might not use it at all, instead relying on bf16 optimiser states.

@tolgacangoz tolgacangoz marked this pull request as draft July 24, 2024 19:30
@tolgacangoz tolgacangoz changed the title Fix latents.dtype before vae.decode() at ROCm devices in StableDiffusionPipelines [Sleeping] Fix latents.dtype before vae.decode() at ROCm devices in StableDiffusionPipelines Sep 7, 2024
@tolgacangoz tolgacangoz changed the title [Sleeping] Fix latents.dtype before vae.decode() at ROCm devices in StableDiffusionPipelines Fix latents.dtype before vae.decode() at ROCm devices in StableDiffusionPipelines Sep 27, 2024
@tolgacangoz tolgacangoz changed the title Fix latents.dtype before vae.decode() at ROCm devices in StableDiffusionPipelines __Fix__ latents.dtype before vae.decode() at ROCm devices in StableDiffusionPipelines Oct 11, 2024
@tolgacangoz tolgacangoz changed the title __Fix__ latents.dtype before vae.decode() at ROCm devices in StableDiffusionPipelines _Fix_ latents.dtype before vae.decode() at ROCm devices in StableDiffusionPipelines Oct 11, 2024
@tolgacangoz tolgacangoz changed the title _Fix_ latents.dtype before vae.decode() at ROCm devices in StableDiffusionPipelines Fix latents.dtype before vae.decode() at ROCm devices in StableDiffusionPipelines Oct 11, 2024
Copy link

github-actions bot commented Nov 4, 2024

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

@github-actions github-actions bot added the stale Issues that haven't received updates label Nov 4, 2024
@tolgacangoz tolgacangoz marked this pull request as ready for review November 4, 2024 16:19
@yiyixuxu yiyixuxu removed the stale Issues that haven't received updates label Nov 4, 2024
@yiyixuxu
Copy link
Collaborator

yiyixuxu commented Nov 4, 2024

@tolgacangoz
hey, sorry if I missed some context for this PR - why do we need to update this deprecated method?

@bghira
Copy link
Contributor

bghira commented Nov 4, 2024

because it has dtype inconsistency upon vae.decode especially when vae is upcast outside of the pipeline

@yiyixuxu
Copy link
Collaborator

yiyixuxu commented Nov 5, 2024

@bghira is this used in training?
asking becaUse the method is deprecated and will be removed in the future

@tolgacangoz tolgacangoz deleted the fix-rocm branch November 17, 2024 08:34
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

Successfully merging this pull request may close these issues.

3 participants