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

Add backwards compatibility w/ older versions of diffusers (<0.25.0) #5083

Merged
merged 5 commits into from
Feb 6, 2024

Conversation

lekurile
Copy link
Contributor

@lekurile lekurile commented Feb 5, 2024

This PR adds backwards compatibility for older versions of diffusers (<0.25.0) by updating the vae container import logic to account for changes between the various versions.

@lekurile lekurile enabled auto-merge February 6, 2024 00:42
@lekurile lekurile added this pull request to the merge queue Feb 6, 2024
Merged via the queue into master with commit e212845 Feb 6, 2024
13 checks passed
@mikob
Copy link

mikob commented Feb 6, 2024

Tried this out, hit another roadblock:

[2024-02-06 14:20:04,114] [INFO] [logging.py:96:log_dist] [Rank -1] quantize_bits = 8 mlp_extra_grouping = False, quantize_groups = 1
Traceback (most recent call last):
  File "/home/mikob/workspace/hairgen.ai/backend/worker/main.py", line 10, in <module>
    init_expensive_stuff()
  File "/home/mikob/workspace/hairgen.ai/backend/worker/core/inpaint.py", line 54, in init_expensive_stuff
    pipe = deepspeed.init_inference(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mikob/.cache/pypoetry/virtualenvs/hairgen-ai-worker-23uPZkfb-py3.11/lib/python3.11/site-packages/deepspeed/__init__.py", line 342, in init_inference
    engine = InferenceEngine(model, config=ds_inference_config)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mikob/.cache/pypoetry/virtualenvs/hairgen-ai-worker-23uPZkfb-py3.11/lib/python3.11/site-packages/deepspeed/inference/engine.py", line 158, in __init__
    self._apply_injection_policy(config)
  File "/home/mikob/.cache/pypoetry/virtualenvs/hairgen-ai-worker-23uPZkfb-py3.11/lib/python3.11/site-packages/deepspeed/inference/engine.py", line 414, in _apply_injection_policy
    generic_injection(self.module, dtype=config.dtype, enable_cuda_graph=config.enable_cuda_graph)
  File "/home/mikob/.cache/pypoetry/virtualenvs/hairgen-ai-worker-23uPZkfb-py3.11/lib/python3.11/site-packages/deepspeed/module_inject/replace_module.py", line 162, in generic_injection
    policy = _module_match(sub_module)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mikob/.cache/pypoetry/virtualenvs/hairgen-ai-worker-23uPZkfb-py3.11/lib/python3.11/site-packages/deepspeed/module_inject/replace_module.py", line 81, in _module_match
    policy = policy()
             ^^^^^^^^
  File "/home/mikob/.cache/pypoetry/virtualenvs/hairgen-ai-worker-23uPZkfb-py3.11/lib/python3.11/site-packages/deepspeed/module_inject/containers/unet.py", line 19, in __init__
    self._orig_layer_class = diffusers.models.unet_2d_condition.UNet2DConditionModel
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mikob/.cache/pypoetry/virtualenvs/hairgen-ai-worker-23uPZkfb-py3.11/lib/python3.11/site-packages/diffusers/utils/import_utils.py", line 697, in __getattr__
    raise AttributeError(f"module {self.__name__} has no attribute {name}")
AttributeError: module diffusers.models has no attribute unet_2d_condition. Did you mean: 'unets.unet_2d_condition'?

That was easily fixed with:
self._orig_layer_class = diffusers.models.unets.unet_2d_condition.UNet2DConditionModel

But now I get a runtime error when doing size 512 images:
Error: Sizes of tensors must match except in dimension 1. Expected size 64 but got size 512 for tensor number 2 in the list

mauryaavinash95 pushed a commit to mauryaavinash95/DeepSpeed that referenced this pull request Feb 17, 2024
…eepspeedai#5083)

This PR adds backwards compatibility for older versions of `diffusers`
(`<0.25.0`) by updating the `vae` container import logic to account for
changes between the various versions.
rraminen pushed a commit to ROCm/DeepSpeed that referenced this pull request May 9, 2024
…eepspeedai#5083)

This PR adds backwards compatibility for older versions of `diffusers`
(`<0.25.0`) by updating the `vae` container import logic to account for
changes between the various versions.
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