Skip to content

Commit 19ef9ce

Browse files
committed
feat: add cli ref for each command
1 parent 203bf36 commit 19ef9ce

10 files changed

Lines changed: 444 additions & 24 deletions

docs/source/_toctree.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,22 @@
4545
title: Layers
4646
- local: cli
4747
title: Kernels CLI
48+
title: API Reference
49+
- sections:
4850
- local: cli-init
49-
title: cli init
51+
title: kernels init
52+
- local: cli-upload
53+
title: kernels upload
5054
- local: cli-benchmark
51-
title: cli benchmark
52-
title: API Reference
55+
title: kernels benchmark
56+
- local: cli-check
57+
title: kernels check
58+
- local: cli-versions
59+
title: kernels versions
60+
- local: cli-generate-readme
61+
title: kernels generate-readme
62+
- local: cli-lock
63+
title: kernels lock
64+
- local: cli-download
65+
title: kernels download
66+
title: CLI Reference

docs/source/cli-benchmark.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The command:
1414
`kernels benchmark` requires extra dependencies:
1515

1616
```bash
17-
pip install 'kernels[benchmark]'
17+
uv pip install 'kernels[benchmark]' # or pip install 'kernels[benchmark]'
1818
```
1919

2020
## Example

docs/source/cli-check.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# kernels check
2+
3+
Use `kernels check` to verify that a kernel on the Hub meets compliance requirements.
4+
5+
## What It Checks
6+
7+
- Python ABI compatibility (default: 3.9)
8+
- Operating system compatibility (macOS 15.0+, manylinux_2_28)
9+
10+
## Usage
11+
12+
```bash
13+
kernels check <repo_id> [--revision <rev>] [--macos <version>] [--manylinux <version>] [--python-abi <version>]
14+
```
15+
16+
## Installation
17+
18+
`kernels check` requires an additional dependency:
19+
20+
```bash
21+
uv pip install kernel-abi-check # or pip install kernel-abi-check
22+
```
23+
24+
## Examples
25+
26+
Check a kernel on the Hub:
27+
28+
```bash
29+
kernels check kernels-community/flash-attn3
30+
```
31+
32+
Check a specific revision:
33+
34+
```bash
35+
kernels check kernels-community/flash-attn3 --revision v2
36+
```
37+
38+
Check with custom compatibility requirements:
39+
40+
```bash
41+
kernels check kernels-community/flash-attn3 --python-abi 3.10 --manylinux manylinux_2_31
42+
```
43+
44+
## Example Output
45+
46+
```text
47+
Checking variant: torch210-metal-aarch64-darwin
48+
Dynamic library _example_kernel_metal_2juixjwdznbhy.abi3.so:
49+
🐍 Python ABI 3.9 compatible
50+
🍏 compatible with macOS 15.0
51+
Checking variant: torch29-metal-aarch64-darwin
52+
Dynamic library _example_kernel_metal_vtlnpevkb6uum.abi3.so:
53+
🐍 Python ABI 3.9 compatible
54+
🍏 compatible with macOS 15.0
55+
```
56+
57+
## Options
58+
59+
| Option | Default | Description |
60+
| -------------- | ---------------- | ----------------------------------- |
61+
| `--revision` | `main` | Branch, tag, or commit SHA to check |
62+
| `--macos` | `15.0` | Minimum macOS version to require |
63+
| `--manylinux` | `manylinux_2_28` | Manylinux version to require |
64+
| `--python-abi` | `3.9` | Python ABI version to require |
65+

docs/source/cli-download.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# kernels download
2+
3+
Use `kernels download` to download kernels that have been locked in a project's `kernels.lock` file.
4+
5+
## Usage
6+
7+
```bash
8+
kernels download <project_dir> [--all-variants]
9+
```
10+
11+
## What It Does
12+
13+
- Reads the `kernels.lock` file from the specified project directory
14+
- Downloads each locked kernel at its pinned revision (SHA)
15+
- Installs the appropriate variant for your platform (or all variants with `--all-variants`)
16+
17+
## Examples
18+
19+
Download kernels for the current project:
20+
21+
```bash
22+
kernels download .
23+
```
24+
25+
Download all build variants (useful for CI or multi-platform builds):
26+
27+
```bash
28+
kernels download . --all-variants
29+
```
30+
31+
Download kernels for a specific project:
32+
33+
```bash
34+
kernels download /path/to/my-project
35+
```
36+
37+
## Options
38+
39+
| Option | Description |
40+
| ---------------- | ----------------------------------------------------------------------------------------- |
41+
| `--all-variants` | Download all build variants of each kernel instead of just the current platform's variant |
42+
43+
## Prerequisites
44+
45+
Your project directory must contain a `kernels.lock` file. Generate one using [`kernels lock`](cli-lock.md).
46+
47+
## See Also
48+
49+
- [kernels lock](cli-lock.md) - Generate the lock file
50+
- [kernels versions](cli-versions.md) - View available kernel versions

