From b18fa08b6756bd7224af1193e685eb5f5f68f81d Mon Sep 17 00:00:00 2001 From: drbh Date: Thu, 16 Apr 2026 11:17:18 -0400 Subject: [PATCH 1/3] feat: remove backward compatibility that will not be supported after next release --- kernels/src/kernels/_versions.py | 73 ++--- kernels/src/kernels/cli/__init__.py | 52 ---- kernels/src/kernels/cli/upload.py | 147 ---------- kernels/src/kernels/layer/func.py | 7 +- kernels/src/kernels/layer/layer.py | 7 +- kernels/src/kernels/lockfile.py | 7 +- kernels/src/kernels/utils.py | 20 +- kernels/tests/kernel_locking_old/kernels.lock | 158 ---------- .../tests/kernel_locking_old/pyproject.toml | 3 - kernels/tests/layer_locking/kernels.lock | 14 +- kernels/tests/layer_locking/pyproject.toml | 2 +- kernels/tests/layer_locking_old/kernels.lock | 12 - .../tests/layer_locking_old/pyproject.toml | 2 - kernels/tests/test_kernel_locking.py | 114 +------- kernels/tests/test_kernel_upload.py | 272 ------------------ tests/kernel_locking_old/kernels.lock | 158 ---------- tests/kernel_locking_old/pyproject.toml | 3 - tests/layer_locking_old/kernels.lock | 12 - tests/layer_locking_old/pyproject.toml | 2 - 19 files changed, 41 insertions(+), 1024 deletions(-) delete mode 100644 kernels/src/kernels/cli/upload.py delete mode 100644 kernels/tests/kernel_locking_old/kernels.lock delete mode 100644 kernels/tests/kernel_locking_old/pyproject.toml delete mode 100644 kernels/tests/layer_locking_old/kernels.lock delete mode 100644 kernels/tests/layer_locking_old/pyproject.toml delete mode 100644 kernels/tests/test_kernel_upload.py delete mode 100644 tests/kernel_locking_old/kernels.lock delete mode 100644 tests/kernel_locking_old/pyproject.toml delete mode 100644 tests/layer_locking_old/kernels.lock delete mode 100644 tests/layer_locking_old/pyproject.toml diff --git a/kernels/src/kernels/_versions.py b/kernels/src/kernels/_versions.py index 52a05f678..ed7cabb83 100644 --- a/kernels/src/kernels/_versions.py +++ b/kernels/src/kernels/_versions.py @@ -2,8 +2,6 @@ import warnings from huggingface_hub.hf_api import GitRefInfo -from packaging.specifiers import SpecifierSet -from packaging.version import InvalidVersion, Version logger = logging.getLogger(__name__) @@ -26,72 +24,35 @@ def _get_available_versions(repo_id: str) -> dict[int, GitRefInfo]: return versions -def _get_available_versions_old(repo_id: str) -> dict[Version, GitRefInfo]: +def resolve_version_spec_as_ref(repo_id: str, version_spec: int) -> GitRefInfo: """ - Get kernel versions that are available in the repository. - - This is for the old tag-based versioning scheme. - """ - from kernels.utils import _get_hf_api - - versions = {} - for tag in _get_hf_api().list_repo_refs(repo_id, repo_type="kernel").tags: - if not tag.name.startswith("v"): - continue - try: - versions[Version(tag.name[1:])] = tag - except InvalidVersion: - continue - - return versions - - -def resolve_version_spec_as_ref(repo_id: str, version_spec: int | str) -> GitRefInfo: + Get the ref for a kernel with the given version. """ - Get the ref for a kernel with the given version spec. + versions = _get_available_versions(repo_id) - The version specifier can be any valid Python version specifier: - https://packaging.python.org/en/latest/specifications/version-specifiers/#version-specifiers - """ - if isinstance(version_spec, int): - versions = _get_available_versions(repo_id) - - ref = versions.get(version_spec, None) - if ref is None: - raise ValueError( - f"Version {version_spec} not found, available versions: {', '.join(sorted(str(v) for v in versions.keys()))}" - ) - - latest_version = max(versions.keys()) - if version_spec < latest_version: - logger.warning( - "You are using version %d of '%s', but version %d is available.", - version_spec, - repo_id, - latest_version, - ) - - return ref - else: - warnings.warn( - """Version specifiers are deprecated, support will be removed in a future `kernels` version. - For more information on migrating to versions, see: https://huggingface.co/docs/kernels/migration""" + ref = versions.get(version_spec, None) + if ref is None: + raise ValueError( + f"Version {version_spec} not found, available versions: {', '.join(sorted(str(v) for v in versions.keys()))}" ) - versions_old = _get_available_versions_old(repo_id) - requirement = SpecifierSet(version_spec) - accepted_versions = sorted(requirement.filter(versions_old.keys())) - if len(accepted_versions) == 0: - raise ValueError(f"No version of `{repo_id}` satisfies requirement: {version_spec}") + latest_version = max(versions.keys()) + if version_spec < latest_version: + logger.warning( + "You are using version %d of '%s', but version %d is available.", + version_spec, + repo_id, + latest_version, + ) - return versions_old[accepted_versions[-1]] + return ref def select_revision_or_version( repo_id: str, *, revision: str | None, - version: int | str | None, + version: int | None, ) -> str: if revision is not None and version is not None: raise ValueError("Only one of `revision` or `version` must be specified.") diff --git a/kernels/src/kernels/cli/__init__.py b/kernels/src/kernels/cli/__init__.py index 51f3832ab..b3c3d92b5 100644 --- a/kernels/src/kernels/cli/__init__.py +++ b/kernels/src/kernels/cli/__init__.py @@ -4,7 +4,6 @@ import sys from pathlib import Path -from kernels.cli.upload import upload_kernels_dir from kernels.cli.versions import print_kernel_versions from kernels.compat import tomllib from kernels.lockfile import KernelLock, get_kernel_locks @@ -56,34 +55,6 @@ def main(): versions_parser.add_argument("repo_id", type=str, help="The kernel repo ID") versions_parser.set_defaults(func=kernel_versions) - upload_parser = subparsers.add_parser( - "upload", - help="(Deprecated) Upload kernels to the Hub. Use `kernel-builder upload` instead.", - ) - upload_parser.add_argument( - "kernel_dir", - type=Path, - help="Directory of the kernel build", - ) - upload_parser.add_argument( - "--repo-id", - type=str, - required=True, - help="Repository ID to use to upload to the Hugging Face Hub", - ) - upload_parser.add_argument( - "--branch", - type=str, - default=None, - help="If set, the upload will be made to a particular branch of the provided `repo-id`.", - ) - upload_parser.add_argument( - "--private", - action="store_true", - help="If the repository should be private.", - ) - upload_parser.set_defaults(func=upload_kernels) - lock_parser = subparsers.add_parser("lock", help="Lock kernel revisions") lock_parser.add_argument( "project_dir", @@ -190,29 +161,6 @@ def lock_kernels(args): json.dump(all_locks, f, cls=_JSONEncoder, indent=2) -def upload_kernels(args): - import warnings - - warnings.warn( - "`kernels upload` is deprecated and will be removed in version 0.14. " - "Please use `kernel-builder upload` instead.", - DeprecationWarning, - stacklevel=1, - ) - # Also print to stderr for visibility in CLI usage - print( - "Warning: `kernels upload` is deprecated and will be removed in version 0.14.\n" - "Please use `kernel-builder upload` instead.\n", - file=sys.stderr, - ) - upload_kernels_dir( - Path(args.kernel_dir).resolve(), - repo_id=args.repo_id, - branch=args.branch, - private=args.private, - ) - - class _JSONEncoder(json.JSONEncoder): def default(self, o): if dataclasses.is_dataclass(o): diff --git a/kernels/src/kernels/cli/upload.py b/kernels/src/kernels/cli/upload.py deleted file mode 100644 index 7d062c99f..000000000 --- a/kernels/src/kernels/cli/upload.py +++ /dev/null @@ -1,147 +0,0 @@ -from itertools import chain -from pathlib import Path - -from huggingface_hub import CommitOperationAdd, CommitOperationDelete -from huggingface_hub.utils import chunk_iterable - -from kernels.metadata import Metadata -from kernels.utils import _get_hf_api -from kernels.variants import BUILD_VARIANT_REGEX - -BUILD_COMMIT_BATCH_SIZE = 1_000 - - -def _branch_exists(api, repo_id, branch): - refs = api.list_repo_refs(repo_id=repo_id) - return any(ref.name == branch for ref in refs.branches) - - -def _upload_build_dir( - api, - *, - repo_id: str, - revision: str | None, - build_dir: Path, - variants: list[Path], - is_new_branch: bool, -): - repo_paths = {} - for variant in variants: - for path in sorted(variant.rglob("*")): - if path.is_file(): - repo_paths[f"build/{path.relative_to(build_dir).as_posix()}"] = path - - variant_prefixes = tuple(f"build/{variant.relative_to(build_dir).as_posix()}/" for variant in variants) - delete_prefixes = ("build/",) if is_new_branch else variant_prefixes - operations: list[CommitOperationAdd | CommitOperationDelete] = [ - CommitOperationDelete(path_in_repo=repo_file) - for repo_file in sorted(api.list_repo_files(repo_id=repo_id, revision=revision, repo_type="model")) - if repo_file.startswith(delete_prefixes) and repo_file not in repo_paths - ] - operations.extend( - CommitOperationAdd(path_in_repo=repo_path, path_or_fileobj=str(local_path)) - for repo_path, local_path in sorted(repo_paths.items()) - ) - - if not operations: - return - - batch_count = (len(operations) + BUILD_COMMIT_BATCH_SIZE - 1) // BUILD_COMMIT_BATCH_SIZE - if batch_count > 1: - print(f"⚠️ Found {len(operations)} build operations, uploading in {batch_count} commits.") - - for batch_index, chunk in enumerate(chunk_iterable(operations, chunk_size=BUILD_COMMIT_BATCH_SIZE), start=1): - commit_message = "Build uploaded using `kernels`." - if batch_count > 1: - commit_message = f"Build uploaded using `kernels` (batch {batch_index}/{batch_count})." - api.create_commit( - repo_id=repo_id, - operations=list(chunk), - revision=revision, - commit_message=commit_message, - ) - - -def upload_kernels_dir( - kernel_dir: Path, - *, - repo_id: str, - branch: str | None, - private: bool, -): - api = _get_hf_api() - kernel_dir = Path(kernel_dir).resolve() - - build_dir = None - variants = None - for candidate in [kernel_dir / "build", kernel_dir]: - variants = [ - variant_path - for variant_path in chain(candidate.glob("torch*"), candidate.glob("tvm-ffi*")) - if BUILD_VARIANT_REGEX.match(variant_path.name) is not None and (variant_path / "metadata.json").is_file() - ] - 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()}" - ) - - if branch is None: - assert variants is not None - versions = set() - for variant in variants: - metadata = Metadata.load_from_variant(variant) - versions.add(metadata.version) - - if len(versions) > 1: - raise ValueError( - f"Found multiple versions in build variants: {', '.join(str(version) for version in versions)}" - ) - - version = versions.pop() - if version is not None: - branch = f"v{version}" - - repo_id = api.create_repo(repo_id=repo_id, private=private, exist_ok=True).repo_id - - is_new_branch = False - if branch is not None: - is_new_branch = not _branch_exists(api, repo_id, branch) - api.create_branch(repo_id=repo_id, branch=branch, exist_ok=True) - - # In the case we have benchmarks, upload to the same repo as the kernel_dir. - if (kernel_dir / "benchmarks").is_dir(): - benchmark_delete = ["**"] if is_new_branch else ["benchmark*.py"] - api.upload_folder( - repo_id=repo_id, - folder_path=kernel_dir / "benchmarks", - revision=branch, - path_in_repo="benchmarks", - delete_patterns=benchmark_delete, - commit_message="Benchmarks uploaded using `kernels`.", - allow_patterns=["benchmark*.py"], - ) - - assert variants is not None - _upload_build_dir( - api, - repo_id=repo_id, - revision=branch, - build_dir=build_dir, - variants=variants, - is_new_branch=is_new_branch, - ) - print(f"✅ Kernel upload successful. Find the kernel in: https://hf.co/{repo_id}") - - # We always upload the card to "main" branch. - card_path = kernel_dir / "build" / "CARD.md" - if (card_path).exists(): - api.upload_file( - repo_id=repo_id, - path_or_fileobj=card_path, - path_in_repo="README.md", - revision="main", - commit_message="File uploaded using `kernels`.", - ) diff --git a/kernels/src/kernels/layer/func.py b/kernels/src/kernels/layer/func.py index 852ab4e20..a4b3e6995 100644 --- a/kernels/src/kernels/layer/func.py +++ b/kernels/src/kernels/layer/func.py @@ -35,9 +35,8 @@ class FuncRepository: The name of the function within the kernel repository. revision (`str`, *optional*, defaults to `"main"`): The specific revision (branch, tag, or commit) to download. Cannot be used together with `version`. - version (`int|str`, *optional*): - The kernel version to download as an integer. The `str` variant is deprecated and will be - removed in a future release. Cannot be used together with `revision`. + version (`int`, *optional*): + The kernel version to download. Cannot be used together with `revision`. Example: ```python @@ -64,7 +63,7 @@ def __init__( *, func_name: str, revision: str | None = None, - version: int | str | None = None, + version: int | None = None, ): if revision is not None and version is not None: raise ValueError("Either a revision or a version must be specified, not both.") diff --git a/kernels/src/kernels/layer/layer.py b/kernels/src/kernels/layer/layer.py index f227faf54..dad80bd63 100644 --- a/kernels/src/kernels/layer/layer.py +++ b/kernels/src/kernels/layer/layer.py @@ -40,9 +40,8 @@ class LayerRepository: The name of the layer within the kernel repository. revision (`str`, *optional*, defaults to `"main"`): The specific revision (branch, tag, or commit) to download. Cannot be used together with `version`. - version (`int|str`, *optional*): - The kernel version to download as an integer. The `str` variant is deprecated and will be - removed in a future release. Cannot be used together with `revision`. + version (`int`, *optional*): + The kernel version to download. Cannot be used together with `revision`. Example: ```python @@ -63,7 +62,7 @@ def __init__( *, layer_name: str, revision: str | None = None, - version: int | str | None = None, + version: int | None = None, ): if revision is not None and version is not None: raise ValueError("Either a revision or a version must be specified, not both.") diff --git a/kernels/src/kernels/lockfile.py b/kernels/src/kernels/lockfile.py index 86b4051bb..2c500c5c1 100644 --- a/kernels/src/kernels/lockfile.py +++ b/kernels/src/kernels/lockfile.py @@ -30,12 +30,9 @@ def from_json(cls, o: dict): return cls(repo_id=o["repo_id"], sha=o["sha"], variants=variants) -def get_kernel_locks(repo_id: str, version_spec: int | str) -> KernelLock: +def get_kernel_locks(repo_id: str, version_spec: int) -> KernelLock: """ - Get the locks for a kernel with the given version spec. - - The version specifier can be any valid Python version specifier: - https://packaging.python.org/en/latest/specifications/version-specifiers/#version-specifiers + Get the locks for a kernel with the given version. """ from kernels.utils import _get_hf_api diff --git a/kernels/src/kernels/utils.py b/kernels/src/kernels/utils.py index ae084bf07..ab7cd0171 100644 --- a/kernels/src/kernels/utils.py +++ b/kernels/src/kernels/utils.py @@ -5,7 +5,6 @@ import importlib.metadata import inspect import json -import logging import os import platform import sys @@ -56,11 +55,6 @@ def get_loaded_kernels() -> list[LoadedKernel]: def _get_cache_dir() -> str | None: """Returns the kernels cache directory.""" - cache_dir = os.environ.get("HF_KERNELS_CACHE", None) - if cache_dir is not None: - logging.warning("HF_KERNELS_CACHE will be removed in the future, use KERNELS_CACHE instead") - return cache_dir - return os.environ.get("KERNELS_CACHE", None) @@ -265,7 +259,7 @@ def install_kernel_all_variants( def get_kernel( repo_id: str, revision: str | None = None, - version: int | str | None = None, + version: int | None = None, backend: str | None = None, user_agent: str | dict | None = None, ) -> ModuleType: @@ -280,9 +274,8 @@ def get_kernel( The Hub repository containing the kernel. revision (`str`, *optional*, defaults to `"main"`): The specific revision (branch, tag, or commit) to download. Cannot be used together with `version`. - version (`int|str`, *optional*): - The kernel version to download as an integer. The `str` variant is deprecated and will be - removed in a future release. Cannot be used together with `revision`. + version (`int`, *optional*): + The kernel version to download. Cannot be used together with `revision`. backend (`str`, *optional*): The backend to load the kernel for. Can only be `cpu` or the backend that Torch is compiled for. The backend will be detected automatically if not provided. @@ -361,7 +354,7 @@ def get_local_kernel( def has_kernel( repo_id: str, revision: str | None = None, - version: int | str | None = None, + version: int | None = None, backend: str | None = None, ) -> bool: """ @@ -372,9 +365,8 @@ def has_kernel( The Hub repository containing the kernel. revision (`str`, *optional*, defaults to `"main"`): The specific revision (branch, tag, or commit) to download. Cannot be used together with `version`. - version (`int|str`, *optional*): - The kernel version to download as an integer. The `str` variant is deprecated and will be - removed in a future release. Cannot be used together with `revision`. + version (`int`, *optional*): + The kernel version to download. Cannot be used together with `revision`. backend (`str`, *optional*): The backend to load the kernel for. Can only be `cpu` or the backend that Torch is compiled for. The backend will be detected automatically if not provided. diff --git a/kernels/tests/kernel_locking_old/kernels.lock b/kernels/tests/kernel_locking_old/kernels.lock deleted file mode 100644 index 9dedafd09..000000000 --- a/kernels/tests/kernel_locking_old/kernels.lock +++ /dev/null @@ -1,158 +0,0 @@ -[ - { - "repo_id": "kernels-community/activation", - "sha": "b3cb933fdc2354b80db222dadff831503b9c1632", - "variants": { - "torch210-cu128-x86_64-windows": { - "hash": "sha256-cbf085e1d297d990d9cb074fb5079ff48e9682c729f53a0899a36b5164a6fb45", - "hash_type": "git_lfs_concat" - }, - "torch210-cxx11-cu126-aarch64-linux": { - "hash": "sha256-85184e408af4b22586d1da98632b7d1ab3d9d87b8becbc5b5c785025a55fbe88", - "hash_type": "git_lfs_concat" - }, - "torch210-cxx11-cu126-x86_64-linux": { - "hash": "sha256-924c5f36805c1f12649cfabc28d1234ffce7cc6fa7e12c9e0841b3760290a57a", - "hash_type": "git_lfs_concat" - }, - "torch210-cxx11-cu128-aarch64-linux": { - "hash": "sha256-45ba6c5202137081323abc42c92b5a2fb9c46b1d89f9f2d8ecd7e4192cf66e2e", - "hash_type": "git_lfs_concat" - }, - "torch210-cxx11-cu128-x86_64-linux": { - "hash": "sha256-0c5ff1cdf5d020edc4b79b7bad40f671c8692c33fa2492334c0171a328c546e5", - "hash_type": "git_lfs_concat" - }, - "torch210-cxx11-cu130-aarch64-linux": { - "hash": "sha256-e3c8da0b23e9c4fa7b749e5b917f029951135a4c0d5fc4e76d6bc84d6201f116", - "hash_type": "git_lfs_concat" - }, - "torch210-cxx11-cu130-x86_64-linux": { - "hash": "sha256-d090008245aec4d8dd7a92226c15e6cc3b9465afebe9a7a2357dad78c3c3be2c", - "hash_type": "git_lfs_concat" - }, - "torch210-metal-aarch64-darwin": { - "hash": "sha256-369e4f2ca723aa2776cab8330eae464b99ee7531072d1f90075afeadc4c5c5d1", - "hash_type": "git_lfs_concat" - }, - "torch211-cu128-x86_64-windows": { - "hash": "sha256-b4ff2e690c8eac3e93643c442f8cf8acc8f6514d9054fa425186800d2a5a6e2f", - "hash_type": "git_lfs_concat" - }, - "torch211-cxx11-cu126-aarch64-linux": { - "hash": "sha256-abff92d40279ee8324039b0ddfa7e4791d6d0a52ea552328903ec48d9cb7f9f4", - "hash_type": "git_lfs_concat" - }, - "torch211-cxx11-cu126-x86_64-linux": { - "hash": "sha256-deb8ab3998f075b44462cce4bf36d449c8934012c928073c36f1deabd10d9445", - "hash_type": "git_lfs_concat" - }, - "torch211-cxx11-cu128-aarch64-linux": { - "hash": "sha256-ff7945f50f5b27d43d31cbe1ba3b515fcb8bdc691538b6632efafbb61b7cce4d", - "hash_type": "git_lfs_concat" - }, - "torch211-cxx11-cu128-x86_64-linux": { - "hash": "sha256-3ec6937795f4d0178ce36dbc23e53e0cb59bb583f4158b6cde254a37e1202881", - "hash_type": "git_lfs_concat" - }, - "torch211-cxx11-cu130-aarch64-linux": { - "hash": "sha256-b574e8b6f35077b78af583c735e952acfcc81a61400e53821053fa9537a72030", - "hash_type": "git_lfs_concat" - }, - "torch211-cxx11-cu130-x86_64-linux": { - "hash": "sha256-2fd9f14f77b717b7a1ef0010a57a4a6e45b322ea76ed866035103576116d32cf", - "hash_type": "git_lfs_concat" - }, - "torch211-metal-aarch64-darwin": { - "hash": "sha256-9430c5a298420b9457fe96aa1e8011e62aeaaa60a918ae35c563da1d62262a7a", - "hash_type": "git_lfs_concat" - }, - "torch27-cxx11-cu118-x86_64-linux": { - "hash": "sha256-e34965c814c4c092fcb634ebadefe82ea9a05b98343f8ebdefa7305dcc05359e", - "hash_type": "git_lfs_concat" - }, - "torch27-cxx11-cu126-x86_64-linux": { - "hash": "sha256-5f92b35922b37224a416398a39a29b7e5f1aca1df17d5c69f1b9e9cdb7033561", - "hash_type": "git_lfs_concat" - }, - "torch27-cxx11-cu128-aarch64-linux": { - "hash": "sha256-125967cb23bacd2cec443799f184ac08247dfff33f5027e54ee16d3779ca5986", - "hash_type": "git_lfs_concat" - }, - "torch27-cxx11-cu128-x86_64-linux": { - "hash": "sha256-496a84c99d7035a1b6f0ea1c026b751c3a2677956f4c1be546d3cc1505a5fdbb", - "hash_type": "git_lfs_concat" - }, - "torch28-cxx11-cu126-aarch64-linux": { - "hash": "sha256-f0775a30ffa290c90aba3a41037e3ca91edb15b4a9367561fafd5f25455e117a", - "hash_type": "git_lfs_concat" - }, - "torch28-cxx11-cu126-x86_64-linux": { - "hash": "sha256-f8281d634ef8aff5f8c59409032ede3263ec88a98e17eb18d5c8e9fa9534dd22", - "hash_type": "git_lfs_concat" - }, - "torch28-cxx11-cu128-aarch64-linux": { - "hash": "sha256-b937fef62a0c1cd71ab98490b651c473577af209b9a3e2a6b452350283d8812c", - "hash_type": "git_lfs_concat" - }, - "torch28-cxx11-cu128-x86_64-linux": { - "hash": "sha256-481c8ebeb936c717f16e45bc8ff783ac2778e64439f15ac0bb94db8b0798ac59", - "hash_type": "git_lfs_concat" - }, - "torch28-cxx11-cu129-aarch64-linux": { - "hash": "sha256-a24dca8e998f88be42491921c9df89d88a6112ca630acd2efc2dd34a64b91fcb", - "hash_type": "git_lfs_concat" - }, - "torch28-cxx11-cu129-x86_64-linux": { - "hash": "sha256-92687517c590c6206116ded3d9d05c60b478c4be04de7c9ab4e6b88b3a539c0b", - "hash_type": "git_lfs_concat" - }, - "torch29-cxx11-cu126-aarch64-linux": { - "hash": "sha256-c120011c201072b4cfd70c2ba2d45c2f05337feaf604ddec3c6c4987def33ab3", - "hash_type": "git_lfs_concat" - }, - "torch29-cxx11-cu126-x86_64-linux": { - "hash": "sha256-5a28d4d7c370280d7f35024ccbc52e4ff09e7b10dc05f5026db0c0c189c1d0c4", - "hash_type": "git_lfs_concat" - }, - "torch29-cxx11-cu128-aarch64-linux": { - "hash": "sha256-266d057a9cd82b872a0e02f09ac5e2660fcffcf9a7b7fa1fa8ff33dc19c0f5c2", - "hash_type": "git_lfs_concat" - }, - "torch29-cxx11-cu128-x86_64-linux": { - "hash": "sha256-64852d1194ba9c2476f3b3046148fbbfeb7adab645ef86b30dd393d4c0ba4ed0", - "hash_type": "git_lfs_concat" - }, - "torch29-cxx11-cu129-aarch64-linux": { - "hash": "sha256-c7444128e54787e1597e1d84ef221d4cf0e2cdefd11f772d8eb5ab904d8c8df0", - "hash_type": "git_lfs_concat" - }, - "torch29-cxx11-cu129-x86_64-linux": { - "hash": "sha256-6868015dc4cdc088b669f474a944a206d78f9cf427c0a35086091309cff8a3ed", - "hash_type": "git_lfs_concat" - }, - "torch29-cxx11-cu130-aarch64-linux": { - "hash": "sha256-23741b935462b53bdf868f8d1c9c8cff5f02f71ea3b0550df41dc8b030b0b474", - "hash_type": "git_lfs_concat" - }, - "torch29-cxx11-cu130-x86_64-linux": { - "hash": "sha256-2e6f47d3152c8e2a920d56f06bd635ca96210b02bde76f1cc73a7c9bf98f5e07", - "hash_type": "git_lfs_concat" - }, - "torch29-metal-aarch64-darwin": { - "hash": "sha256-9f665b54a53246a7d3627422f8a0d41d7956dc5409043dbd14c4ec0327aea310", - "hash_type": "git_lfs_concat" - } - } - }, - { - "repo_id": "kernels-community/triton-scaled-mm", - "sha": "d9d0c93d9a705edd38d446199589c5aca981e215", - "variants": { - "torch-universal": { - "hash": "sha256-b843c5f30b52b6c1c56fca28cb0cf453be71d6ce7d308f383dce71a8050f7b52", - "hash_type": "git_lfs_concat" - } - } - } -] diff --git a/kernels/tests/kernel_locking_old/pyproject.toml b/kernels/tests/kernel_locking_old/pyproject.toml deleted file mode 100644 index eeffd5aa1..000000000 --- a/kernels/tests/kernel_locking_old/pyproject.toml +++ /dev/null @@ -1,3 +0,0 @@ -[tool.kernels.dependencies] -"kernels-community/activation" = ">=0.0.2" -"kernels-community/triton-scaled-mm" = ">=0.0.2" diff --git a/kernels/tests/layer_locking/kernels.lock b/kernels/tests/layer_locking/kernels.lock index 533cdb0f0..1796bd89d 100644 --- a/kernels/tests/layer_locking/kernels.lock +++ b/kernels/tests/layer_locking/kernels.lock @@ -1,28 +1,28 @@ [ { "repo_id": "kernels-test/versions", - "sha": "56d69c4e6d313a4616421077eee6447fffbe3e70", + "sha": "31a8142c476b8933320aae9a198945dcebe20f45", "variants": { "torch-cpu": { - "hash": "sha256-e1e60c9e2c69f1b60614f5867e22e9147a2419984b4ef77041ae920c7abc4a73", + "hash": "sha256-d70e804797597372e50001a1e631e96bb38ccec669f5f0a47d7e9863af293447", "hash_type": "git_lfs_concat" }, "torch-cuda": { - "hash": "sha256-e1e60c9e2c69f1b60614f5867e22e9147a2419984b4ef77041ae920c7abc4a73", + "hash": "sha256-d70e804797597372e50001a1e631e96bb38ccec669f5f0a47d7e9863af293447", "hash_type": "git_lfs_concat" }, "torch-rocm": { - "hash": "sha256-e1e60c9e2c69f1b60614f5867e22e9147a2419984b4ef77041ae920c7abc4a73", + "hash": "sha256-d70e804797597372e50001a1e631e96bb38ccec669f5f0a47d7e9863af293447", "hash_type": "git_lfs_concat" }, "torch-universal": { - "hash": "sha256-57de77a9bde54f52d0a67eb9e5d259d223cae66963f644ed2b7386f59f7e2d23", + "hash": "sha256-cf447f2d128fc60937aee4e2cfe2a915df0829b170a86e5760783726de86a731", "hash_type": "git_lfs_concat" }, "torch-xpu": { - "hash": "sha256-e1e60c9e2c69f1b60614f5867e22e9147a2419984b4ef77041ae920c7abc4a73", + "hash": "sha256-d70e804797597372e50001a1e631e96bb38ccec669f5f0a47d7e9863af293447", "hash_type": "git_lfs_concat" } } } -] +] \ No newline at end of file diff --git a/kernels/tests/layer_locking/pyproject.toml b/kernels/tests/layer_locking/pyproject.toml index 92a0bc11f..3be48ef45 100644 --- a/kernels/tests/layer_locking/pyproject.toml +++ b/kernels/tests/layer_locking/pyproject.toml @@ -1,2 +1,2 @@ [tool.kernels.dependencies] -"kernels-test/versions" = ">=0.1.0,<0.2.0" +"kernels-test/versions" = 2 diff --git a/kernels/tests/layer_locking_old/kernels.lock b/kernels/tests/layer_locking_old/kernels.lock deleted file mode 100644 index a85c6188a..000000000 --- a/kernels/tests/layer_locking_old/kernels.lock +++ /dev/null @@ -1,12 +0,0 @@ -[ - { - "repo_id": "kernels-test/versions", - "sha": "d3821a34bf6736bb7312025138becd4b8b2eb704", - "variants": { - "torch-universal": { - "hash": "sha256-57de77a9bde54f52d0a67eb9e5d259d223cae66963f644ed2b7386f59f7e2d23", - "hash_type": "git_lfs_concat" - } - } - } -] diff --git a/kernels/tests/layer_locking_old/pyproject.toml b/kernels/tests/layer_locking_old/pyproject.toml deleted file mode 100644 index 92a0bc11f..000000000 --- a/kernels/tests/layer_locking_old/pyproject.toml +++ /dev/null @@ -1,2 +0,0 @@ -[tool.kernels.dependencies] -"kernels-test/versions" = ">=0.1.0,<0.2.0" diff --git a/kernels/tests/test_kernel_locking.py b/kernels/tests/test_kernel_locking.py index 7c860c03a..9e8129136 100644 --- a/kernels/tests/test_kernel_locking.py +++ b/kernels/tests/test_kernel_locking.py @@ -29,11 +29,6 @@ def test_download_all_hash_validation(): download_kernels(DownloadArgs(all_variants=True, project_dir=project_dir)) -def test_download_all_hash_validation_old(): - project_dir = Path(__file__).parent / "kernel_locking_old" - download_kernels(DownloadArgs(all_variants=True, project_dir=project_dir)) - - @pytest.mark.cuda_only def test_load_locked(): project_dir = Path(__file__).parent / "kernel_locking" @@ -42,14 +37,6 @@ def test_load_locked(): load_kernel("kernels-community/relu", lockfile=project_dir / "kernels.lock") -@pytest.mark.cuda_only -def test_load_locked_old(): - project_dir = Path(__file__).parent / "kernel_locking_old" - # Also validates that hashing works correctly. - download_kernels(DownloadArgs(all_variants=False, project_dir=project_dir)) - load_kernel("kernels-community/activation", lockfile=project_dir / "kernels.lock") - - def test_layer_locked(device): project_dir = Path(__file__).parent / "layer_locking" @@ -72,49 +59,7 @@ def forward(self) -> str: } ): version = kernelize(version, device=device, mode=Mode.INFERENCE) - assert version() == "1" - - -@pytest.mark.skip(reason="Tags are not supported on kernel repos") -def test_layer_locked_old(device): - project_dir = Path(__file__).parent / "layer_locking_old" - - @use_kernel_forward_from_hub("Version") - class Version(nn.Module): - def forward(self) -> str: - return "0.0.0" - - version = Version() - - with use_kernel_mapping( - { - "Version": { - device: LockedLayerRepository( - repo_id="kernels-test/versions", - layer_name="Version", - lockfile=project_dir / "kernels.lock", - ) - }, - } - ): - version = kernelize(version, device=device, mode=Mode.INFERENCE) - assert version() == "0.1.1" - - with pytest.raises(ValueError, match="Kernel.* is not locked"): - # Must fail, because our project does not have a lock for it. However, - # if layer caching is too aggressive (i.e. does not take the revision into - # account), this may incorrectly pass. - with use_kernel_mapping( - { - "Version": { - device: LockedLayerRepository( - repo_id="kernels-test/versions", - layer_name="Version", - ) - }, - } - ): - kernelize(version, device=device, mode=Mode.INFERENCE) + assert version() == "2" def test_func_locked(device): @@ -147,62 +92,7 @@ def forward(self) -> str: ): model = kernelize(model, device=device, mode=Mode.INFERENCE) - assert version() == "1" - - with use_kernel_mapping({"version": {}}): - model = kernelize(model, mode=Mode.INFERENCE, device=device) - - assert version() == "0.0.0" - - -@pytest.mark.skip(reason="Tags are not supported on kernel repos") -def test_func_locked_old(device): - project_dir = Path(__file__).parent / "layer_locking_old" - - @use_kernel_func_from_hub("version") - def version(): - return "0.0.0" - - class Version(nn.Module): - def __init__(self): - super().__init__() - self.version = version - - def forward(self) -> str: - return self.version() - - model = Version() - - with use_kernel_mapping( - { - "version": { - device: LockedFuncRepository( - repo_id="kernels-test/versions", - func_name="version", - lockfile=project_dir / "kernels.lock", - ) - }, - } - ): - model = kernelize(model, device=device, mode=Mode.INFERENCE) - - assert version() == "0.1.1" - - with pytest.raises(ValueError, match="Kernel.* is not locked"): - # Must fail, because our project does not have a lock for it. However, - # if layer caching is too aggressive (i.e. does not take the revision into - # account), this may incorrectly pass. - with use_kernel_mapping( - { - "version": { - device: LockedFuncRepository( - repo_id="kernels-test/versions", - func_name="version", - ) - }, - } - ): - kernelize(model, device=device, mode=Mode.INFERENCE) + assert version() == "2" with use_kernel_mapping({"version": {}}): model = kernelize(model, mode=Mode.INFERENCE, device=device) diff --git a/kernels/tests/test_kernel_upload.py b/kernels/tests/test_kernel_upload.py deleted file mode 100644 index c26bc04ef..000000000 --- a/kernels/tests/test_kernel_upload.py +++ /dev/null @@ -1,272 +0,0 @@ -import logging -import os -import re -import tempfile -from dataclasses import dataclass -from pathlib import Path -from types import SimpleNamespace -from unittest.mock import MagicMock, Mock, patch - -import pytest -from huggingface_hub import CommitOperationAdd, CommitOperationDelete - -from kernels.cli import upload_kernels -from kernels.cli.upload import BUILD_COMMIT_BATCH_SIZE, upload_kernels_dir -from kernels.utils import _get_hf_api - -REPO_ID = "__DUMMY_KERNELS_USER__/kernels-upload-test" - - -PY_CONTENT = """\ -#!/usr/bin/env python3 - -def main(): - print("Hello from torch-universal!") - -if __name__ == "__main__": - main() -""" - - -@dataclass -class UploadArgs: - kernel_dir: None - repo_id: None - private: False - branch: None - - -def create_build_variant(tmpdir: str, filename: str) -> tuple[Path, Path]: - build_dir = Path(tmpdir) / "build" / "torch-cpu" - build_dir.mkdir(parents=True, exist_ok=True) - (build_dir / "metadata.json").write_text('{"version": null, "python-depends": []}') - script_path = build_dir / filename - script_path.write_text(PY_CONTENT) - return build_dir, script_path - - -def next_filename(path: Path) -> Path: - """ - Given a path like foo_2050.py, return foo_2051.py. - """ - m = re.match(r"^(.*?)(\d+)(\.py)$", path.name) - if not m: - raise ValueError(f"Filename {path.name!r} does not match pattern _.py") - - prefix, number, suffix = m.groups() - new_number = str(int(number) + 1).zfill(len(number)) - return path.with_name(f"{prefix}{new_number}{suffix}") - - -def get_filename_to_change(repo_filenames): - for f in repo_filenames: - if "foo" in f and f.endswith(".py"): - filename_to_change = os.path.basename(f) - break - assert filename_to_change - return filename_to_change - - -def get_filenames_from_a_repo(repo_id: str) -> list[str]: - try: - repo_info = _get_hf_api().model_info(repo_id=repo_id, files_metadata=True) - repo_siblings = repo_info.siblings - if repo_siblings is not None: - return [f.rfilename for f in repo_siblings] - else: - raise ValueError("No repo siblings found.") - except Exception as e: - logging.error(f"Error connecting to the Hub: {e}.") - - -@pytest.mark.token -@pytest.mark.is_staging_test -@pytest.mark.parametrize("branch", (None, "foo")) -def test_kernel_upload_works_as_expected(branch): - with tempfile.TemporaryDirectory() as tmpdir: - _, script_path = create_build_variant(tmpdir, "foo.py") - upload_kernels(UploadArgs(tmpdir, REPO_ID, False, branch)) - - repo_filenames = get_filenames_from_a_repo(REPO_ID) - assert any(str(script_path.name) for f in repo_filenames) - - api = _get_hf_api() - if branch is not None: - refs = api.list_repo_refs(repo_id=REPO_ID) - assert any(ref_branch.name == branch for ref_branch in refs.branches) - - api.delete_repo(repo_id=REPO_ID) - - -def get_filenames_from_a_branch(repo_id: str, branch: str) -> list[str]: - try: - repo_info = _get_hf_api().model_info(repo_id=repo_id, revision=branch, files_metadata=True) - repo_siblings = repo_info.siblings - if repo_siblings is not None: - return [f.rfilename for f in repo_siblings] - else: - raise ValueError("No repo siblings found.") - except Exception as e: - logging.error(f"Error connecting to the Hub: {e}.") - - -@pytest.mark.token -@pytest.mark.is_staging_test -def test_kernel_upload_new_branch_starts_fresh(): - api = _get_hf_api() - - # First upload to main to populate it. - with tempfile.TemporaryDirectory() as tmpdir: - create_build_variant(tmpdir, "foo.py") - upload_kernels(UploadArgs(tmpdir, REPO_ID, False, None)) - - main_files = get_filenames_from_a_repo(REPO_ID) - assert any("foo.py" in f for f in main_files) - - # Now upload a different variant to a new branch. - with tempfile.TemporaryDirectory() as tmpdir: - create_build_variant(tmpdir, "bar.py") - upload_kernels(UploadArgs(tmpdir, REPO_ID, False, "v2")) - - branch_files = get_filenames_from_a_branch(REPO_ID, "v2") - - assert any("bar.py" in f for f in branch_files), f"{branch_files=}" - assert not any("foo.py" in f for f in branch_files), ( - f"Branch v2 should not inherit foo.py from main: {branch_files=}" - ) - - api.delete_repo(repo_id=REPO_ID) - - -@pytest.mark.token -@pytest.mark.is_staging_test -def test_kernel_upload_deletes_as_expected(): - with tempfile.TemporaryDirectory() as tmpdir: - _, script_path = create_build_variant(tmpdir, "foo_2025.py") - upload_kernels(UploadArgs(tmpdir, REPO_ID, False, None)) - - repo_filenames = get_filenames_from_a_repo(REPO_ID) - filename_to_change = get_filename_to_change(repo_filenames) - - with tempfile.TemporaryDirectory() as tmpdir: - changed_filename = next_filename(Path(filename_to_change)) - create_build_variant(tmpdir, changed_filename) - upload_kernels(UploadArgs(tmpdir, REPO_ID, False, None)) - - repo_filenames = get_filenames_from_a_repo(REPO_ID) - assert any(str(changed_filename) in k for k in repo_filenames), f"{repo_filenames=}" - assert not any(str(filename_to_change) in k for k in repo_filenames), f"{repo_filenames=}" - _get_hf_api().delete_repo(repo_id=REPO_ID) - - -def test_upload_includes_card_as_readme(): - with tempfile.TemporaryDirectory() as tmpdir: - kernel_dir = Path(tmpdir).resolve() - - variant_dir = kernel_dir / "torch-cuda" - variant_dir.mkdir(parents=True) - (variant_dir / "metadata.json").write_text('{"version": 1, "python-depends": []}') - - build_dir = kernel_dir / "build" - build_dir.mkdir() - card_path = build_dir / "CARD.md" - card_path.write_text("# Test Kernel\n") - - mock_api = MagicMock() - mock_api.create_repo.return_value.repo_id = REPO_ID - - with patch("kernels.cli.upload._get_hf_api", return_value=mock_api): - upload_kernels_dir(kernel_dir, repo_id=REPO_ID, branch=None, private=False) - - mock_api.upload_file.assert_called_once_with( - repo_id=REPO_ID, - path_or_fileobj=card_path, - path_in_repo="README.md", - revision="main", - commit_message="File uploaded using `kernels`.", - ) - - -def test_large_kernel_upload_uses_create_commit_batches(monkeypatch, tmp_path): - kernel_root = tmp_path / "kernel" - build_variant = kernel_root / "build" / "torch-cpu" - build_variant.mkdir(parents=True, exist_ok=True) - (build_variant / "metadata.json").write_text("{}") - file_count = BUILD_COMMIT_BATCH_SIZE * 2 - for i in range(file_count): - (build_variant / f"file_{i}.py").touch() - - api = Mock() - api.create_repo.return_value = SimpleNamespace(repo_id=REPO_ID) - api.list_repo_refs.return_value = SimpleNamespace(branches=[SimpleNamespace(name="main")]) - api.list_repo_files.return_value = [ - "README.md", - "build/torch-cpu/file_0.py", - "build/torch-cpu/stale.py", - "build/torch-cuda/keep.py", - ] - monkeypatch.setattr("kernels.cli.upload._get_hf_api", lambda: api) - - upload_kernels(UploadArgs(kernel_root, REPO_ID, False, "main")) - - # 2 full batches of adds, plus metadata and 1 stale-file delete. - assert api.create_commit.call_count == 3 - batch_sizes = [len(call.kwargs["operations"]) for call in api.create_commit.call_args_list] - assert batch_sizes == [ - BUILD_COMMIT_BATCH_SIZE, - BUILD_COMMIT_BATCH_SIZE, - 2, - ] - commit_messages = [call.kwargs["commit_message"] for call in api.create_commit.call_args_list] - assert commit_messages == [ - "Build uploaded using `kernels` (batch 1/3).", - "Build uploaded using `kernels` (batch 2/3).", - "Build uploaded using `kernels` (batch 3/3).", - ] - - # Stale repo files should be deleted. - operations = [operation for call in api.create_commit.call_args_list for operation in call.kwargs["operations"]] - delete_paths = {op.path_in_repo for op in operations if isinstance(op, CommitOperationDelete)} - assert delete_paths == {"build/torch-cpu/stale.py"} - - add_paths = {op.path_in_repo for op in operations if isinstance(op, CommitOperationAdd)} - assert len(add_paths) == file_count + 1 - assert "build/torch-cpu/metadata.json" in add_paths - assert "build/torch-cpu/file_0.py" in add_paths - assert "build/torch-cpu/file_399.py" in add_paths - api.upload_folder.assert_not_called() - - -def test_new_branch_upload_replaces_inherited_build_tree(monkeypatch, tmp_path): - kernel_root = tmp_path / "kernel" - build_variant = kernel_root / "build" / "torch-cpu" - build_variant.mkdir(parents=True, exist_ok=True) - (build_variant / "metadata.json").write_text("{}") - (build_variant / "current.py").write_text(PY_CONTENT) - - benchmarks_dir = kernel_root / "benchmarks" - benchmarks_dir.mkdir(parents=True, exist_ok=True) - (benchmarks_dir / "benchmark_current.py").write_text(PY_CONTENT) - - api = Mock() - api.create_repo.return_value = SimpleNamespace(repo_id=REPO_ID) - api.list_repo_refs.return_value = SimpleNamespace(branches=[]) - api.list_repo_files.return_value = [ - "README.md", - "benchmarks/benchmark_old.py", - "build/torch-cpu/stale.py", - "build/torch-cuda/inherited.py", - ] - monkeypatch.setattr("kernels.cli.upload._get_hf_api", lambda: api) - - upload_kernels(UploadArgs(kernel_root, REPO_ID, False, "v2")) - - api.upload_folder.assert_called_once() - assert api.upload_folder.call_args.kwargs["delete_patterns"] == ["**"] - - operations = [operation for call in api.create_commit.call_args_list for operation in call.kwargs["operations"]] - delete_paths = {op.path_in_repo for op in operations if isinstance(op, CommitOperationDelete)} - assert delete_paths == { - "build/torch-cpu/stale.py", - "build/torch-cuda/inherited.py", - } diff --git a/tests/kernel_locking_old/kernels.lock b/tests/kernel_locking_old/kernels.lock deleted file mode 100644 index 9dedafd09..000000000 --- a/tests/kernel_locking_old/kernels.lock +++ /dev/null @@ -1,158 +0,0 @@ -[ - { - "repo_id": "kernels-community/activation", - "sha": "b3cb933fdc2354b80db222dadff831503b9c1632", - "variants": { - "torch210-cu128-x86_64-windows": { - "hash": "sha256-cbf085e1d297d990d9cb074fb5079ff48e9682c729f53a0899a36b5164a6fb45", - "hash_type": "git_lfs_concat" - }, - "torch210-cxx11-cu126-aarch64-linux": { - "hash": "sha256-85184e408af4b22586d1da98632b7d1ab3d9d87b8becbc5b5c785025a55fbe88", - "hash_type": "git_lfs_concat" - }, - "torch210-cxx11-cu126-x86_64-linux": { - "hash": "sha256-924c5f36805c1f12649cfabc28d1234ffce7cc6fa7e12c9e0841b3760290a57a", - "hash_type": "git_lfs_concat" - }, - "torch210-cxx11-cu128-aarch64-linux": { - "hash": "sha256-45ba6c5202137081323abc42c92b5a2fb9c46b1d89f9f2d8ecd7e4192cf66e2e", - "hash_type": "git_lfs_concat" - }, - "torch210-cxx11-cu128-x86_64-linux": { - "hash": "sha256-0c5ff1cdf5d020edc4b79b7bad40f671c8692c33fa2492334c0171a328c546e5", - "hash_type": "git_lfs_concat" - }, - "torch210-cxx11-cu130-aarch64-linux": { - "hash": "sha256-e3c8da0b23e9c4fa7b749e5b917f029951135a4c0d5fc4e76d6bc84d6201f116", - "hash_type": "git_lfs_concat" - }, - "torch210-cxx11-cu130-x86_64-linux": { - "hash": "sha256-d090008245aec4d8dd7a92226c15e6cc3b9465afebe9a7a2357dad78c3c3be2c", - "hash_type": "git_lfs_concat" - }, - "torch210-metal-aarch64-darwin": { - "hash": "sha256-369e4f2ca723aa2776cab8330eae464b99ee7531072d1f90075afeadc4c5c5d1", - "hash_type": "git_lfs_concat" - }, - "torch211-cu128-x86_64-windows": { - "hash": "sha256-b4ff2e690c8eac3e93643c442f8cf8acc8f6514d9054fa425186800d2a5a6e2f", - "hash_type": "git_lfs_concat" - }, - "torch211-cxx11-cu126-aarch64-linux": { - "hash": "sha256-abff92d40279ee8324039b0ddfa7e4791d6d0a52ea552328903ec48d9cb7f9f4", - "hash_type": "git_lfs_concat" - }, - "torch211-cxx11-cu126-x86_64-linux": { - "hash": "sha256-deb8ab3998f075b44462cce4bf36d449c8934012c928073c36f1deabd10d9445", - "hash_type": "git_lfs_concat" - }, - "torch211-cxx11-cu128-aarch64-linux": { - "hash": "sha256-ff7945f50f5b27d43d31cbe1ba3b515fcb8bdc691538b6632efafbb61b7cce4d", - "hash_type": "git_lfs_concat" - }, - "torch211-cxx11-cu128-x86_64-linux": { - "hash": "sha256-3ec6937795f4d0178ce36dbc23e53e0cb59bb583f4158b6cde254a37e1202881", - "hash_type": "git_lfs_concat" - }, - "torch211-cxx11-cu130-aarch64-linux": { - "hash": "sha256-b574e8b6f35077b78af583c735e952acfcc81a61400e53821053fa9537a72030", - "hash_type": "git_lfs_concat" - }, - "torch211-cxx11-cu130-x86_64-linux": { - "hash": "sha256-2fd9f14f77b717b7a1ef0010a57a4a6e45b322ea76ed866035103576116d32cf", - "hash_type": "git_lfs_concat" - }, - "torch211-metal-aarch64-darwin": { - "hash": "sha256-9430c5a298420b9457fe96aa1e8011e62aeaaa60a918ae35c563da1d62262a7a", - "hash_type": "git_lfs_concat" - }, - "torch27-cxx11-cu118-x86_64-linux": { - "hash": "sha256-e34965c814c4c092fcb634ebadefe82ea9a05b98343f8ebdefa7305dcc05359e", - "hash_type": "git_lfs_concat" - }, - "torch27-cxx11-cu126-x86_64-linux": { - "hash": "sha256-5f92b35922b37224a416398a39a29b7e5f1aca1df17d5c69f1b9e9cdb7033561", - "hash_type": "git_lfs_concat" - }, - "torch27-cxx11-cu128-aarch64-linux": { - "hash": "sha256-125967cb23bacd2cec443799f184ac08247dfff33f5027e54ee16d3779ca5986", - "hash_type": "git_lfs_concat" - }, - "torch27-cxx11-cu128-x86_64-linux": { - "hash": "sha256-496a84c99d7035a1b6f0ea1c026b751c3a2677956f4c1be546d3cc1505a5fdbb", - "hash_type": "git_lfs_concat" - }, - "torch28-cxx11-cu126-aarch64-linux": { - "hash": "sha256-f0775a30ffa290c90aba3a41037e3ca91edb15b4a9367561fafd5f25455e117a", - "hash_type": "git_lfs_concat" - }, - "torch28-cxx11-cu126-x86_64-linux": { - "hash": "sha256-f8281d634ef8aff5f8c59409032ede3263ec88a98e17eb18d5c8e9fa9534dd22", - "hash_type": "git_lfs_concat" - }, - "torch28-cxx11-cu128-aarch64-linux": { - "hash": "sha256-b937fef62a0c1cd71ab98490b651c473577af209b9a3e2a6b452350283d8812c", - "hash_type": "git_lfs_concat" - }, - "torch28-cxx11-cu128-x86_64-linux": { - "hash": "sha256-481c8ebeb936c717f16e45bc8ff783ac2778e64439f15ac0bb94db8b0798ac59", - "hash_type": "git_lfs_concat" - }, - "torch28-cxx11-cu129-aarch64-linux": { - "hash": "sha256-a24dca8e998f88be42491921c9df89d88a6112ca630acd2efc2dd34a64b91fcb", - "hash_type": "git_lfs_concat" - }, - "torch28-cxx11-cu129-x86_64-linux": { - "hash": "sha256-92687517c590c6206116ded3d9d05c60b478c4be04de7c9ab4e6b88b3a539c0b", - "hash_type": "git_lfs_concat" - }, - "torch29-cxx11-cu126-aarch64-linux": { - "hash": "sha256-c120011c201072b4cfd70c2ba2d45c2f05337feaf604ddec3c6c4987def33ab3", - "hash_type": "git_lfs_concat" - }, - "torch29-cxx11-cu126-x86_64-linux": { - "hash": "sha256-5a28d4d7c370280d7f35024ccbc52e4ff09e7b10dc05f5026db0c0c189c1d0c4", - "hash_type": "git_lfs_concat" - }, - "torch29-cxx11-cu128-aarch64-linux": { - "hash": "sha256-266d057a9cd82b872a0e02f09ac5e2660fcffcf9a7b7fa1fa8ff33dc19c0f5c2", - "hash_type": "git_lfs_concat" - }, - "torch29-cxx11-cu128-x86_64-linux": { - "hash": "sha256-64852d1194ba9c2476f3b3046148fbbfeb7adab645ef86b30dd393d4c0ba4ed0", - "hash_type": "git_lfs_concat" - }, - "torch29-cxx11-cu129-aarch64-linux": { - "hash": "sha256-c7444128e54787e1597e1d84ef221d4cf0e2cdefd11f772d8eb5ab904d8c8df0", - "hash_type": "git_lfs_concat" - }, - "torch29-cxx11-cu129-x86_64-linux": { - "hash": "sha256-6868015dc4cdc088b669f474a944a206d78f9cf427c0a35086091309cff8a3ed", - "hash_type": "git_lfs_concat" - }, - "torch29-cxx11-cu130-aarch64-linux": { - "hash": "sha256-23741b935462b53bdf868f8d1c9c8cff5f02f71ea3b0550df41dc8b030b0b474", - "hash_type": "git_lfs_concat" - }, - "torch29-cxx11-cu130-x86_64-linux": { - "hash": "sha256-2e6f47d3152c8e2a920d56f06bd635ca96210b02bde76f1cc73a7c9bf98f5e07", - "hash_type": "git_lfs_concat" - }, - "torch29-metal-aarch64-darwin": { - "hash": "sha256-9f665b54a53246a7d3627422f8a0d41d7956dc5409043dbd14c4ec0327aea310", - "hash_type": "git_lfs_concat" - } - } - }, - { - "repo_id": "kernels-community/triton-scaled-mm", - "sha": "d9d0c93d9a705edd38d446199589c5aca981e215", - "variants": { - "torch-universal": { - "hash": "sha256-b843c5f30b52b6c1c56fca28cb0cf453be71d6ce7d308f383dce71a8050f7b52", - "hash_type": "git_lfs_concat" - } - } - } -] diff --git a/tests/kernel_locking_old/pyproject.toml b/tests/kernel_locking_old/pyproject.toml deleted file mode 100644 index eeffd5aa1..000000000 --- a/tests/kernel_locking_old/pyproject.toml +++ /dev/null @@ -1,3 +0,0 @@ -[tool.kernels.dependencies] -"kernels-community/activation" = ">=0.0.2" -"kernels-community/triton-scaled-mm" = ">=0.0.2" diff --git a/tests/layer_locking_old/kernels.lock b/tests/layer_locking_old/kernels.lock deleted file mode 100644 index a85c6188a..000000000 --- a/tests/layer_locking_old/kernels.lock +++ /dev/null @@ -1,12 +0,0 @@ -[ - { - "repo_id": "kernels-test/versions", - "sha": "d3821a34bf6736bb7312025138becd4b8b2eb704", - "variants": { - "torch-universal": { - "hash": "sha256-57de77a9bde54f52d0a67eb9e5d259d223cae66963f644ed2b7386f59f7e2d23", - "hash_type": "git_lfs_concat" - } - } - } -] diff --git a/tests/layer_locking_old/pyproject.toml b/tests/layer_locking_old/pyproject.toml deleted file mode 100644 index 92a0bc11f..000000000 --- a/tests/layer_locking_old/pyproject.toml +++ /dev/null @@ -1,2 +0,0 @@ -[tool.kernels.dependencies] -"kernels-test/versions" = ">=0.1.0,<0.2.0" From 41d40a78cadb889bc72c7df181907f870d47e7ef Mon Sep 17 00:00:00 2001 From: drbh Date: Fri, 17 Apr 2026 09:59:47 -0400 Subject: [PATCH 2/3] fix: pin versions as vars --- .github/workflows/lint.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 1a39a4de2..d5844e036 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,5 +1,10 @@ name: Lints on: [push, pull_request] + +env: + RUFF_VERSION: "0.15.10" + GRIFFE_VERSION: "1.15.0" + jobs: lint: name: Run lints @@ -10,12 +15,12 @@ jobs: uses: astral-sh/ruff-action@4919ec5cf1f49eff0871dbcea0da843445b837e6 # v3 with: src: kernels - version: "0.15.10" + version: ${{ env.RUFF_VERSION }} - name: Run ruff format check uses: astral-sh/ruff-action@4919ec5cf1f49eff0871dbcea0da843445b837e6 # v3 with: src: kernels - version: "0.15.10" + version: ${{ env.RUFF_VERSION }} args: format --check griffe: @@ -32,7 +37,7 @@ jobs: with: python-version: "3.12" - name: Check for breaking changes - run: uvx griffe check kernels --search kernels/src -a main + run: uvx griffe==${{ env.GRIFFE_VERSION }} check kernels --search kernels/src -a main validate-dependencies: name: Validate python_depends.json From e99beddfc2f3dfce1b23f2e761005ab8f19ecda2 Mon Sep 17 00:00:00 2001 From: drbh Date: Fri, 17 Apr 2026 10:09:56 -0400 Subject: [PATCH 3/3] fix: remove upload tests from CI --- .github/workflows/test_kernels.yaml | 9 --------- kernels/pytest.ini | 1 - 2 files changed, 10 deletions(-) diff --git a/.github/workflows/test_kernels.yaml b/.github/workflows/test_kernels.yaml index cae9061c3..3527d1d93 100644 --- a/.github/workflows/test_kernels.yaml +++ b/.github/workflows/test_kernels.yaml @@ -72,15 +72,6 @@ jobs: uv pip install einops nvidia-cutlass-dsl uv run pytest tests/test_deps.py - - name: Run hub-ci upload tests - working-directory: ./kernels - env: - HF_HUB_DOWNLOAD_TIMEOUT: 60 - HF_ENDPOINT: https://hub-ci.huggingface.co - HF_TOKEN: ${{ secrets.HF_HUB_CI_TOKEN }} - run: | - uv run pytest --token -m "is_staging_test" tests/ - if: matrix.python-version == '3.10' && matrix.torch-version == '2.9.0' - name: Check kernel check working-directory: ./kernels diff --git a/kernels/pytest.ini b/kernels/pytest.ini index 410bac52d..a94211637 100644 --- a/kernels/pytest.ini +++ b/kernels/pytest.ini @@ -6,4 +6,3 @@ markers = xpu_only: marks tests that should only run on hosts with Intel XPUs npu_only: marks tests that should only run on Ascend NPUs token: enable tests that require a write token - is_staging_test: Marks tests that should only run on a staging environment