Compare commits

..

1 Commits

Author SHA1 Message Date
d8fefaeef5 Set version to 0.10.4 2025-10-16 20:22:17 +02:00
6 changed files with 24 additions and 42 deletions

View File

@ -51,7 +51,7 @@ activation.gelu_fast(y, x)
print(y)
```
You can [search for kernels](https://huggingface.co/models?other=kernels) on
You can [search for kernels](https://huggingface.co/models?other=kernel) on
the Hub.
## 📚 Documentation

View File

@ -16,5 +16,5 @@ packages in that they are made to be:
the different PyTorch build configurations (various CUDA versions
and C++ ABIs). Furthermore, older C library versions must be supported.
You can [search for kernels](https://huggingface.co/models?other=kernels) on
You can [search for kernels](https://huggingface.co/models?other=kernel) on
the Hub.

View File

@ -1,6 +1,6 @@
[project]
name = "kernels"
version = "0.10.4.dev0"
version = "0.10.4"
description = "Download compute kernels"
authors = [
{ name = "OlivierDehaene", email = "olivier@huggingface.co" },

View File

@ -1,7 +1,6 @@
import argparse
import dataclasses
import json
import re
import sys
from pathlib import Path
@ -14,8 +13,6 @@ from kernels.utils import install_kernel, install_kernel_all_variants
from .doc import generate_readme_for_kernel
from .wheel import build_variant_to_wheel
BUILD_VARIANT_REGEX = re.compile(r"^(torch\d+\d+|torch-universal)")
def main():
parser = argparse.ArgumentParser(
@ -68,14 +65,14 @@ def main():
help="Directory of the kernel build",
)
upload_parser.add_argument(
"--repo-id",
"--repo_id",
type=str,
help="Repository ID to use to upload to the Hugging Face Hub",
)
upload_parser.add_argument(
"--branch",
type=None,
help="If set, the upload will be made to a particular branch of the provided `repo-id`.",
help="If set, the upload will be made to a particular branch of the provided `repo_id`.",
)
upload_parser.add_argument(
"--private",
@ -209,21 +206,11 @@ def lock_kernels(args):
def upload_kernels(args):
# Resolve `kernel_dir` to be uploaded.
kernel_dir = Path(args.kernel_dir).resolve()
build_dir = None
for candidate in [kernel_dir / "build", kernel_dir]:
variants = [
variant_path
for variant_path in candidate.glob("torch*")
if BUILD_VARIANT_REGEX.match(variant_path.name) is not None
]
if variants:
build_dir = candidate
break
if build_dir is None:
raise ValueError(
f"Couldn't find any build variants in: {kernel_dir.absolute()} or {(kernel_dir / 'build').absolute()}"
)
build_dir = kernel_dir / "build"
if not kernel_dir.is_dir():
raise ValueError(f"{kernel_dir} is not a directory")
if not build_dir.is_dir():
raise ValueError("Couldn't find `build` directory inside `kernel_dir`")
repo_id = create_repo(
repo_id=args.repo_id, private=args.private, exist_ok=True

View File

@ -111,10 +111,10 @@ def generate_readme_for_kernel(repo_id: str, *, revision: str = "main") -> None:
def generate_metadata(module: ModuleType) -> None:
metadata = getattr(module, "__kernel_metadata__", {})
if "tags" not in metadata:
metadata["tags"] = ["kernels"]
metadata["tags"] = ["kernel"]
else:
if "kernels" not in metadata["tags"]:
metadata["tags"].append("kernels")
if "kernel" not in metadata["tags"]:
metadata["tags"].append("kernel")
print("---")
print(yaml.dump(metadata), end="")

View File

@ -65,7 +65,9 @@ def build_variant() -> str:
cann_major, cann_minor = get_cann_version()[0], get_cann_version()[2]
compute_framework = f"cann{cann_major}{cann_minor}"
else:
compute_framework = "cpu"
raise AssertionError(
"Torch was not compiled with CUDA, Metal, XPU, NPU, or ROCm enabled."
)
torch_version = parse(torch.__version__)
cpu = platform.machine()
@ -74,11 +76,9 @@ def build_variant() -> str:
if os == "darwin":
cpu = "aarch64" if cpu == "arm64" else cpu
return f"torch{torch_version.major}{torch_version.minor}-{compute_framework}-{cpu}-{os}"
elif os == "windows":
cpu = "x86_64" if cpu == "AMD64" else cpu
return f"torch{torch_version.major}{torch_version.minor}-{compute_framework}-{cpu}-{os}"
cxxabi = "cxx11" if torch.compiled_with_cxx11_abi() else "cxx98"
return f"torch{torch_version.major}{torch_version.minor}-{cxxabi}-{compute_framework}-{cpu}-{os}"
@ -528,16 +528,11 @@ def _get_user_agent(
return None
if user_agent is None:
user_agent = {}
if isinstance(user_agent, dict):
user_agent.update(
{
"kernels": __version__,
"torch": torch.__version__,
"build_variant": build_variant(),
"file_type": "kernel",
}
)
elif isinstance(user_agent, str):
user_agent += f"; kernels/{__version__}; torch/{torch.__version__}; build_variant/{build_variant()}; file_type/kernel"
user_agent = {
"kernels": __version__,
"torch": torch.__version__,
"build_variant": build_variant(),
"file_type": "kernel",
}
return user_agent