adarshxs HF Staff commited on
Commit
bd34069
·
verified ·
1 Parent(s): f80539e

Add files using upload-large-folder tool

Browse files
.gitattributes CHANGED
@@ -35,3 +35,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
  torch210-cxx11-cpu-x86_64-linux/_stdlib_repro_cpu_1e7c8a4.abi3.so filter=lfs diff=lfs merge=lfs -text
37
  torch211-cxx11-cpu-x86_64-linux/_stdlib_repro_cpu_1e7c8a4.abi3.so filter=lfs diff=lfs merge=lfs -text
 
 
 
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
  torch210-cxx11-cpu-x86_64-linux/_stdlib_repro_cpu_1e7c8a4.abi3.so filter=lfs diff=lfs merge=lfs -text
37
  torch211-cxx11-cpu-x86_64-linux/_stdlib_repro_cpu_1e7c8a4.abi3.so filter=lfs diff=lfs merge=lfs -text
38
+ build/torch210-cxx11-cpu-x86_64-linux/_stdlib_repro_cpu_1e7c8a4.abi3.so filter=lfs diff=lfs merge=lfs -text
39
+ build/torch211-cxx11-cpu-x86_64-linux/_stdlib_repro_cpu_1e7c8a4.abi3.so filter=lfs diff=lfs merge=lfs -text
build/CARD.md ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: kernels
3
+ license: apache-2.0
4
+ ---
5
+
6
+ This is a tiny Kernel Hub repro for C++ standard-library runtime crashes in packaged kernels.
7
+
8
+ It exposes a CPU op that runs:
9
+
10
+ - `std::regex` include parsing
11
+ - `std::ostringstream`/`std::hex` hash formatting
12
+ - a simple ReLU copy so the op has a normal tensor path
13
+
14
+ ## How to use
15
+
16
+ ```python
17
+ from kernels import get_kernel
18
+
19
+ kernel_module = get_kernel("adarshxs/stdlib-repro", backend="cpu", trust_remote_code=True)
20
+ out, digest = kernel_module.relu_and_probe(x, iters=1000)
21
+ ```
22
+
23
+ ## Available functions
24
+ - `DEFAULT_CODE`
25
+ - `probe_stdlib`
26
+ - `relu_and_probe`
build/torch210-cxx11-cpu-x86_64-linux/__init__.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from typing import Optional
4
+
5
+ import torch
6
+
7
+ from ._ops import ops
8
+
9
+ DEFAULT_CODE = """\
10
+ #include <deep_gemm/impls/smxx_layout.cuh>
11
+ #include <deep_gemm/common/compile.cuh>
12
+ #include <cutlass/detail/helper_macros.hpp>
13
+ #include "local_header.cuh"
14
+ """
15
+
16
+
17
+ def relu_and_probe(
18
+ x: torch.Tensor,
19
+ *,
20
+ code: str = DEFAULT_CODE,
21
+ iters: int = 1000,
22
+ out: Optional[torch.Tensor] = None,
23
+ ) -> tuple[torch.Tensor, str]:
24
+ if out is None:
25
+ out = torch.empty_like(x)
26
+ digest = ops.relu_and_probe(out, x, code, iters)
27
+ return out, digest
28
+
29
+
30
+ def probe_stdlib(*, code: str = DEFAULT_CODE, iters: int = 1000) -> str:
31
+ x = torch.tensor([-1.0, 0.0, 2.0], dtype=torch.float32)
32
+ _, digest = relu_and_probe(x, code=code, iters=iters)
33
+ return digest
34
+
35
+
36
+ __all__ = ["DEFAULT_CODE", "probe_stdlib", "relu_and_probe"]
build/torch210-cxx11-cpu-x86_64-linux/_ops.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from . import _stdlib_repro_cpu_1e7c8a4
3
+ ops = torch.ops._stdlib_repro_cpu_1e7c8a4
4
+
5
+ def add_op_namespace_prefix(op_name: str):
6
+ """
7
+ Prefix op by namespace.
8
+ """
9
+ return f"_stdlib_repro_cpu_1e7c8a4::{op_name}"
build/torch210-cxx11-cpu-x86_64-linux/_stdlib_repro_cpu_1e7c8a4.abi3.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5dc04c34b6e4607170f612c92424088e2c0583279ad84bb2561e5876dd972b44
3
+ size 1989000
build/torch210-cxx11-cpu-x86_64-linux/metadata.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "stdlib-repro",
3
+ "id": "_stdlib_repro_cpu_1e7c8a4",
4
+ "version": 1,
5
+ "license": "Apache-2.0",
6
+ "python-depends": [],
7
+ "backend": {
8
+ "type": "cpu"
9
+ }
10
+ }
build/torch210-cxx11-cpu-x86_64-linux/stdlib_repro/__init__.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ctypes
2
+ import importlib.util
3
+ import sys
4
+ from pathlib import Path
5
+ from types import ModuleType
6
+
7
+
8
+ def _import_from_path(file_path: Path) -> ModuleType:
9
+ # We cannot use the module name as-is, after adding it to `sys.modules`,
10
+ # it would also be used for other imports. So, we make a module name that
11
+ # depends on the path for it to be unique using the hex-encoded hash of
12
+ # the path.
13
+ path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value)
14
+ module_name = path_hash
15
+ spec = importlib.util.spec_from_file_location(module_name, file_path)
16
+ if spec is None:
17
+ raise ImportError(f"Cannot load spec for {module_name} from {file_path}")
18
+ module = importlib.util.module_from_spec(spec)
19
+ if module is None:
20
+ raise ImportError(f"Cannot load module {module_name} from spec")
21
+ sys.modules[module_name] = module
22
+ spec.loader.exec_module(module) # type: ignore
23
+ return module
24
+
25
+
26
+ globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py")))
build/torch211-cxx11-cpu-x86_64-linux/__init__.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from typing import Optional
4
+
5
+ import torch
6
+
7
+ from ._ops import ops
8
+
9
+ DEFAULT_CODE = """\
10
+ #include <deep_gemm/impls/smxx_layout.cuh>
11
+ #include <deep_gemm/common/compile.cuh>
12
+ #include <cutlass/detail/helper_macros.hpp>
13
+ #include "local_header.cuh"
14
+ """
15
+
16
+
17
+ def relu_and_probe(
18
+ x: torch.Tensor,
19
+ *,
20
+ code: str = DEFAULT_CODE,
21
+ iters: int = 1000,
22
+ out: Optional[torch.Tensor] = None,
23
+ ) -> tuple[torch.Tensor, str]:
24
+ if out is None:
25
+ out = torch.empty_like(x)
26
+ digest = ops.relu_and_probe(out, x, code, iters)
27
+ return out, digest
28
+
29
+
30
+ def probe_stdlib(*, code: str = DEFAULT_CODE, iters: int = 1000) -> str:
31
+ x = torch.tensor([-1.0, 0.0, 2.0], dtype=torch.float32)
32
+ _, digest = relu_and_probe(x, code=code, iters=iters)
33
+ return digest
34
+
35
+
36
+ __all__ = ["DEFAULT_CODE", "probe_stdlib", "relu_and_probe"]
build/torch211-cxx11-cpu-x86_64-linux/_ops.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from . import _stdlib_repro_cpu_1e7c8a4
3
+ ops = torch.ops._stdlib_repro_cpu_1e7c8a4
4
+
5
+ def add_op_namespace_prefix(op_name: str):
6
+ """
7
+ Prefix op by namespace.
8
+ """
9
+ return f"_stdlib_repro_cpu_1e7c8a4::{op_name}"
build/torch211-cxx11-cpu-x86_64-linux/_stdlib_repro_cpu_1e7c8a4.abi3.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3cfb30a15e55aff2a0f3ed7a12ea2640d2788f208f0b3291b857f71adb8b4b6c
3
+ size 1989000
build/torch211-cxx11-cpu-x86_64-linux/metadata.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "stdlib-repro",
3
+ "id": "_stdlib_repro_cpu_1e7c8a4",
4
+ "version": 1,
5
+ "license": "Apache-2.0",
6
+ "python-depends": [],
7
+ "backend": {
8
+ "type": "cpu"
9
+ }
10
+ }
build/torch211-cxx11-cpu-x86_64-linux/stdlib_repro/__init__.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ctypes
2
+ import importlib.util
3
+ import sys
4
+ from pathlib import Path
5
+ from types import ModuleType
6
+
7
+
8
+ def _import_from_path(file_path: Path) -> ModuleType:
9
+ # We cannot use the module name as-is, after adding it to `sys.modules`,
10
+ # it would also be used for other imports. So, we make a module name that
11
+ # depends on the path for it to be unique using the hex-encoded hash of
12
+ # the path.
13
+ path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value)
14
+ module_name = path_hash
15
+ spec = importlib.util.spec_from_file_location(module_name, file_path)
16
+ if spec is None:
17
+ raise ImportError(f"Cannot load spec for {module_name} from {file_path}")
18
+ module = importlib.util.module_from_spec(spec)
19
+ if module is None:
20
+ raise ImportError(f"Cannot load module {module_name} from spec")
21
+ sys.modules[module_name] = module
22
+ spec.loader.exec_module(module) # type: ignore
23
+ return module
24
+
25
+
26
+ globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py")))