Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ jobs:
( cd kernels && cargo fmt --all -- --check )
- name: Cargo fmt (kernel-builder)
run: ( cd kernel-builder && cargo fmt --all -- --check )
- name: Cargo fmt (kernels-tool)
run: ( cd kernels-tool && cargo fmt --all -- --check )
- name: Cargo fmt (kernel-tool)
run: ( cd kernel-tool && cargo fmt --all -- --check )
- name: Cargo fmt (kernel-port)
run: ( cd kernel-port && cargo fmt --all -- --check )

Expand Down Expand Up @@ -66,8 +66,8 @@ jobs:
( cd kernels && cargo clippy -- -D warnings )
- name: Clippy (kernel-builder)
run: ( cd kernel-builder && cargo clippy -- -D warnings )
- name: Clippy (kernels-tool)
run: ( cd kernels-tool && cargo clippy -- -D warnings )
- name: Clippy (kernel-tool)
run: ( cd kernel-tool && cargo clippy -- -D warnings )
- name: Clippy (kernel-port)
run: ( cd kernel-port && cargo clippy -- -D warnings )

Expand All @@ -94,7 +94,7 @@ jobs:
run: cargo test -p kernels-common
- name: Test (kernel-builder)
run: cargo test -p hf-kernel-builder
- name: Test (kernels-tool)
run: cargo test -p kernels-tool
- name: Test (kernel-tool)
run: cargo test -p kernel-tool
- name: Test (kernel-port)
run: cargo test -p kernel-port
4 changes: 2 additions & 2 deletions .github/workflows/security-audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ jobs:
* `kernel-builder`: this is the main user interface for building and uploading kernels,
though it also generates CMake/pyproject files which are used by the NIx builder.
* `kernels`: Python package that can download and load kernels from Hugging Face Hub.
* `kernels-common`: data structures shared by `kernel-builder`, `kernels-tool` and `kernels`.
* `kernels-tool`: tools that process and validate built kernels (hashing, zipping,
* `kernels-common`: data structures shared by `kernel-builder`, `kernel-tool` and `kernels`.
* `kernel-tool`: tools that process and validate built kernels (hashing, zipping,
provenance, ABI checks), used by the Nix builder.
* `nix-builder`: Nix code that drives kernel building, also contains Nix derivations for
some dependencies.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- "kernels/rust/**"
- "nix-builder/**"
- "kernels-common/**"
- "kernels-tool/**"
- "kernel-tool/**"
- ".github/workflows/test_e2e.yaml"
workflow_dispatch:
inputs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_kernels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
- "docs/**"
- "*.md"
- "kernel-builder/**"
- "kernels-tool/**"
- "kernel-tool/**"
- "nix-builder/**"
workflow_dispatch:

Expand Down
38 changes: 19 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ members = [
"kernel-builder",
"kernels",
"kernels-common",
"kernels-tool",
"kernel-tool",
"kernel-port",
]
resolver = "2"
Expand Down
4 changes: 2 additions & 2 deletions docs/source/kernel-requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,10 @@ The ABI3 requirement can be checked with the ABI checker (see below).
### ABI checker

The manylinux_2_28 and Python ABI 3.9 version requirements can be checked with
`kernels-tool check-abi`:
`kernel-tool check-abi`:

```bash
$ kernels-tool check-abi examples/kernels/relu
$ kernel-tool check-abi examples/kernels/relu
🐍 Checking for compatibility with manylinux_2_28 and Python ABI version 3.9: /home/daniel/git/kernels/examples/kernels/relu/result/torch211-cpu-x86_64-linux/_relu_cpu_30dc0ae_dirty.abi3.so
✅ No compatibility issues found
🐍 Checking for compatibility with manylinux_2_28 and Python ABI version 3.9: /home/daniel/git/kernels/examples/kernels/relu/result/torch211-cu126-x86_64-linux/_relu_cuda_30dc0ae_dirty.abi3.so
Expand Down
4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
mkShell {
nativeBuildInputs = [
kernel-builder
kernels-tool
kernel-tool
nodejs # For hf-doc-builder.
pinact
pkg-config
Expand Down Expand Up @@ -265,7 +265,7 @@
formatter = pkgs.nixfmt-tree;

packages = rec {
inherit (buildSet.pkgs) kernel-builder kernels-tool kernel-port;
inherit (buildSet.pkgs) kernel-builder kernel-tool kernel-port;
kernels = buildSet.overrideTorch buildSet.pkgs.python3.pkgs.kernels;

update-build = pkgs.writeShellScriptBin "update-build" ''
Expand Down
2 changes: 1 addition & 1 deletion kernel-builder/skills/cuda-kernels/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def my_kernel(x: torch.Tensor) -> torch.Tensor:
4. `kernel-builder check-config` passes — `[general]` needs a **dash-separated** `name` (never underscores) and a `license`, plus `[torch]` (binding sources) and `[kernel.<name>]` sections.
5. The kernel directory is a git repository with all files committed (Nix refuses non-git builds).
6. The build succeeds: `nix run .#build-and-copy -L`.
7. ABI compliance passes: `kernels-tool check-abi` (after building).
7. ABI compliance passes: `kernel-tool check-abi` (after building).

## Quick Start

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ output[idx] = from_float(result, (scalar_t*)nullptr);

### 3. Build Errors Mentioning pybind11 / Py_LIMITED_API / abi3

**Problem:** Errors like `pybind11 does not support the limited API`, undefined `PyCFunction` variants, or `kernels-tool check-abi` failures.
**Problem:** Errors like `pybind11 does not support the limited API`, undefined `PyCFunction` variants, or `kernel-tool check-abi` failures.

**Cause:** The kernel uses a disallowed binding pattern — `#include <torch/extension.h>` (which transitively includes pybind11), `PYBIND11_MODULE`, or a hand-written `setup.py` with `torch.utils.cpp_extension.CUDAExtension`. kernel-builder compiles against the Python limited API (ABI3); pybind11 and setuptools extensions cannot be used.

Expand Down
6 changes: 3 additions & 3 deletions kernels-tool/Cargo.toml → kernel-tool/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "kernels-tool"
name = "kernel-tool"
version = "0.20.0-dev0"
edition = "2021"
description = "Tools to process and validate Hub kernels"
homepage = "https://github.com/huggingface/kernels"
license = "Apache-2.0"
documentation = "https://docs.rs/kernels-tool"
documentation = "https://docs.rs/kernel-tool"
repository = "https://github.com/huggingface/kernels"

[dependencies]
Expand All @@ -26,5 +26,5 @@ zip = { version = "9.7.0", default-features = false, features = ["deflate-flate2
tempfile = "3"

[[bin]]
name = "kernels-tool"
name = "kernel-tool"
path = "src/main.rs"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions nix-builder/lib/build.nix
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ rec {
# Fill card iff we build any variants.
postInstall = lib.optionalString (buildSets != [ ]) ''
if [ -f "${path}/CARD.md" ]; then
${(builtins.head buildSets).pkgs.kernels-tool}/bin/kernels-tool fill-card ${path} $out/CARD.md
${(builtins.head buildSets).pkgs.kernel-tool}/bin/kernel-tool fill-card ${path} $out/CARD.md
fi
'';
};
Expand Down Expand Up @@ -627,7 +627,7 @@ rec {
with pkgs;
[
kernel-builder
kernels-tool
kernel-tool
]
++ (pythonNativeCheckInputs buildSet.python3.pkgs);
buildInputs = [ python ];
Expand Down
2 changes: 1 addition & 1 deletion nix-builder/lib/cache.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
allOutputs buildSet.torch
++ lib.concatMap allOutputs buildSet.extension.extraBuildDeps
++ allOutputs kernel-builder
++ allOutputs kernels-tool
++ allOutputs kernel-tool
++ allOutputs kernel-port
++ allOutputs (overrideTorch python3.pkgs.einops)
++ allOutputs buildSet.python3.pkgs.jax
Expand Down
4 changes: 2 additions & 2 deletions nix-builder/lib/extension/mlx/no-arch.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
generate-symbols-hook,
get-kernel-check,
hash-kernel-hook,
kernels-tool,
kernel-tool,
kernel-layout-check,
python3,
remove-bytecode-hook,
Expand Down Expand Up @@ -110,7 +110,7 @@ stdenv.mkDerivation (prevAttrs: {
buildPython
zip-build-hook
hash-kernel-hook
kernels-tool
kernel-tool
kernel-layout-check
remove-bytecode-hook
]
Expand Down
4 changes: 2 additions & 2 deletions nix-builder/lib/extension/torch/arch.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
writeText,

# Native build inputs
kernels-tool,
kernel-tool,
cmake,
cmakeNvccThreadsHook,
hipccThreadsHook,
Expand Down Expand Up @@ -191,7 +191,7 @@ stdenv.mkDerivation (prevAttrs: {
zip-build-hook
hash-kernel-hook
ninja
kernels-tool
kernel-tool
kernel-layout-check
remove-bytecode-hook
torch-ops-check
Expand Down
4 changes: 2 additions & 2 deletions nix-builder/lib/extension/torch/no-arch.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
pkgs,
stdenv,

kernels-tool,
kernel-tool,
generate-symbols-hook,
get-kernel-check,
hash-kernel-hook,
Expand Down Expand Up @@ -119,7 +119,7 @@ stdenv.mkDerivation (prevAttrs: {
nativeBuildInputs = [
zip-build-hook
hash-kernel-hook
kernels-tool
kernel-tool
kernel-layout-check
remove-bytecode-hook
torch-ops-check
Expand Down
4 changes: 2 additions & 2 deletions nix-builder/lib/extension/tvm-ffi/arch.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
writeText,

# Native build inputs
kernels-tool,
kernel-tool,
cargo,
cmake,
cmakeNvccThreadsHook,
Expand Down Expand Up @@ -247,7 +247,7 @@ stdenv.mkDerivation (
zip-build-hook
hash-kernel-hook
ninja
kernels-tool
kernel-tool
kernel-layout-check
remove-bytecode-hook
torch-ops-check
Expand Down
2 changes: 1 addition & 1 deletion nix-builder/lib/flake-outputs/gen-sdk-flake-outputs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ let
# Order matters: remove bytecode, then hash.
pkgs.remove-bytecode-hook
pkgs.hash-kernel-hook
pkgs.kernels-tool
pkgs.kernel-tool
(pkgs.get-kernel-check.override {
python3 = loadCheckPython;
inherit kernels;
Expand Down
2 changes: 1 addition & 1 deletion nix-builder/overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ final: prev:
# Local packages/hooks.
kernel-builder = final.callPackage ./pkgs/kernel-builder { };

kernels-tool = final.callPackage ./pkgs/kernels-tool { };
kernel-tool = final.callPackage ./pkgs/kernel-tool { };

kernel-port = final.callPackage ./pkgs/kernel-port { };

Expand Down
4 changes: 2 additions & 2 deletions nix-builder/pkgs/hash-kernel-hook/default.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{ makeSetupHook, kernels-tool }:
{ makeSetupHook, kernel-tool }:

makeSetupHook {
name = "hash-kernel-hook";
substitutions = {
kernels_tool = kernels-tool;
kernel_tool = kernel-tool;
};
} ./hash-kernel-hook.sh
2 changes: 1 addition & 1 deletion nix-builder/pkgs/hash-kernel-hook/hash-kernel-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ echo "Sourcing hash-kernel-hook.sh"

hashKernelHook() {
echo "Writing kernel hashes to metadata"
@kernels_tool@/bin/kernels-tool hash $out/
@kernel_tool@/bin/kernel-tool hash $out/
}

if [ -z "${dontHashKernel-}" ]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ echo "Sourcing add-provenance-hook.sh"
addProvenanceHook() {
echo "Writing provenance to metadata"

kernels-tool add-provenance "${provenance}" "$out/"
kernel-tool add-provenance "${provenance}" "$out/"
}

if [ -n "${provenance:-}" ]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ _checkAbiHook() {
args+=("--torch-stable-abi=${torchStableAbiVersion}")
fi

kernels-tool check-abi ${args[@]+"${args[@]}"} "$out/"
kernel-tool check-abi ${args[@]+"${args[@]}"} "$out/"
fi
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ _checkKernelBuildHook() {
echo "Skipping kernel build check"
else
echo "Checking kernel build"
kernels-tool check-builds "$out/"
kernel-tool check-builds "$out/"
fi
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
}:

let
version = (builtins.fromTOML (builtins.readFile ../../../kernels-tool/Cargo.toml)).package.version;
version = (builtins.fromTOML (builtins.readFile ../../../kernel-tool/Cargo.toml)).package.version;
cargoFlags = [
"-p"
"kernels-tool"
"kernel-tool"
];
in
rustPlatform.buildRustPackage {
inherit version;
pname = "kernels-tool";
pname = "kernel-tool";

src = mkKernelsRustSrc {
crates = [ "kernels-tool" ];
crates = [ "kernel-tool" ];
};

cargoDeps = kernelsCargoDeps;
Expand Down
4 changes: 2 additions & 2 deletions nix-builder/pkgs/zip-build-hook/default.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{ makeSetupHook, kernels-tool }:
{ makeSetupHook, kernel-tool }:

makeSetupHook {
name = "zip-build-hook";
substitutions = {
kernels_tool = kernels-tool;
kernel_tool = kernel-tool;
};
} ./zip-build-hook.sh
2 changes: 1 addition & 1 deletion nix-builder/pkgs/zip-build-hook/zip-build-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ zipBuildHook() {
# `buildLayout` is `files` (the default) or `zip`.
if [ "${buildLayout-files}" = "zip" ]; then
echo "Zipping builds with the ZIP build layout"
@kernels_tool@/bin/kernels-tool zip-build $out/
@kernel_tool@/bin/kernel-tool zip-build $out/
fi
}

Expand Down
Loading
Loading