Skip to content

fix: for checking mandatory and optional pipeline components #11189

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

Merged
merged 1 commit into from
Apr 2, 2025

Conversation

elismasilva
Copy link
Contributor

What does this PR do?

This PR correct the verification of mandatory and optional pipeline components. Currently, if a mandatory component is not informed, an exception is generated due to an operation on incompatible types. The adjustment matches the type of the list of optional components so that the operation is executed correctly and the correct treatment is given to the user.

Expected:

Pipeline <class 'diffusers.pipelines.controlnet.pipeline_controlnet_sd_xl.StableDiffusionXLControlNetPipeline'> expected ['controlnet', 'feature_extractor', 'image_encoder', 'scheduler', 'text_encoder', 'text_encoder_2', 'tokenizer', 'tokenizer_2', 'unet', 'vae'], but only {'tokenizer_2', 'scheduler', 'tokenizer', 'text_encoder', 'vae', 'text_encoder_2', 'unet'} were passed.
  File "/mnt/f/projetos/diffusers/src/diffusers/pipelines/pipeline_utils.py", line 1002, in from_pretrained
    raise ValueError(
  File "/mnt/f/Projetos/diffusers/venv/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
    return fn(*args, **kwargs)
  File "/mnt/f/Projetos/diffusers/lang_code_data/test_verification_components.py", line 4, in <module>
    pipe = StableDiffusionXLControlNetPipeline.from_pretrained("SG161222/RealVisXL_V4.0",
  File "/home/master/miniconda3/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/master/miniconda3/lib/python3.10/runpy.py", line 196, in _run_module_as_main (Current frame)
    return _run_code(code, main_globals, None,
ValueError: Pipeline <class 'diffusers.pipelines.controlnet.pipeline_controlnet_sd_xl.StableDiffusionXLControlNetPipeline'> expected ['controlnet', 'feature_extractor', 'image_encoder', 'scheduler', 'text_encoder', 'text_encoder_2', 'tokenizer', 'tokenizer_2', 'unet', 'vae'], but only {'tokenizer_2', 'scheduler', 'tokenizer', 'text_encoder', 'vae', 'text_encoder_2', 'unet'} were passed.

Current error:

Exception has occurred: TypeError       (note: full exception trace is shown but execution is paused at: _run_module_as_main)
unsupported operand type(s) for -: 'set' and 'list'
  File "/mnt/f/projetos/diffusers/src/diffusers/pipelines/pipeline_utils.py", line 1001, in from_pretrained
    passed_modules = set(list(init_kwargs.keys()) + list(passed_class_obj.keys())) - optional_kwargs
  File "/mnt/f/Projetos/diffusers/venv/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
    return fn(*args, **kwargs)
  File "/mnt/f/Projetos/diffusers/lang_code_data/test_verification_components.py", line 4, in <module>
    pipe = StableDiffusionXLControlNetPipeline.from_pretrained("SG161222/RealVisXL_V4.0",
  File "/home/master/miniconda3/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/master/miniconda3/lib/python3.10/runpy.py", line 196, in _run_module_as_main (Current frame)
    return _run_code(code, main_globals, None,
TypeError: unsupported operand type(s) for -: 'set' and 'list'

Error simulation:

import torch
from diffusers import StableDiffusionXLControlNetPipeline

pipe = StableDiffusionXLControlNetPipeline.from_pretrained("SG161222/RealVisXL_V4.0", 
                                                            torch_dtype=torch.float16,                                                            
                                                            use_safetensors=True,
                                                            variant="fp16")

Before submitting

Who can review?

@asomoza @yiyixuxu

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Contributor

@hlky hlky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @elismasilva. Thanks for the fix

@hlky hlky merged commit be0b7f5 into huggingface:main Apr 2, 2025
28 of 29 checks passed
jonluca added a commit to weights-ai/diffusers that referenced this pull request Apr 3, 2025
* Raise warning and round down if Wan num_frames is not 4k + 1 (huggingface#11167)

* update

* raise warning and round to nearest multiple of scale factor

* [Docs] Fix environment variables in `installation.md` (huggingface#11179)

* Add `latents_mean` and `latents_std` to `SDXLLongPromptWeightingPipeline` (huggingface#11034)

* Bug fix in LTXImageToVideoPipeline.prepare_latents() when latents is already set (huggingface#10918)

* Bug fix in ltx

* Assume packed latents.

---------

Co-authored-by: Dhruv Nair <dhruv.nair@gmail.com>
Co-authored-by: YiYi Xu <yixu310@gmail.com>

* [tests] no hard-coded cuda  (huggingface#11186)

no cuda only

* [WIP] Add Wan Video2Video (huggingface#11053)

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* map BACKEND_RESET_MAX_MEMORY_ALLOCATED to reset_peak_memory_stats on XPU (huggingface#11191)

Signed-off-by: YAO Matrix <matrix.yao@intel.com>

* fix autocast (huggingface#11190)

Signed-off-by: jiqing-feng <jiqing.feng@intel.com>

* fix: for checking mandatory and optional pipeline components (huggingface#11189)

fix: optional componentes verification on load

* remove unnecessary call to `F.pad` (huggingface#10620)

* rewrite memory count without implicitly using dimensions by @ic-synth

* replace F.pad by built-in padding in Conv3D

* in-place sums to reduce memory allocations

* fixed trailing whitespace

* file reformatted

* in-place sums

* simpler in-place expressions

* removed in-place sum, may affect backward propagation logic

* removed in-place sum, may affect backward propagation logic

* removed in-place sum, may affect backward propagation logic

* reverted change

* allow models to run with a user-provided dtype map instead of a single dtype (huggingface#10301)

* allow models to run with a user-provided dtype map instead of a single dtype

* make style

* Add warning, change `_` to `default`

* make style

* add test

* handle shared tensors

* remove warning

---------

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>

* [tests] HunyuanDiTControlNetPipeline inference precision issue on XPU (huggingface#11197)

* add xpu part

* fix more cases

* remove some cases

* no canny

* format fix

* Revert `save_model` in ModelMixin save_pretrained and use safe_serialization=False in test (huggingface#11196)

* [docs] `torch_dtype` map (huggingface#11194)

* Fix enable_sequential_cpu_offload in CogView4Pipeline (huggingface#11195)

* Fix enable_sequential_cpu_offload in CogView4Pipeline

* make fix-copies

* SchedulerMixin from_pretrained and ConfigMixin Self type annotation (huggingface#11192)

* Update import_utils.py (huggingface#10329)

added onnxruntime-vitisai for custom build onnxruntime pkg

* Add CacheMixin to Wan and LTX Transformers (huggingface#11187)

* update

* update

* update

* feat: [Community Pipeline] - FaithDiff Stable Diffusion XL Pipeline (huggingface#11188)

* feat: [Community Pipeline] - FaithDiff Stable Diffusion XL Pipeline for Image SR.

* added pipeline

* [Model Card] standardize advanced diffusion training sdxl lora (huggingface#7615)

* model card gen code

* push modelcard creation

* remove optional from params

* add import

* add use_dora check

* correct lora var use in tags

* make style && make quality

---------

Co-authored-by: Aryan <aryan@huggingface.co>
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>

* Change KolorsPipeline LoRA Loader to StableDiffusion (huggingface#11198)

Change LoRA Loader to StableDiffusion

Replace the SDXL LoRA Loader Mixin inheritance with the StableDiffusion one

* Update Style Bot workflow (huggingface#11202)

update style bot workflow

---------

Signed-off-by: YAO Matrix <matrix.yao@intel.com>
Signed-off-by: jiqing-feng <jiqing.feng@intel.com>
Co-authored-by: Aryan <aryan@huggingface.co>
Co-authored-by: Mark <remarkablemark@users.noreply.github.com>
Co-authored-by: hlky <hlky@hlky.ac>
Co-authored-by: kakukakujirori <63725741+kakukakujirori@users.noreply.github.com>
Co-authored-by: Dhruv Nair <dhruv.nair@gmail.com>
Co-authored-by: YiYi Xu <yixu310@gmail.com>
Co-authored-by: Fanli Lin <fanli.lin@intel.com>
Co-authored-by: Yao Matrix <matrix.yao@intel.com>
Co-authored-by: jiqing-feng <jiqing.feng@intel.com>
Co-authored-by: Eliseu Silva <elismasilva@gmail.com>
Co-authored-by: Bruno Magalhaes <bruno.magalhaes@synthesia.io>
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
Co-authored-by: lakshay sharma <31830611+Lakshaysharma048@users.noreply.github.com>
Co-authored-by: Abhipsha Das <ad6489@nyu.edu>
Co-authored-by: Basile Lewandowski <basile.lewan@gmail.com>
Co-authored-by: célina <hanouticelina@gmail.com>
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