You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Particularly, the next(iter()) call causes the evaluation of the lazy tensors that preceed this part of the graph, forcing conv_in module to compile independently.
It would be ideal if this upscale_dtype can be inferred in a different way
Thanks!
Reproduction
This is the repro code:
import torch
from diffusers import AutoencoderKL
vae = AutoencoderKL.from_pretrained(
"stabilityai/stable-diffusion-xl-base-1.0",
subfolder="vae",
torch_dtype=torch.float16
)
model = vae.decoder
model = model.eval()
model = model.to(torch.bfloat16)
device = torch.device("cpu")
sample_img = torch.randn(1, 4, 64, 64, dtype=torch.bfloat16)
model.compile()
sample_img = sample_img.to(device)
model = model.to(device)
with torch.no_grad():
output = model(sample_img)
Activity
sayakpaul commentedon Oct 17, 2025
Have you tried compiling just the decode method?
Like
vae.decode = torch.compile(vae.decode)?Cc: @anijain2305
ppadjinTT commentedon Oct 20, 2025
Decode method calls upon the decoder forward method under the hood, so it doesn't help unfortunately
ppadjinTT commentedon Oct 20, 2025
Since conv_out and upscale_blocks are of the same dtype, is there any chance the line
Can be replaced with:
This solves the problem
I can make a pull request if you think that is okay?
@sayakpaul @anijain2305
ppadjinTT commentedon Oct 20, 2025
I opened a PR #12512 , let me know if you think this is valid!