apache / apache/tvm-ffi

Support in Hugging Face kernels

Open
#595 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C++
Stars
462
Forks
99
Avg merge
8h 37m
Merged PRs (30d)
73

Description

Hi 👋. I am one of the core team members of the Hugging Face Kernels project: https://huggingface.co/docs/kernels/ The goal of the kernels project is to make it easy for kernel developers to write and distribute kernels and for kernel users to use kernels in their favorite models. The project consists of several parts:

* `kernel-builder`: builds kernels for multiple systems (OS + arch), backends (CUDA, XPU, ROCm, Metal and multiple versions of each), and framework versions (e.g. multiple Torch versions).
* Kernel Hub: which can be used for distribution of kernels. There are quite some kernels already available from us and from third-parties: https://huggingface.co/kernels
* The `kernels` Python client. Using the Python client, users can download and load kernels using simply:

```
import kernels
fa3 = kernels.get_kernel("kernels-community/flash-attn3", version=1)
```

`kernels` will take care of download and loading the right variant for a user's system.

So far, we have focused primarily on Torch support, but I think TVM FFI fits in well with our goal of making it easy to build and load kernels, especially because it would make Hub kernels available for frameworks beyond Torch. A while ago, we implemented initial support for building and loading TVM FFI kernels. There is a minimal example at: https://github.com/huggingface/kernels/tree/main/examples/kernels/relu-tvm-ffi , with the built kernel at: https://huggingface.co/kernels/kernels-test/relu-tvm-ffi

We would love to collaborate more if you are interested - we have a bunch of questions around encoding ABI versions, etc. If you are interested, we could set up a shared Slack channel or otherwise communicate through this issue.

Contributor guide

Open the contributing guide

Research direction

Start by reading the linked Hugging Face Kernels documentation and the minimal example in examples/kernels/relu-tvm-ffi, then inspect the built relu-tvm-ffi kernel. The issue does not define a specific change; first establish the desired TVM FFI integration and ABI-versioning requirements with the project teams before implementation. Done would require an agreed support scope and corresponding changes and validation.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, huggingface, python
Domain
backend-api-design, machine-learning
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.