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
13 changes: 4 additions & 9 deletions .github/workflows/build_kernel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,16 @@ jobs:
USER: runner
- name: Nix info
run: nix-shell -p nix-info --run "nix-info -m"
- name: Build activation kernel
run: ( cd examples/activation && nix build .\#redistributable.torch29-cxx11-cu126-x86_64-linux )
- name: Copy activation kernel
run: cp -rL examples/activation/result activation-kernel
- name: Build relu kernel
run: ( cd examples/relu && nix build .\#redistributable.torch29-cxx11-cu126-x86_64-linux )
- name: Copy relu kernel
run: cp -rL examples/relu/result relu-kernel

- name: Build cutlass GEMM kernel
run: ( cd examples/cutlass-gemm && nix build .\#redistributable.torch29-cxx11-cu126-x86_64-linux )
- name: Copy cutlass GEMM kernel
run: cp -rL examples/cutlass-gemm/result cutlass-gemm-kernel

- name: Build relu kernel
run: ( cd examples/relu && nix build .\#redistributable.torch29-cxx11-cu126-x86_64-linux )
- name: Copy relu kernel
run: cp -rL examples/relu/result relu-kernel

- name: Build relu-backprop-compile kernel
run: ( cd examples/relu-backprop-compile && nix build .\#redistributable.torch29-cxx11-cu126-x86_64-linux )
- name: Copy relu-backprop-compile kernel
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ nix run nixpkgs#cachix -- use huggingface
Then quick start a build with:

```bash
cd examples/activation
cd examples/relu
nix run .#build-and-copy \
--max-jobs 2 \
--cores 8 \
Expand All @@ -51,7 +51,7 @@ We also provide Docker containers for CI builds. For a quick build:

```bash
# Using the prebuilt container
cd examples/activation
cd examples/relu
docker run --rm \
--mount type=bind,source=$(pwd),target=/kernelcode \
-w /kernelcode ghcr.io/huggingface/kernel-builder:main build
Expand Down
14 changes: 7 additions & 7 deletions docs/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ installed.
We provide a Docker image with which you can build a kernel:

```bash
# navigate to the activation directory
cd examples/activation
# navigate to the relu directory
cd examples/relu

# then run the following command to build the kernel
docker run --rm \
Expand All @@ -39,7 +39,7 @@ docker run --rm \
```

This will build the kernel and save the output in the `build` directory in
the activation folder.
the relu folder.

## CLI Interface

Expand All @@ -55,10 +55,10 @@ The kernel builder includes a command-line interface for easier interaction. The
### Examples

```bash
# Build the example activation kernel from the root of the repository
# Build the example relu kernel from the root of the repository
docker run --rm \
-v $(pwd):/kernel-builder \
-w /kernel-builder/examples/activation \
-w /kernel-builder/examples/relu \
ghcr.io/huggingface/kernel-builder:main \
build

Expand Down Expand Up @@ -194,11 +194,11 @@ The kernel can then be imported as a Python module:
```python
import torch

import activation
import relu

x = torch.randn(10, 10)
out = torch.empty_like(x)
activation.silu_and_mul(out, x)
relu.relu(x, out)

print(out)
```
Expand Down
15 changes: 2 additions & 13 deletions docs/nix.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ A kernel that has a `flake.nix` file can be built with the `build-and-copy`
command. For example:

```bash
cd examples/activation
cd examples/relu
nix run .#build-and-copy -L
```

Expand Down Expand Up @@ -94,7 +94,7 @@ with the kernel in Python's search path. This makes it more convenient to run
tests:

```bash
cd examples/activation
cd examples/relu
nix develop -L .#test
python -m pytest tests
```
Expand Down Expand Up @@ -142,14 +142,3 @@ this check enabled, as it is one of the checks that validates that a kernel
is compliant. This option is primarily intended for kernels with
`triton.autotune` decorators, which can fail because there is no GPU available
in the build sandbox.

## Building a kernel without `flake.nix`

If a kernels source directory does not have a `flake.nix` file, you can build the
kernel using the `buildTorchExtensionBundle` function from the kernel builder
itself:

```bash
cd examples/activation
nix build --impure --expr 'with import ../..; lib.x86_64-linux.buildTorchExtensionBundle ./.' -L
```
2 changes: 1 addition & 1 deletion docs/writing-kernels.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ src = [
"torch-ext/torch_binding.h"
]

[kernel.activation]
[kernel.relu]
backend = "cuda"
src = [
"relu_kernel/relu.cu",
Expand Down
201 changes: 0 additions & 201 deletions examples/activation/LICENSE

This file was deleted.

5 changes: 0 additions & 5 deletions examples/activation/README.md

This file was deleted.

Loading
Loading