kernels 0.3.2__tar.gz → 0.4.0__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.
@@ -1,13 +1,13 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.1
2
2
  Name: kernels
3
- Version: 0.3.2
3
+ Version: 0.4.0
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
7
7
  Description-Content-Type: text/markdown
8
- Requires-Dist: huggingface-hub>=0.26.3
9
- Requires-Dist: packaging>=24.2
10
- Requires-Dist: tomli>=2.0.1; python_version < "3.11"
8
+ Requires-Dist: huggingface_hub<1.0,>=0.26.0
9
+ Requires-Dist: packaging>=20.0
10
+ Requires-Dist: tomli>=2.0; python_version < "3.11"
11
11
  Provides-Extra: torch
12
12
  Requires-Dist: torch; extra == "torch"
13
13
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "kernels"
3
- version = "0.3.2"
3
+ version = "0.4.0"
4
4
  description = "Download compute kernels"
5
5
  authors = [
6
6
  { name = "OlivierDehaene", email = "olivier@huggingface.co" },
@@ -11,9 +11,9 @@ authors = [
11
11
  readme = "README.md"
12
12
  requires-python = ">= 3.9"
13
13
  dependencies = [
14
- "huggingface-hub>=0.26.3",
15
- "packaging>=24.2",
16
- "tomli>=2.0.1; python_version<'3.11'",
14
+ "huggingface_hub>=0.26.0,<1.0",
15
+ "packaging>=20.0",
16
+ "tomli>=2.0; python_version<'3.11'",
17
17
  ]
18
18
 
19
19
  [build-system]
@@ -54,11 +54,26 @@ _KERNEL_MAPPING: ContextVar[Dict[str, Dict[Device, LayerRepository]]] = ContextV
54
54
  )
55
55
 
56
56
 
57
- def use_kernel_mapping(mapping: Dict[str, Dict[Union[Device, str], LayerRepository]]):
57
+ def use_kernel_mapping(
58
+ mapping: Dict[str, Dict[Union[Device, str], LayerRepository]],
59
+ *,
60
+ inherit_mapping: bool = True,
61
+ ):
62
+ """
63
+ Context manager that sets a mapping for a duration of the context.
64
+
65
+ When `inherit_mapping` is set to `True` the current mapping will be
66
+ extended by `mapping` inside the context. If it is `False`, only
67
+ `mapping` is used inside the context.
68
+ """
69
+
58
70
  class ContextManager:
59
71
  def __enter__(self):
60
72
  # Mappings always stack on previous mappings.
61
- self.token = _KERNEL_MAPPING.set(deepcopy(_KERNEL_MAPPING.get()))
73
+ if inherit_mapping:
74
+ self.token = _KERNEL_MAPPING.set(deepcopy(_KERNEL_MAPPING.get()))
75
+ else:
76
+ self.token = _KERNEL_MAPPING.set({})
62
77
  register_kernel_mapping(mapping)
63
78
 
64
79
  def __exit__(self, exc_type, exc_value, traceback):
@@ -1,13 +1,13 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.1
2
2
  Name: kernels
3
- Version: 0.3.2
3
+ Version: 0.4.0
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
7
7
  Description-Content-Type: text/markdown
8
- Requires-Dist: huggingface-hub>=0.26.3
9
- Requires-Dist: packaging>=24.2
10
- Requires-Dist: tomli>=2.0.1; python_version < "3.11"
8
+ Requires-Dist: huggingface_hub<1.0,>=0.26.0
9
+ Requires-Dist: packaging>=20.0
10
+ Requires-Dist: tomli>=2.0; python_version < "3.11"
11
11
  Provides-Extra: torch
12
12
  Requires-Dist: torch; extra == "torch"
13
13
 
@@ -0,0 +1,8 @@
1
+ huggingface_hub<1.0,>=0.26.0
2
+ packaging>=20.0
3
+
4
+ [:python_version < "3.11"]
5
+ tomli>=2.0
6
+
7
+ [torch]
8
+ torch
@@ -152,6 +152,25 @@ def test_mapping_contexts():
152
152
  == "kernels-community/activation"
153
153
  )
154
154
 
155
+ with use_kernel_mapping(extra_mapping2, inherit_mapping=False):
156
+ assert set(_KERNEL_MAPPING.get().keys()) == {
157
+ "SiluAndMul",
158
+ }
159
+ assert (
160
+ _KERNEL_MAPPING.get()["SiluAndMul"][Device(type="cuda")].repo_id
161
+ == "kernels-community/non-existing"
162
+ )
163
+
164
+ assert set(_KERNEL_MAPPING.get().keys()) == {
165
+ "SiluAndMul",
166
+ "SiluAndMulStringDevice",
167
+ "TestKernel",
168
+ }
169
+ assert (
170
+ _KERNEL_MAPPING.get()["SiluAndMul"][Device(type="cuda")].repo_id
171
+ == "kernels-community/activation"
172
+ )
173
+
155
174
  assert set(_KERNEL_MAPPING.get().keys()) == {
156
175
  "SiluAndMul",
157
176
  "SiluAndMulStringDevice",
@@ -1,8 +0,0 @@
1
- huggingface-hub>=0.26.3
2
- packaging>=24.2
3
-
4
- [:python_version < "3.11"]
5
- tomli>=2.0.1
6
-
7
- [torch]
8
- torch
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes