[kernels] download kernels when users request for it. by sayakpaul · Pull Request #14298 · huggingface/diffusers · GitHub
Skip to content

[kernels] download kernels when users request for it. - #14298

Merged
sayakpaul merged 4 commits into
mainfrom
user-permission-kernel
Aug 3, 2026
Merged

sayakpaul merged 4 commits into
mainfrom
user-permission-kernel

Conversation

@sayakpaul

Copy link
Copy Markdown
Member

We were downloading and loading kernels for gguf and nunchaku-lite without asking from users. This PR fixes that.

@sayakpaul
sayakpaul requested a review from DN6 July 27, 2026 08:05
@github-actions github-actions Bot added documentation Improvements or additions to documentation quantization utils size/S PR with diff < 50 LOC labels Jul 27, 2026
@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

Comment thread src/diffusers/quantizers/gguf/utils.py Outdated
from kernels import get_kernel

ops = get_kernel("Isotr0py/ggml")
ops = get_kernel("Isotr0py/ggml", trust_remote_code=DIFFUSERS_TRUST_REMOTE_KERNELS)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Wouldn't this break for anyone using kernels<=0.14?
https://github.com/huggingface/diffusers/pull/14298/changes#diff-249c332f10872ba150d634947de12055f99d9db5c3dbf2bef092ccba775f39bdR97

Also trust_remote_code should resolve based on whether downloading remote code is remotely disabled as well.

Suggested change
ops = get_kernel("Isotr0py/ggml", trust_remote_code=DIFFUSERS_TRUST_REMOTE_KERNELS)
ops = get_kernel("Isotr0py/ggml", trust_remote_code=DIFFUSERS_TRUST_REMOTE_KERNELS and not DIFFUSERS_DISABLE_REMOTE_CODE)

from kernels import get_kernel

ops = get_kernel(_HF_KERNEL_REPO, version=_HF_KERNEL_VERSION, trust_remote_code=True).ops
ops = get_kernel(_HF_KERNEL_REPO, version=_HF_KERNEL_VERSION, trust_remote_code=DIFFUSERS_TRUST_REMOTE_KERNELS).ops

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should also respect global remote code download flag

Suggested change
ops = get_kernel(_HF_KERNEL_REPO, version=_HF_KERNEL_VERSION, trust_remote_code=DIFFUSERS_TRUST_REMOTE_KERNELS).ops
ops = get_kernel(_HF_KERNEL_REPO, version=_HF_KERNEL_VERSION, trust_remote_code=DIFFUSERS_TRUST_REMOTE_KERNELS and not DIFFUSERS_DISABLE_REMOTE_CODE).ops

Comment on lines 33 to 37
can_use_cuda_kernels = (
os.getenv("DIFFUSERS_GGUF_CUDA_KERNELS", "false").lower() in ["1", "true", "yes"]
and torch.cuda.is_available()
and torch.cuda.get_device_capability()[0] >= 7
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can be done in a follow up. But I think we can remove/deprecate this flag and use DIFFUSER_TRUST_REMOTE_KERNELS as the standard flag for these kinds of operations.

@sayakpaul
sayakpaul requested a review from DN6 July 28, 2026 06:12
@sayakpaul

Copy link
Copy Markdown
Member Author

@DN6 addressed.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Think we can just raise a warning here and run without the kernel. It's backwards breaking if we raise an error.

@sayakpaul
sayakpaul merged commit 3533886 into main Aug 3, 2026
16 checks passed
@sayakpaul
sayakpaul deleted the user-permission-kernel branch August 3, 2026 15:28
DN6 pushed a commit that referenced this pull request Aug 6, 2026
* download kernels when users request for it.

* address review feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation quantization size/S PR with diff < 50 LOC utils

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants