Uh oh!
There was an error while loading. Please reload this page.
use kernels to support _flash_hub attention backend - #12318
Closed
ParagEkbote wants to merge 9 commits into
Closed
Conversation
sayakpaul
commented
Sep 11, 2025
Member
Thanks for this PR. Could you update it with some code examples and results? |
ContributorAuthor
This is the test command, but unable to generate images. importosos.environ["DIFFUSERS_ENABLE_HUB_KERNELS"] ="yes"# Debug: Verify the env var is setprint(f"DIFFUSERS_ENABLE_HUB_KERNELS = {os.environ.get('DIFFUSERS_ENABLE_HUB_KERNELS')}")
importtorchfromdiffusersimportFluxPipelinefromdiffusers.quantizersimportPipelineQuantizationConfig# Debug: Check if diffusers sees the env varfromdiffusers.models.attention_dispatchimportDIFFUSERS_ENABLE_HUB_KERNELSprint(f"Diffusers sees DIFFUSERS_ENABLE_HUB_KERNELS = {DIFFUSERS_ENABLE_HUB_KERNELS}")
# ✅ 3. Load pipeline with quantizationmodel_id="black-forest-labs/FLUX.1-dev"pipe=FluxPipeline.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
quantization_config=PipelineQuantizationConfig(
quant_backend="bitsandbytes_4bit",
quant_kwargs={
"load_in_4bit": True,
"bnb_4bit_quant_type": "nf4",
"bnb_4bit_compute_dtype": torch.bfloat16,
},
components_to_quantize=["transformer"],
),
).to("cuda")
pipe.transformer.set_attention_backend("_flash_hub")
prompt="A cat holding a sign that says 'hello world'"image=pipe(prompt, num_inference_steps=28, guidance_scale=4.0).images[0]
image.save("output.png") |
ParagEkbote
commented
Sep 12, 2025
ContributorAuthor
I'm having issues regarding some of the parameters with the following traceback: The same error occurs with dropout_p parameter as well. WDYT? cc: @sayakpaul |
sayakpaul
commented
Sep 25, 2025
Member
@ParagEkbote I think we can close this PR in favor of #12387. You're more than welcome to test the PR and let us know of any feedback. |
ParagEkbote
commented
Sep 25, 2025
ContributorAuthor
@sayakpaul Thanks for letting me know and being a patient reviewer. Closing the PR.. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
As discussed in the issue, this PR adds support for kernels-community/flash-attn kernel. Could you please review?
Fixes#12308
Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@sayakpaul