docs/source/cli-generate-readme.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# kernels generate-readme
2+
3+
Use `kernels generate-readme` to automatically generate documentation snippets for a kernel's public functions.
4+
5+
## Usage
6+
7+
```bash
8+
kernels generate-readme <repo_id> [--revision <rev>]
9+
```
10+
11+
## What It Does
12+
13+
- Downloads the specified kernel from the Hub
14+
- Inspects the kernel's public API
15+
- Generates markdown documentation snippets showing function signatures and usage
16+
17+
## Examples
18+
19+
Generate README snippets for a kernel:
20+
21+
```bash
22+
kernels generate-readme kernels-community/activation > README.md
23+
```
24+
25+
## Example Output
26+
27+
README.md snippet for `kernels-community/activation`:
28+
```md
29+
---
30+
tags:
31+
- kernels
32+
---
33+
34+
## Functions
35+
36+
### Function `fatrelu_and_mul`
37+
38+
`(out: torch.Tensor, x: torch.Tensor, threshold: float = 0.0) -> None`
39+
40+
No documentation available.
41+
42+
### Function `gelu`
43+
44+
`(out: torch.Tensor, x: torch.Tensor) -> None`
45+
46+
No documentation available.
47+
48+
### Function `gelu_and_mul`
49+
50+
`(out: torch.Tensor, x: torch.Tensor) -> None`
51+
52+
No documentation available.
53+
54+
### Function `gelu_fast`
55+
56+
`(out: torch.Tensor, x: torch.Tensor) -> None`
57+
58+
No documentation available.
59+
60+
...
61+
```

docs/source/cli-lock.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# kernels lock
2+
3+
Use `kernels lock` to generate a `kernels.lock` file that pins kernel dependencies to specific revisions.
4+
5+
## Usage
6+
7+
```bash
8+
kernels lock <project_dir>
9+
```
10+
11+
## What It Does
12+
13+
- Reads kernel dependencies from `pyproject.toml` under `[tool.kernels.dependencies]`
14+
- Resolves each kernel to its current revision SHA
15+
- Writes a `kernels.lock` file with pinned versions and variant information
16+
17+
## Examples
18+
19+
Lock kernels in the current project:
20+
21+
```bash
22+
kernels lock .
23+
```
24+
25+
Lock kernels in a specific project:
26+
27+
```bash
28+
kernels lock /path/to/my-project
29+
```
30+
31+
## pyproject.toml Format
32+
33+
Add your kernel dependencies to `pyproject.toml`:
34+
35+
```toml
36+
[tool.kernels.dependencies]
37+
"kernels-community/activation" = 1
38+
```
39+
40+
The version can be:
41+
42+
- A version number (e.g., `1`, `2`)
43+
44+
## kernels.lock Format
45+
46+
The generated lock file contains:
47+
48+
```json
49+
[
50+
{
51+
"repo_id": "kernels-community/activation",
52+
"sha": "ece277f908b9453112722d584fee4b5696f21c49",
53+
"variants": {
54+
"torch210-cu128-x86_64-windows": {
55+
"hash": "sha256-cbf085e1d297d990d9cb074fb5079ff48e9682c729f53a0899a36b5164a6fb45",
56+
"hash_type": "git_lfs_concat"
57+
},
58+
// ...
59+
"torch29-metal-aarch64-darwin": {
60+
"hash": "sha256-9f665b54a53246a7d3627422f8a0d41d7956dc5409043dbd14c4ec0327aea310",
61+
"hash_type": "git_lfs_concat"
62+
}
63+
}
64+
}
65+
]
66+
```
67+
68+
## Workflow
69+
70+
1. Add dependencies to `pyproject.toml`
71+
2. Run `kernels lock .` to generate the lock file
72+
3. Commit both `pyproject.toml` and `kernels.lock`
73+
4. Use `kernels download .` to install locked kernels
74+
75+
## See Also
76+
77+
- [kernels download](cli-download.md) - Download locked kernels
78+
- [kernels versions](cli-versions.md) - View available kernel versions

