Skip to content

fix(aura_flow): cast latents to VAE dtype on every decode#14219

Open
sergioperezcheco wants to merge 1 commit into
huggingface:mainfrom
sergioperezcheco:fix/auraflow-vae-dtype-reuse
Open

fix(aura_flow): cast latents to VAE dtype on every decode#14219
sergioperezcheco wants to merge 1 commit into
huggingface:mainfrom
sergioperezcheco:fix/auraflow-vae-dtype-reuse

Conversation

@sergioperezcheco

Copy link
Copy Markdown

Calling AuraFlowPipeline a second time on the same instance raises RuntimeError: Input type (c10::Half) and bias type (float) should be the same. The decode block only cast latents to the VAE dtype when needs_upcasting was True, but upcast_vae() moves the whole VAE to fp32 in place on the first call, so on the second call needs_upcasting is False and fp16 latents go straight into the now-fp32 VAE. I moved the latents.to(self.vae.dtype) inline at the decode call so it always runs, matching what pixart_sigma already does (the fix from #8391 for the same class of bug). Added a regression test that simulates the post-upcast state and confirms the cast runs unconditionally. Fixes #14183.

AuraFlowPipeline guarded the latents dtype cast behind needs_upcasting, so
after the first call upcast_vae() left the VAE in fp32 and the second call
fed fp16 latents into it, raising RuntimeError. Cast latents to the VAE
dtype inline at the decode call (matching the pixart_sigma fix in huggingface#8391) so
the cast runs unconditionally. Added a regression test.

Fixes huggingface#14183
@sergioperezcheco
sergioperezcheco force-pushed the fix/auraflow-vae-dtype-reuse branch from 8821e8d to 86dc582 Compare July 18, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fixes-issue size/S PR with diff < 50 LOC tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AuraFlowPipeline: VAE dtype mismatch on pipeline reuse (latents cast skipped on 2nd call)

1 participant