Skip to content
Open
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
5 changes: 5 additions & 0 deletions docs/source/builder/writing-kernels.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ The following sections enumerate all supported options for `build.toml`.
branch named `v<version>`.
- `backends` (required): a list of supported backends. Must be one or
more of `cpu`, `cuda`, `metal`, `rocm`, or `xpu`.
- `upstream`: URL of the original upstream repository where the kernel
source code comes from.
- `source`: URL of the kernel-builder formatted source repository. This
repository must contain a `build.toml` and `flake.nix` so that it can be
pulled and built with the kernel builder.
Comment on lines +193 to +197
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In both cases, I think we should say something about the format. Should this be a URL that can be passed directly to git? What about Git over SSH?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now saw GitUrl below, so I think good to mention here that these should be Git-compatible (passable to git clone).

- `python-depends` (**experimental**): a list of additional Python dependencies
that the kernel requires. The only supported dependencies are `einops`
and `nvidia-cutlass-dsl`.
Expand Down
4 changes: 4 additions & 0 deletions docs/source/kernel-requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ metadata. Currently the following top-level keys are supported:
- `version` (`int`, required): the kernel version number.
- `license` (`str`, required): the kernel license in. Refer to the
list of [supported license identifiers](https://huggingface.co/docs/hub/repositories-licenses).
- `upstream` (`str`, optional): URL of the original upstream repository
where the kernel source code comes from.
- `source` (`str`, optional): URL of the kernel-builder formatted source
repository (must contain `build.toml` and `flake.nix`).
Comment on lines +74 to +77
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above.

- `backend` (`dict`, required): information about the compute backend that
this build variant supports.
- `python-depends` (`list[str]`, optional): list of Python dependencies
Expand Down
10 changes: 8 additions & 2 deletions examples/kernels/cutlass-gemm-tvm-ffi/CARD.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@ No benchmark available yet.
{% endif %}
{% if upstream %}

## Source code
## Upstream

Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`.
The original source code for this kernel comes from {{ upstream }}.
{% endif %}
{% if source %}

## Source

The kernel-builder formatted source for this kernel is available at {{ source }}.
{% endif %}

10 changes: 8 additions & 2 deletions examples/kernels/cutlass-gemm/CARD.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@ No benchmark available yet.
{% endif %}
{% if upstream %}

## Source code
## Upstream

Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`.
The original source code for this kernel comes from {{ upstream }}.
{% endif %}
{% if source %}

## Source

The kernel-builder formatted source for this kernel is available at {{ source }}.
{% endif %}

10 changes: 8 additions & 2 deletions examples/kernels/extra-data/CARD.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@ No benchmark available yet.
{% endif %}
{% if upstream %}

## Source code
## Upstream

Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`.
The original source code for this kernel comes from {{ upstream }}.
{% endif %}
{% if source %}

## Source

The kernel-builder formatted source for this kernel is available at {{ source }}.
{% endif %}

10 changes: 8 additions & 2 deletions examples/kernels/relu-backprop-compile/CARD.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@ No benchmark available yet.
{% endif %}
{% if upstream %}

## Source code
## Upstream

Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`.
The original source code for this kernel comes from {{ upstream }}.
{% endif %}
{% if source %}

## Source

The kernel-builder formatted source for this kernel is available at {{ source }}.
{% endif %}

10 changes: 8 additions & 2 deletions examples/kernels/relu-compiler-flags/CARD.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@ No benchmark available yet.
{% endif %}
{% if upstream %}

## Source code
## Upstream

Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`.
The original source code for this kernel comes from {{ upstream }}.
{% endif %}
{% if source %}

## Source

The kernel-builder formatted source for this kernel is available at {{ source }}.
{% endif %}

10 changes: 8 additions & 2 deletions examples/kernels/relu-metal-cpp/CARD.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@ No benchmark available yet.
{% endif %}
{% if upstream %}

## Source code
## Upstream

Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`.
The original source code for this kernel comes from {{ upstream }}.
{% endif %}
{% if source %}

## Source

The kernel-builder formatted source for this kernel is available at {{ source }}.
{% endif %}

10 changes: 8 additions & 2 deletions examples/kernels/relu-nki/CARD.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@ No benchmark available yet.
{% endif %}
{% if upstream %}

## Source code
## Upstream

Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`.
The original source code for this kernel comes from {{ upstream }}.
{% endif %}
{% if source %}

## Source

The kernel-builder formatted source for this kernel is available at {{ source }}.
{% endif %}

10 changes: 8 additions & 2 deletions examples/kernels/relu-specific-torch/CARD.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@ No benchmark available yet.
{% endif %}
{% if upstream %}

## Source code
## Upstream

Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`.
The original source code for this kernel comes from {{ upstream }}.
{% endif %}
{% if source %}

## Source

The kernel-builder formatted source for this kernel is available at {{ source }}.
{% endif %}

10 changes: 8 additions & 2 deletions examples/kernels/relu-torch-bounds/CARD.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@ No benchmark available yet.
{% endif %}
{% if upstream %}

## Source code
## Upstream

Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`.
The original source code for this kernel comes from {{ upstream }}.
{% endif %}
{% if source %}

## Source

The kernel-builder formatted source for this kernel is available at {{ source }}.
{% endif %}

10 changes: 8 additions & 2 deletions examples/kernels/relu-tvm-ffi/CARD.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@ No benchmark available yet.
{% endif %}
{% if upstream %}

## Source code
## Upstream

Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`.
The original source code for this kernel comes from {{ upstream }}.
{% endif %}
{% if source %}

## Source

The kernel-builder formatted source for this kernel is available at {{ source }}.
{% endif %}

9 changes: 7 additions & 2 deletions examples/kernels/relu/CARD.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ No benchmark available yet.
{% endif %}
{% if upstream %}

## Source code
## Upstream

Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`.
The original source code for this kernel comes from {{ upstream }}.
{% endif %}
{% if source %}

## Source

The kernel-builder formatted source for this kernel is available at {{ source }}.
{% endif %}
10 changes: 8 additions & 2 deletions examples/kernels/silu-and-mul-bad-registration/CARD.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@ No benchmark available yet.
{% endif %}
{% if upstream %}

## Source code
## Upstream

Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`.
The original source code for this kernel comes from {{ upstream }}.
{% endif %}
{% if source %}

## Source

The kernel-builder formatted source for this kernel is available at {{ source }}.
{% endif %}

10 changes: 8 additions & 2 deletions examples/kernels/silu-and-mul/CARD.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@ No benchmark available yet.
{% endif %}
{% if upstream %}

## Source code
## Upstream

Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`.
The original source code for this kernel comes from {{ upstream }}.
{% endif %}
{% if source %}

## Source

The kernel-builder formatted source for this kernel is available at {{ source }}.
{% endif %}

3 changes: 2 additions & 1 deletion kernel-builder/src/card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ fn render_card(build: &Build, kernel_dir: &Path) -> Result<String> {
functions => functions,
layers => layers,
has_benchmark => has_benchmark,
upstream => build.general.upstream.as_ref().map(|u| u.to_string()),
upstream => build.general.upstream.as_ref().map(|u| u.as_url().to_string()),
source => build.general.source.as_ref().map(|u| u.as_url().to_string()),
license => build.general.license.to_lowercase(),
})
.wrap_err("Cannot render card template")
Expand Down
10 changes: 8 additions & 2 deletions kernel-builder/src/init/templates/CARD.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@ No benchmark available yet.
{% endif %}
{% if upstream %}

## Source code
## Upstream

Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`.
The original source code for this kernel comes from {{ upstream }}.
{% endif %}
{% if source %}

## Source

The kernel-builder formatted source for this kernel is available at {{ source }}.
{% endif %}
{% endraw %}
1 change: 1 addition & 0 deletions kernel-builder/src/pyproject/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pub fn write_metadata(
version: general.version,
license: general.license.clone(),
upstream: general.upstream.clone(),
source: general.source.clone(),
python_depends,
backend: BackendInfo {
archs: None,
Expand Down
2 changes: 2 additions & 0 deletions kernels-data/bindings/python/kernels_data.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ class Metadata:
@property
def upstream(self) -> Optional[str]: ...
@property
def source(self) -> Optional[str]: ...
@property
def python_depends(self) -> list[str]: ...
@property
def backend(self) -> BackendInfo: ...
Expand Down
12 changes: 10 additions & 2 deletions kernels-data/bindings/python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ struct PyMetadata {
version: usize,
license: String,
upstream: Option<String>,
source: Option<String>,
python_depends: Vec<String>,
backend: PyBackendInfo,
}
Expand All @@ -206,7 +207,8 @@ impl From<Metadata> for PyMetadata {
name: PyKernelName { inner: m.name },
version: m.version,
license: m.license,
upstream: m.upstream.map(|u| u.to_string()),
upstream: m.upstream.map(|u| u.as_url().to_string()),
source: m.source.map(|u| u.as_url().to_string()),
python_depends: m.python_depends,
backend: m.backend.into(),
}
Expand Down Expand Up @@ -257,6 +259,11 @@ impl PyMetadata {
self.upstream.as_deref()
}

#[getter]
fn source(&self) -> Option<&str> {
self.source.as_deref()
}

#[getter]
fn python_depends(&self) -> &[String] {
&self.python_depends
Expand All @@ -269,12 +276,13 @@ impl PyMetadata {

fn __repr__(&self) -> String {
format!(
"Metadata(id={}, name={:?}, version={:?}, license={:?}, upstream={:?}, python_depends={:?}, backend={})",
"Metadata(id={}, name={:?}, version={:?}, license={:?}, upstream={:?}, source={:?}, python_depends={:?}, backend={})",
self.id,
self.name,
self.version,
self.license,
self.upstream,
self.source,
self.python_depends,
self.backend.__repr__()
)
Expand Down
3 changes: 3 additions & 0 deletions kernels-data/bindings/python/tests/test_kernels_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def test_metadata_load_full(tmp_path):
"name": "my-kernel",
"license": "Apache-2.0",
"upstream": "https://github.com/example/kernel",
"source": "https://github.com/example/kernel-builder",
"python-depends": ["torch"],
"backend": {"type": "cuda", "archs": ["9.0", "10.0"]},
}
Expand All @@ -106,6 +107,7 @@ def test_metadata_load_full(tmp_path):
assert m.version == 1
assert m.license == "Apache-2.0"
assert m.upstream == "https://github.com/example/kernel"
assert m.source == "https://github.com/example/kernel-builder"
assert m.python_depends == ["torch"]
assert m.backend.backend_type == Backend.CUDA
assert m.backend.archs == ["9.0", "10.0"]
Expand All @@ -129,6 +131,7 @@ def test_metadata_load_minimal(tmp_path):
assert m.version == 1
assert m.license == "Apache-2.0"
assert m.upstream is None
assert m.source is None
assert m.python_depends == []
assert m.backend.backend_type == Backend.CPU

Expand Down
Loading
Loading