Skip to content

Instantly share code, notes, and snippets.

View cbensimon's full-sized avatar

Charles cbensimon

View GitHub Profile
@cbensimon
cbensimon / aot_regional_dynamic.py
Created September 4, 2025 15:22
PyTorch regional AoT compilation with dynamic shapes (QwenImageEdit)
"""
"""
import spaces
import torch
from diffusers import DiffusionPipeline
from diffusers.utils import load_image
from spaces.zero.torch.aoti import ZeroGPUCompiledModel
from spaces.zero.torch.aoti import ZeroGPUWeights
from torch.utils._pytree import tree_map
@cbensimon
cbensimon / zerogpu-aoti-multi.py
Created September 1, 2025 14:14
Multi-compile + dispatch for ZeroGPU AoT compilation
@spaces.GPU
def compile():
with spaces.aoti_capture(pipe.transformer) as call_landscape:
pipe("prompt", width=832, height=480)
with spaces.aoti_capture(pipe.transformer) as call_portrait:
pipe("prompt", width=480, height=832)
exported_landscape = torch.export.export(model, args=call_landscape.args, kwargs=call_landscape.kwargs)
exported_portrait = torch.export.export(model, args=call_portrait.args, kwargs=call_portrait.kwargs)