docs/source/cli-upload.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# kernels upload
2+
3+
Use `kernels upload` to upload built kernels to the Hugging Face Hub.
4+
5+
## Usage
6+
7+
```bash
8+
kernels upload <kernel_dir> --repo-id <repo_id> [--branch <branch>] [--private]
9+
```
10+
11+
## What It Does
12+
13+
- Creates a repository on the Hub if it doesn't exist
14+
- Uploads the kernel build artifacts from the specified directory
15+
- If a build variant already exists in the repo, replaces the existing files
16+
17+
## Examples
18+
19+
Upload a kernel build:
20+
21+
```bash
22+
kernels upload ./build --repo-id my-username/my-kernel
23+
```
24+
25+
Upload to a specific branch:
26+
27+
```bash
28+
kernels upload ./build --repo-id my-username/my-kernel --branch dev
29+
```
30+
31+
Upload as a private repository:
32+
33+
```bash
34+
kernels upload ./build --repo-id my-username/my-kernel --private
35+
```
36+
37+
## Options
38+
39+
| Option | Required | Description |
40+
| ----------- | -------- | ------------------------------------------------------- |
41+
| `--repo-id` | Yes | Repository ID on the Hub (e.g., `username/kernel-name`) |
42+
| `--branch` | No | Upload to a specific branch instead of main |
43+
| `--private` | No | Create the repository as private |
44+
45+
## Prerequisites
46+
47+
You must be authenticated with the Hugging Face Hub:
48+
49+
```bash
50+
huggingface-cli login
51+
```
52+
53+
## Notes
54+
55+
- The `kernel_dir` should contain the build output (typically the `build/` directory from your kernel project)
56+
- If uploading a new variant to an existing repo, only that variant's files are replaced
57+
- Make sure your kernel passes [`kernels check`](cli-check.md) before uploading
58+
59+
## See Also
60+
61+
- [kernels check](cli-check.md) - Verify kernel compliance before uploading
62+
- [kernels init](cli-init.md) - Create a new kernel project

docs/source/cli-versions.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# kernels versions
2+
3+
Use `kernels versions` to list all available versions of a kernel on the Hub.
4+
5+
## Usage
6+
7+
```bash
8+
kernels versions <repo_id>
9+
```
10+
11+
## Examples
12+
13+
List versions of a kernel:
14+
15+
```bash
16+
kernels versions kernels-community/activation
17+
```
18+
19+
## Example Output
20+
21+
```text
22+
Version 1: torch210-cu128-x86_64-windows, torch210-cxx11-cu126-x86_64-linux, torch210-cxx11-cu128-x86_64-linux, torch210-cxx11-cu130-x86_64-linux, torch210-metal-aarch64-darwin ✅, torch27-cxx11-cu118-x86_64-linux, torch27-cxx11-cu126-x86_64-linux, torch27-cxx11-cu128-aarch64-linux, torch27-cxx11-cu128-x86_64-linux, torch28-cxx11-cu126-aarch64-linux, torch28-cxx11-cu126-x86_64-linux, torch28-cxx11-cu128-aarch64-linux, torch28-cxx11-cu128-x86_64-linux, torch28-cxx11-cu129-aarch64-linux, torch28-cxx11-cu129-x86_64-linux, torch29-cxx11-cu126-aarch64-linux, torch29-cxx11-cu126-x86_64-linux, torch29-cxx11-cu128-aarch64-linux, torch29-cxx11-cu128-x86_64-linux, torch29-cxx11-cu130-aarch64-linux, torch29-cxx11-cu130-x86_64-linux, torch29-metal-aarch64-darwin
23+
```
24+
25+
## Use Cases
26+
27+
- Check which versions are available before locking dependencies
28+
- Find the latest version of a kernel
29+
- Identify version SHAs for pinning in `pyproject.toml`
30+
31+
## See Also
32+
33+
- [kernels lock](cli-lock.md) - Lock kernel versions in your project
34+
- [kernels download](cli-download.md) - Download locked kernels

0 commit comments

Comments
 (0)