Hugging Face Kernels 重大更新:新仓库类型与安全增强

原标题:🤗 Kernels: Major Updates
68AI 研判分

Hugging Face 对 Kernels 项目进行重大重构,新增专用仓库类型以标准化自定义内核的分发与消费。此次更新强化了安全机制并优化了 CLI 工具链,旨在为智能体驱动的内核开发奠定基础。

报道正文

本文目录6 个章节

返回文章列表

🤗 Kernels:重大更新

发布于 2026 年 7 月 6 日 在 GitHub 上查看更新 点赞 37

Sayak Paul sayakpaul Daniël de Kok danieldk David Holtz drbh

在我们之前的文章 《从零到 GPU》 中,我们介绍了 🤗 Kernels 项目,该项目旨在标准化自定义 kernel 的打包、分发和使用方式。我们希望这个项目既无摩擦又安全,同时尽可能与 Hub 友好兼容。

在过去几个月里,我们朝着这一目标努力,并在此过程中几乎完全重新设计了该项目。本文将总结我们已经发布的主要更新以及未来的计划。

目录

Kernels – 一种新的仓库类型

我们在 Hub 上引入了一种名为 "kernel" 的新仓库类型。这使我们能够满足具有特定计算需求的用户。例如,用户可以了解给定 kernel 支持哪些加速器、操作系统和后端版本:

Flash Attention 3 Kernel Page

Kernel 页面:kernels-community/flash-attn3

你可以在此浏览 Hub 上所有可用的 kernels:https://huggingface.co/kernels。

Making these kernels first-class citizens of the Hub also benefits the AI ecosystem. Users can now see trends across kernels, models, and the applications that use them. The kernels become more discoverable to users.

Improved security

Kernels run native code with the same privileges as the Python process that loads them, so a malicious kernel can do real harm. Therefore, security has always been of utmost importance to the Kernels project.

This is why we focused early on reproducibility: you should be able to recompile a kernel yourself and verify that it matches the publicly available source. We use Nix to make this possible, since it keeps builds pure through hermetic evaluation of the build recipe and a strongly isolated sandbox. We further improve provenance by embedding the source Git SHA1 into the kernel itself.

In recent months, we have added additional layers of defense: trusted kernel publishers and code signing.

Trusted kernel publishers

With the new repo type, we also introduced “trusted publishers”. Since kernels execute code on a machine with the same privileges as the Python process they are used in, an attacker could compromise machines by uploading a malicious kernel and coaxing you to use that kernel. To help you avoid such malicious kernels, the kernels package will now only load kernels by trusted publishers by default. A trusted publisher is an organization that is trusted by the community to act in good faith.

We still want to support loading kernels from organizations or users that are not trusted publishers, but you have to explicitly opt in using the trust_remote_code argument when loading a kernel from the Hub:

PYTHON
from kernels import get_kernel

kernel_module = get_kernel(  
   “Atlas-Inference/gdn”, version=1, trust_remote_code=True  
)  

By default, users cannot publish kernel repositories on the Hub. They have to request to be a kernel publisher. Users and organizations can request for access from their account settings. This gives us time to treat these requests on a case-by-case basis.

Kernel signing

An additional layer of security that we are adding is code signing. Code signing protects against the scenario where an attacker uploads a malicious kernel to a kernel repo from a trusted publisher whose Hub credentials were compromised. In code signing, a kernel is signed with a private key known only to the kernel developer and validated with a public key that is generally available. In the Hub compromise scenario, an attacker cannot sign the malicious kernel since they do not own the private key needed for signing.

To further improve security, we use Sigstore’s cosign to sign using ephemeral private keys. Since these signing keys are only valid for a limited time, an attacker typically cannot use the private key, even when it is leaked. We also verify that the kernel was signed by a trusted GitHub workflow from a trusted GitHub repository.

Kernel signing is already supported by kernel-builder and we have provided the kernels verify-signature to verify a kernel. Kernels does not verify the signature upon loading a kernel yet, since we would like to test this new functionality more before fully rolling it out. Preliminary notes on setting up code signing for your own kernels can be found in the kernels 0.16.0 release notes: https://github.com/huggingface/kernels/releases/tag/v0.16.0.

Revamped CLIs

Previously, a bunch of utilities were intertwined between kernels and kernel-builder. We have established a better separation of concern between the CLI of kernels and kernel-builder. The mental model here is that kernels is a library for loading and preparing kernels for use. Therefore, it should not include anything related to “building” kernels.

As a result of this, both kernels and kernel-builder are now much leaner and more specific. Refer to the documentation to learn more about this:

This improved CLI experience also lets us cater to the rise of agentic kernel development in a better manner. More on this later.