Buckets:

rtrm's picture
|
download
raw
2.48 kB

Kernels CLI Reference

The kernels CLI provides commands for managing compute kernels.

Commands

Command Description
init Initialize a new kernel project from template
upload Upload kernels to the Hub
benchmark Run benchmark results for a kernel
check Check a kernel for compliance
versions Show kernel versions
generate-readme Generate README snippets for a kernel's public functions
lock Lock kernel revisions
download Download locked kernels
create-and-upload-card Create and upload a model card for a kernel
skills Add skills for AI coding assistants

Quick Start

Create a new kernel project

kernels init my-username/my-kernel
cd my-kernel

Build and test locally

cachix use huggingface
nix run -L --max-jobs 1 --cores 8 .#build-and-copy
uv run example.py

Upload to the Hub

kernels upload ./build --repo-id my-username/my-kernel

Use kernels in your project

Directly from the Hub

import torch

from kernels import get_kernel

# Download optimized kernels from the Hugging Face hub
my_kernel = get_kernel("my-username/my-kernel", version=1)

# Random tensor
x = torch.randn((10, 10), dtype=torch.float16, device="cuda")

# Run the kernel
y = torch.empty_like(x)
my_kernel.my_kernel_function(y, x)

print(y)

or

Locked and downloaded

Add to pyproject.toml:

[tool.kernels.dependencies]
"my-username/my-kernel" = "1"

Then lock and download:

kernels lock .
kernels download .

See help

kernels --help

Xet Storage Details

Size:
2.48 kB
·
Xet hash:
9bb64cbfcc8f5894b6703bb24afadaa80b317f0277b2b4820618c7f35e16c1bc

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.