Closed Teriks closed 4 weeks ago
Pipeline is not callable in this configuration even without offloading *
Disabling auto offloading of pipeline components on this line by removing the with context fixes the pipelines ability to function with this setup.
The other components such as the CLIP models being empty tensors initially is what causes the copy error when mixed with the additional model which starts on the CPU
this causes moving the entire pipeline with .to
to fail as well.
The offloading in single_file_utils should probably happen conditionally in some way that accounts for user supplied modules being present(?)
workaround:
import contextlib
import os
import diffusers
import diffusers.loaders
import diffusers.loaders.single_file_utils
import transformers
os.environ['HF_TOKEN'] = 'your token'
# monkey patch out the context manager
old_ctx_mgr = diffusers.loaders.single_file_utils.init_empty_weights
diffusers.loaders.single_file_utils.init_empty_weights = contextlib.nullcontext
encoder = transformers.T5EncoderModel.from_pretrained('stabilityai/stable-diffusion-3-medium-diffusers',
subfolder='text_encoder_3')
sd3 = diffusers.StableDiffusion3Pipeline.from_single_file(
'https://huggingface.co/stabilityai/stable-diffusion-3-medium/blob/main/sd3_medium_incl_clips.safetensors',
text_encoder_3=encoder)
# put it back
diffusers.loaders.single_file_utils.init_empty_weights = old_ctx_mgr
sd3.enable_sequential_cpu_offload()
sd3(prompt='test')
Cc: @DN6
This does not seem to be an issue in 0.29.1
Describe the bug
Attempting to load an SD3 checkpoint which includes clips from a single file, and supplying a T5 encoder loaded separately causes a meta tensor data copy error when calling
enable_sequential_cpu_offload()
orenable_model_cpu_offload()
Reproduction
or
Logs
System Info
Windows Python 3.12.3 transformers 4.41.2 diffusers 0.29.0 accelerate 0.31.0
Who can help?
No response