diffusers icon indicating copy to clipboard operation
diffusers copied to clipboard

Add FluxPAGPipeline with support for PAG

Open tongyu0924 opened this issue 6 months ago • 5 comments

What does this PR do?

This PR adds support for Perturbed Attention Guidance (PAG) to the FluxPipeline

Fixes #11488

Before submitting

  • [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • [x] Did you read the contributor guideline?
  • [x] Did you read our philosophy doc (important for complex PRs)?
  • [x] Was this discussed/approved via a GitHub issue or the forum? Please add a link to it if that's the case.
  • [ ] Did you make sure to update the documentation with your changes? Here are the documentation guidelines, and here are tips on formatting docstrings.
  • [ ] Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag members/contributors who may be interested in your PR.

tongyu0924 avatar May 06 '25 21:05 tongyu0924

@tongyu0924 Is this ready for review? If so, could you move the pipeline under src/diffusers/pipelines/pag please and make the changes needed to import the pipeline?

DN6 avatar May 22 '25 08:05 DN6

@tongyu0924 Is this ready for review? If so, could you move the pipeline under src/diffusers/pipelines/pag please and make the changes needed to import the pipeline?

Done! The pipeline is now under src/diffusers/pipelines/pag. It's ready for review

tongyu0924 avatar May 23 '25 09:05 tongyu0924

Thank you @tongyu0924 👍🏽! Could we add the pipeline to the necessary init files

PAG Module: https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/pag/init.py

Pipelines Module: https://github.com/huggingface/diffusers/blob/049082e013fb71d78f3abf487916f3de2b674908/src/diffusers/pipelines/init.py#L175

Diffusers main init https://github.com/huggingface/diffusers/blob/049082e013fb71d78f3abf487916f3de2b674908/src/diffusers/init.py#L341

And then could you please add a fast test for the pipeline, similar to how it has been done here https://github.com/huggingface/diffusers/blob/049082e013fb71d78f3abf487916f3de2b674908/tests/pipelines/pag/test_pag_sd3.py#L26

DN6 avatar May 26 '25 07:05 DN6

Thank you @tongyu0924 👍🏽! Could we add the pipeline to the necessary init files

PAG Module: https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/pag/init.py

Pipelines Module:

https://github.com/huggingface/diffusers/blob/049082e013fb71d78f3abf487916f3de2b674908/src/diffusers/pipelines/init.py#L175

Diffusers main init

https://github.com/huggingface/diffusers/blob/049082e013fb71d78f3abf487916f3de2b674908/src/diffusers/init.py#L341

And then could you please add a fast test for the pipeline, similar to how it has been done here

https://github.com/huggingface/diffusers/blob/049082e013fb71d78f3abf487916f3de2b674908/tests/pipelines/pag/test_pag_sd3.py#L26

I've added the pipeline to the necessary __init__.py files and added a fast test following the structure in test_pag_sd3.py.

tongyu0924 avatar May 26 '25 15:05 tongyu0924

Please update the following if possible

diffusers/src/diffusers/pipelines/pag/pipeline_pag_flux.py

EXAMPLE_DOC_STRING = """ Examples: ```py >>> import torch >>> from diffusers import FluxPipeline

    >>> pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16)
    >>> pipe.to("cuda")
    >>> prompt = "A cat holding a sign that says hello world"
    >>> # Depending on the variant being used, the pipeline call will slightly vary.
    >>> # Refer to the pipeline documentation for more details.
    >>> image = pipe(prompt, num_inference_steps=4, guidance_scale=0.0).images[0]
    >>> image.save("flux.png")
    ```

"""

nitinmukesh avatar Jun 09 '25 16:06 nitinmukesh

hi, just wanted to check in, are there any updates on when this might be merged?

semioz avatar Aug 10 '25 18:08 semioz