kernels 0.4.0__tar.gz → 0.4.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {kernels-0.4.0 → kernels-0.4.2}/PKG-INFO +1 -1
- {kernels-0.4.0 → kernels-0.4.2}/pyproject.toml +1 -1
- {kernels-0.4.0 → kernels-0.4.2}/src/kernels/__init__.py +2 -0
- {kernels-0.4.0 → kernels-0.4.2}/src/kernels/layer.py +7 -0
- {kernels-0.4.0 → kernels-0.4.2}/src/kernels/utils.py +9 -6
- {kernels-0.4.0 → kernels-0.4.2}/src/kernels.egg-info/PKG-INFO +1 -1
- {kernels-0.4.0 → kernels-0.4.2}/README.md +0 -0
- {kernels-0.4.0 → kernels-0.4.2}/setup.cfg +0 -0
- {kernels-0.4.0 → kernels-0.4.2}/src/kernels/cli.py +0 -0
- {kernels-0.4.0 → kernels-0.4.2}/src/kernels/compat.py +0 -0
- {kernels-0.4.0 → kernels-0.4.2}/src/kernels/lockfile.py +0 -0
- {kernels-0.4.0 → kernels-0.4.2}/src/kernels.egg-info/SOURCES.txt +0 -0
- {kernels-0.4.0 → kernels-0.4.2}/src/kernels.egg-info/dependency_links.txt +0 -0
- {kernels-0.4.0 → kernels-0.4.2}/src/kernels.egg-info/entry_points.txt +0 -0
- {kernels-0.4.0 → kernels-0.4.2}/src/kernels.egg-info/requires.txt +0 -0
- {kernels-0.4.0 → kernels-0.4.2}/src/kernels.egg-info/top_level.txt +0 -0
- {kernels-0.4.0 → kernels-0.4.2}/tests/test_basic.py +0 -0
- {kernels-0.4.0 → kernels-0.4.2}/tests/test_benchmarks.py +0 -0
- {kernels-0.4.0 → kernels-0.4.2}/tests/test_kernel_locking.py +0 -0
- {kernels-0.4.0 → kernels-0.4.2}/tests/test_layer.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: kernels
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.2
|
|
4
4
|
Summary: Download compute kernels
|
|
5
5
|
Author-email: OlivierDehaene <olivier@huggingface.co>, Daniel de Kok <daniel@huggingface.co>, David Holtz <david@huggingface.co>, Nicolas Patry <nicolas@huggingface.co>
|
|
6
6
|
Requires-Python: >=3.9
|
|
@@ -4,6 +4,7 @@ from kernels.layer import (
|
|
|
4
4
|
register_kernel_mapping,
|
|
5
5
|
replace_kernel_forward_from_hub,
|
|
6
6
|
use_kernel_forward_from_hub,
|
|
7
|
+
use_kernel_mapping,
|
|
7
8
|
)
|
|
8
9
|
from kernels.utils import (
|
|
9
10
|
get_kernel,
|
|
@@ -18,6 +19,7 @@ __all__ = [
|
|
|
18
19
|
"load_kernel",
|
|
19
20
|
"install_kernel",
|
|
20
21
|
"use_kernel_forward_from_hub",
|
|
22
|
+
"use_kernel_mapping",
|
|
21
23
|
"register_kernel_mapping",
|
|
22
24
|
"replace_kernel_forward_from_hub",
|
|
23
25
|
"LayerRepository",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import inspect
|
|
2
|
+
import warnings
|
|
2
3
|
from contextvars import ContextVar
|
|
3
4
|
from copy import deepcopy
|
|
4
5
|
from dataclasses import dataclass, field
|
|
@@ -132,6 +133,12 @@ def replace_kernel_forward_from_hub(cls, layer_name: str, *, use_fallback: bool
|
|
|
132
133
|
def forward(self, x, *args, **kwargs):
|
|
133
134
|
kernel = _KERNEL_MAPPING.get().get(layer_name)
|
|
134
135
|
if kernel is None:
|
|
136
|
+
warnings.warn(
|
|
137
|
+
"\n"
|
|
138
|
+
f"No kernel mapping found for layer `{layer_name}`. "
|
|
139
|
+
f"Check if the layer name matches one of the kernels in the mapping or add the kernel "
|
|
140
|
+
f"you want to use to the mapping. Defaulting to original forward implementation."
|
|
141
|
+
)
|
|
135
142
|
if not use_fallback:
|
|
136
143
|
raise ValueError(f"No layer mapping for `{layer_name}`")
|
|
137
144
|
return fallback_forward(self, x, *args, **kwargs)
|
|
@@ -23,18 +23,21 @@ CACHE_DIR: Optional[str] = os.environ.get("HF_KERNELS_CACHE", None)
|
|
|
23
23
|
def build_variant() -> str:
|
|
24
24
|
import torch
|
|
25
25
|
|
|
26
|
-
if torch.version.cuda is None:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
if torch.version.cuda is not None:
|
|
27
|
+
cuda_version = parse(torch.version.cuda)
|
|
28
|
+
compute_framework = f"cu{cuda_version.major}{cuda_version.minor}"
|
|
29
|
+
elif torch.version.hip is not None:
|
|
30
|
+
rocm_version = parse(torch.version.hip.split("-")[0])
|
|
31
|
+
compute_framework = f"rocm{rocm_version.major}{rocm_version.minor}"
|
|
32
|
+
else:
|
|
33
|
+
raise AssertionError("Torch was not compiled with CUDA or ROCm enabled.")
|
|
30
34
|
|
|
31
35
|
torch_version = parse(torch.__version__)
|
|
32
|
-
cuda_version = parse(torch.version.cuda)
|
|
33
36
|
cxxabi = "cxx11" if torch.compiled_with_cxx11_abi() else "cxx98"
|
|
34
37
|
cpu = platform.machine()
|
|
35
38
|
os = platform.system().lower()
|
|
36
39
|
|
|
37
|
-
return f"torch{torch_version.major}{torch_version.minor}-{cxxabi}-
|
|
40
|
+
return f"torch{torch_version.major}{torch_version.minor}-{cxxabi}-{compute_framework}-{cpu}-{os}"
|
|
38
41
|
|
|
39
42
|
|
|
40
43
|
def universal_build_variant() -> str:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: kernels
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.2
|
|
4
4
|
Summary: Download compute kernels
|
|
5
5
|
Author-email: OlivierDehaene <olivier@huggingface.co>, Daniel de Kok <daniel@huggingface.co>, David Holtz <david@huggingface.co>, Nicolas Patry <nicolas@huggingface.co>
|
|
6
6
|
Requires-Python: >=3.9
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|