Kernels
danieldk HF Staff commited on
Commit
254c86e
·
verified ·
1 Parent(s): 74d778e

Build uploaded using `kernels`.

Browse files
Files changed (36) hide show
  1. build/torch210-cxx11-cu126-aarch64-linux/__init__.py +52 -0
  2. build/{torch29-cxx11-cu128-aarch64-linux/rotary → torch210-cxx11-cu126-aarch64-linux}/_ops.py +3 -3
  3. build/{torch29-cxx11-cu130-aarch64-linux/rotary/_rotary_6abd2a8.abi3.so → torch210-cxx11-cu126-aarch64-linux/_rotary_cuda_4e81b67.abi3.so} +2 -2
  4. build/torch210-cxx11-cu126-aarch64-linux/metadata.json +18 -0
  5. build/torch210-cxx11-cu126-aarch64-linux/rotary/__init__.py +26 -0
  6. build/torch210-cxx11-cu128-aarch64-linux/__init__.py +52 -0
  7. build/{torch29-cxx11-cu130-aarch64-linux/rotary → torch210-cxx11-cu128-aarch64-linux}/_ops.py +3 -3
  8. build/{torch29-cxx11-cu128-aarch64-linux/rotary/_rotary_6abd2a8.abi3.so → torch210-cxx11-cu128-aarch64-linux/_rotary_cuda_4e81b67.abi3.so} +2 -2
  9. build/torch210-cxx11-cu128-aarch64-linux/metadata.json +21 -0
  10. build/torch210-cxx11-cu128-aarch64-linux/rotary/__init__.py +26 -0
  11. build/torch210-cxx11-cu130-aarch64-linux/__init__.py +52 -0
  12. build/{torch29-cxx11-cu126-aarch64-linux/rotary → torch210-cxx11-cu130-aarch64-linux}/_ops.py +3 -3
  13. build/torch210-cxx11-cu130-aarch64-linux/_rotary_cuda_4e81b67.abi3.so +3 -0
  14. build/torch210-cxx11-cu130-aarch64-linux/metadata.json +19 -0
  15. build/torch210-cxx11-cu130-aarch64-linux/rotary/__init__.py +26 -0
  16. build/torch29-cxx11-cu126-aarch64-linux/__init__.py +52 -0
  17. build/torch29-cxx11-cu126-aarch64-linux/_ops.py +9 -0
  18. build/torch29-cxx11-cu126-aarch64-linux/{rotary/_rotary_6abd2a8.abi3.so → _rotary_cuda_4e81b67.abi3.so} +2 -2
  19. build/torch29-cxx11-cu126-aarch64-linux/metadata.json +18 -0
  20. build/torch29-cxx11-cu126-aarch64-linux/rotary/__init__.py +22 -15
  21. build/torch29-cxx11-cu126-aarch64-linux/rotary/__pycache__/__init__.cpython-313.pyc +0 -0
  22. build/torch29-cxx11-cu126-aarch64-linux/rotary/__pycache__/_ops.cpython-313.pyc +0 -0
  23. build/torch29-cxx11-cu128-aarch64-linux/__init__.py +52 -0
  24. build/torch29-cxx11-cu128-aarch64-linux/_ops.py +9 -0
  25. build/torch29-cxx11-cu128-aarch64-linux/_rotary_cuda_4e81b67.abi3.so +3 -0
  26. build/torch29-cxx11-cu128-aarch64-linux/metadata.json +21 -0
  27. build/torch29-cxx11-cu128-aarch64-linux/rotary/__init__.py +22 -15
  28. build/torch29-cxx11-cu128-aarch64-linux/rotary/__pycache__/__init__.cpython-313.pyc +0 -0
  29. build/torch29-cxx11-cu128-aarch64-linux/rotary/__pycache__/_ops.cpython-313.pyc +0 -0
  30. build/torch29-cxx11-cu130-aarch64-linux/__init__.py +52 -0
  31. build/torch29-cxx11-cu130-aarch64-linux/_ops.py +9 -0
  32. build/torch29-cxx11-cu130-aarch64-linux/_rotary_cuda_4e81b67.abi3.so +3 -0
  33. build/torch29-cxx11-cu130-aarch64-linux/metadata.json +19 -0
  34. build/torch29-cxx11-cu130-aarch64-linux/rotary/__init__.py +22 -15
  35. build/torch29-cxx11-cu130-aarch64-linux/rotary/__pycache__/__init__.cpython-313.pyc +0 -0
  36. build/torch29-cxx11-cu130-aarch64-linux/rotary/__pycache__/_ops.cpython-313.pyc +0 -0
build/torch210-cxx11-cu126-aarch64-linux/__init__.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Optional, Tuple
2
+ import torch
3
+
4
+ from ._ops import ops
5
+
6
+
7
+ def apply_rotary(
8
+ x1: torch.Tensor,
9
+ x2: torch.Tensor,
10
+ cos: torch.Tensor,
11
+ sin: torch.Tensor,
12
+ out1: torch.Tensor,
13
+ out2: torch.Tensor,
14
+ conj: bool,
15
+ ) -> None:
16
+ ops.apply_rotary(x1, x2, cos, sin, out1, out2, conj)
17
+
18
+
19
+ def apply_rotary_transformers(
20
+ q: torch.Tensor,
21
+ k: torch.Tensor,
22
+ cos: torch.Tensor,
23
+ sin: torch.Tensor,
24
+ unsqueeze_dim: int = 1,
25
+ ) -> Tuple[torch.Tensor, torch.Tensor]:
26
+ """
27
+ Rotary kernel implementation wrapper
28
+ Adapts rotary kernel implementation to match transformers apply_rotary_pos_emb signature
29
+ """
30
+ cos = cos.unsqueeze(unsqueeze_dim)
31
+ sin = sin.unsqueeze(unsqueeze_dim)
32
+
33
+ q_rotated = q.clone()
34
+ k_rotated = k.clone()
35
+
36
+ # Get half dimension for rotation
37
+ half_dim = q.shape[-1] // 2
38
+ q1 = q_rotated[..., :half_dim]
39
+ q2 = q_rotated[..., half_dim:]
40
+ k1 = k_rotated[..., :half_dim]
41
+ k2 = k_rotated[..., half_dim:]
42
+ if cos.shape[-1] != half_dim:
43
+ # Trim cos/sin to match half_dim
44
+ cos = cos[..., :half_dim]
45
+ sin = sin[..., :half_dim]
46
+
47
+ apply_rotary(q1, q2, cos, sin, q1, q2, False)
48
+ apply_rotary(k1, k2, cos, sin, k1, k2, False)
49
+ return q_rotated, k_rotated
50
+
51
+
52
+ __all__ = ["apply_rotary", "apply_rotary_transformers"]
build/{torch29-cxx11-cu128-aarch64-linux/rotary → torch210-cxx11-cu126-aarch64-linux}/_ops.py RENAMED
@@ -1,9 +1,9 @@
1
  import torch
2
- from . import _rotary_6abd2a8
3
- ops = torch.ops._rotary_6abd2a8
4
 
5
  def add_op_namespace_prefix(op_name: str):
6
  """
7
  Prefix op by namespace.
8
  """
9
- return f"_rotary_6abd2a8::{op_name}"
 
1
  import torch
2
+ from . import _rotary_cuda_4e81b67
3
+ ops = torch.ops._rotary_cuda_4e81b67
4
 
5
  def add_op_namespace_prefix(op_name: str):
6
  """
7
  Prefix op by namespace.
8
  """
9
+ return f"_rotary_cuda_4e81b67::{op_name}"
build/{torch29-cxx11-cu130-aarch64-linux/rotary/_rotary_6abd2a8.abi3.so → torch210-cxx11-cu126-aarch64-linux/_rotary_cuda_4e81b67.abi3.so} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:53bf19b8a4260ba1807b36f0f6559b9b49aeb0954549e370632c1268dea360b7
3
- size 9688688
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:96d0a5e59987c44884005201053f361b0401019b2785c706ec67894a6d47486b
3
+ size 8282888
build/torch210-cxx11-cu126-aarch64-linux/metadata.json ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": 1,
3
+ "license": "BSD-3-Clause",
4
+ "python-depends": [],
5
+ "backend": {
6
+ "type": "cuda",
7
+ "archs": [
8
+ "7.0",
9
+ "7.2",
10
+ "7.5",
11
+ "8.0",
12
+ "8.6",
13
+ "8.7",
14
+ "8.9",
15
+ "9.0+PTX"
16
+ ]
17
+ }
18
+ }
build/torch210-cxx11-cu126-aarch64-linux/rotary/__init__.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ctypes
2
+ import sys
3
+
4
+ import importlib
5
+ from pathlib import Path
6
+ from types import ModuleType
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/torch210-cxx11-cu128-aarch64-linux/__init__.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Optional, Tuple
2
+ import torch
3
+
4
+ from ._ops import ops
5
+
6
+
7
+ def apply_rotary(
8
+ x1: torch.Tensor,
9
+ x2: torch.Tensor,
10
+ cos: torch.Tensor,
11
+ sin: torch.Tensor,
12
+ out1: torch.Tensor,
13
+ out2: torch.Tensor,
14
+ conj: bool,
15
+ ) -> None:
16
+ ops.apply_rotary(x1, x2, cos, sin, out1, out2, conj)
17
+
18
+
19
+ def apply_rotary_transformers(
20
+ q: torch.Tensor,
21
+ k: torch.Tensor,
22
+ cos: torch.Tensor,
23
+ sin: torch.Tensor,
24
+ unsqueeze_dim: int = 1,
25
+ ) -> Tuple[torch.Tensor, torch.Tensor]:
26
+ """
27
+ Rotary kernel implementation wrapper
28
+ Adapts rotary kernel implementation to match transformers apply_rotary_pos_emb signature
29
+ """
30
+ cos = cos.unsqueeze(unsqueeze_dim)
31
+ sin = sin.unsqueeze(unsqueeze_dim)
32
+
33
+ q_rotated = q.clone()
34
+ k_rotated = k.clone()
35
+
36
+ # Get half dimension for rotation
37
+ half_dim = q.shape[-1] // 2
38
+ q1 = q_rotated[..., :half_dim]
39
+ q2 = q_rotated[..., half_dim:]
40
+ k1 = k_rotated[..., :half_dim]
41
+ k2 = k_rotated[..., half_dim:]
42
+ if cos.shape[-1] != half_dim:
43
+ # Trim cos/sin to match half_dim
44
+ cos = cos[..., :half_dim]
45
+ sin = sin[..., :half_dim]
46
+
47
+ apply_rotary(q1, q2, cos, sin, q1, q2, False)
48
+ apply_rotary(k1, k2, cos, sin, k1, k2, False)
49
+ return q_rotated, k_rotated
50
+
51
+
52
+ __all__ = ["apply_rotary", "apply_rotary_transformers"]
build/{torch29-cxx11-cu130-aarch64-linux/rotary → torch210-cxx11-cu128-aarch64-linux}/_ops.py RENAMED
@@ -1,9 +1,9 @@
1
  import torch
2
- from . import _rotary_6abd2a8
3
- ops = torch.ops._rotary_6abd2a8
4
 
5
  def add_op_namespace_prefix(op_name: str):
6
  """
7
  Prefix op by namespace.
8
  """
9
- return f"_rotary_6abd2a8::{op_name}"
 
1
  import torch
2
+ from . import _rotary_cuda_4e81b67
3
+ ops = torch.ops._rotary_cuda_4e81b67
4
 
5
  def add_op_namespace_prefix(op_name: str):
6
  """
7
  Prefix op by namespace.
8
  """
9
+ return f"_rotary_cuda_4e81b67::{op_name}"
build/{torch29-cxx11-cu128-aarch64-linux/rotary/_rotary_6abd2a8.abi3.so → torch210-cxx11-cu128-aarch64-linux/_rotary_cuda_4e81b67.abi3.so} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:7ba1a791e97b5293c4ce2c108f8616c0d4a85d0e862025823ed87fe20c8810d0
3
- size 10640216
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ab263061113a2ecdbbbf05224936586bb133d586958dd83e09074413034a0b31
3
+ size 12019200
build/torch210-cxx11-cu128-aarch64-linux/metadata.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": 1,
3
+ "license": "BSD-3-Clause",
4
+ "python-depends": [],
5
+ "backend": {
6
+ "type": "cuda",
7
+ "archs": [
8
+ "10.0",
9
+ "10.1",
10
+ "12.0+PTX",
11
+ "7.0",
12
+ "7.2",
13
+ "7.5",
14
+ "8.0",
15
+ "8.6",
16
+ "8.7",
17
+ "8.9",
18
+ "9.0"
19
+ ]
20
+ }
21
+ }
build/torch210-cxx11-cu128-aarch64-linux/rotary/__init__.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ctypes
2
+ import sys
3
+
4
+ import importlib
5
+ from pathlib import Path
6
+ from types import ModuleType
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/torch210-cxx11-cu130-aarch64-linux/__init__.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Optional, Tuple
2
+ import torch
3
+
4
+ from ._ops import ops
5
+
6
+
7
+ def apply_rotary(
8
+ x1: torch.Tensor,
9
+ x2: torch.Tensor,
10
+ cos: torch.Tensor,
11
+ sin: torch.Tensor,
12
+ out1: torch.Tensor,
13
+ out2: torch.Tensor,
14
+ conj: bool,
15
+ ) -> None:
16
+ ops.apply_rotary(x1, x2, cos, sin, out1, out2, conj)
17
+
18
+
19
+ def apply_rotary_transformers(
20
+ q: torch.Tensor,
21
+ k: torch.Tensor,
22
+ cos: torch.Tensor,
23
+ sin: torch.Tensor,
24
+ unsqueeze_dim: int = 1,
25
+ ) -> Tuple[torch.Tensor, torch.Tensor]:
26
+ """
27
+ Rotary kernel implementation wrapper
28
+ Adapts rotary kernel implementation to match transformers apply_rotary_pos_emb signature
29
+ """
30
+ cos = cos.unsqueeze(unsqueeze_dim)
31
+ sin = sin.unsqueeze(unsqueeze_dim)
32
+
33
+ q_rotated = q.clone()
34
+ k_rotated = k.clone()
35
+
36
+ # Get half dimension for rotation
37
+ half_dim = q.shape[-1] // 2
38
+ q1 = q_rotated[..., :half_dim]
39
+ q2 = q_rotated[..., half_dim:]
40
+ k1 = k_rotated[..., :half_dim]
41
+ k2 = k_rotated[..., half_dim:]
42
+ if cos.shape[-1] != half_dim:
43
+ # Trim cos/sin to match half_dim
44
+ cos = cos[..., :half_dim]
45
+ sin = sin[..., :half_dim]
46
+
47
+ apply_rotary(q1, q2, cos, sin, q1, q2, False)
48
+ apply_rotary(k1, k2, cos, sin, k1, k2, False)
49
+ return q_rotated, k_rotated
50
+
51
+
52
+ __all__ = ["apply_rotary", "apply_rotary_transformers"]
build/{torch29-cxx11-cu126-aarch64-linux/rotary → torch210-cxx11-cu130-aarch64-linux}/_ops.py RENAMED
@@ -1,9 +1,9 @@
1
  import torch
2
- from . import _rotary_6abd2a8
3
- ops = torch.ops._rotary_6abd2a8
4
 
5
  def add_op_namespace_prefix(op_name: str):
6
  """
7
  Prefix op by namespace.
8
  """
9
- return f"_rotary_6abd2a8::{op_name}"
 
1
  import torch
2
+ from . import _rotary_cuda_4e81b67
3
+ ops = torch.ops._rotary_cuda_4e81b67
4
 
5
  def add_op_namespace_prefix(op_name: str):
6
  """
7
  Prefix op by namespace.
8
  """
9
+ return f"_rotary_cuda_4e81b67::{op_name}"
build/torch210-cxx11-cu130-aarch64-linux/_rotary_cuda_4e81b67.abi3.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ef4f0e8c6ea30aad380796386ad0463128958b0b378fad0a28354a86a8e10246
3
+ size 10411432
build/torch210-cxx11-cu130-aarch64-linux/metadata.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": 1,
3
+ "license": "BSD-3-Clause",
4
+ "python-depends": [],
5
+ "backend": {
6
+ "type": "cuda",
7
+ "archs": [
8
+ "10.0",
9
+ "11.0",
10
+ "12.0+PTX",
11
+ "7.5",
12
+ "8.0",
13
+ "8.6",
14
+ "8.7",
15
+ "8.9",
16
+ "9.0"
17
+ ]
18
+ }
19
+ }
build/torch210-cxx11-cu130-aarch64-linux/rotary/__init__.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ctypes
2
+ import sys
3
+
4
+ import importlib
5
+ from pathlib import Path
6
+ from types import ModuleType
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/torch29-cxx11-cu126-aarch64-linux/__init__.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Optional, Tuple
2
+ import torch
3
+
4
+ from ._ops import ops
5
+
6
+
7
+ def apply_rotary(
8
+ x1: torch.Tensor,
9
+ x2: torch.Tensor,
10
+ cos: torch.Tensor,
11
+ sin: torch.Tensor,
12
+ out1: torch.Tensor,
13
+ out2: torch.Tensor,
14
+ conj: bool,
15
+ ) -> None:
16
+ ops.apply_rotary(x1, x2, cos, sin, out1, out2, conj)
17
+
18
+
19
+ def apply_rotary_transformers(
20
+ q: torch.Tensor,
21
+ k: torch.Tensor,
22
+ cos: torch.Tensor,
23
+ sin: torch.Tensor,
24
+ unsqueeze_dim: int = 1,
25
+ ) -> Tuple[torch.Tensor, torch.Tensor]:
26
+ """
27
+ Rotary kernel implementation wrapper
28
+ Adapts rotary kernel implementation to match transformers apply_rotary_pos_emb signature
29
+ """
30
+ cos = cos.unsqueeze(unsqueeze_dim)
31
+ sin = sin.unsqueeze(unsqueeze_dim)
32
+
33
+ q_rotated = q.clone()
34
+ k_rotated = k.clone()
35
+
36
+ # Get half dimension for rotation
37
+ half_dim = q.shape[-1] // 2
38
+ q1 = q_rotated[..., :half_dim]
39
+ q2 = q_rotated[..., half_dim:]
40
+ k1 = k_rotated[..., :half_dim]
41
+ k2 = k_rotated[..., half_dim:]
42
+ if cos.shape[-1] != half_dim:
43
+ # Trim cos/sin to match half_dim
44
+ cos = cos[..., :half_dim]
45
+ sin = sin[..., :half_dim]
46
+
47
+ apply_rotary(q1, q2, cos, sin, q1, q2, False)
48
+ apply_rotary(k1, k2, cos, sin, k1, k2, False)
49
+ return q_rotated, k_rotated
50
+
51
+
52
+ __all__ = ["apply_rotary", "apply_rotary_transformers"]
build/torch29-cxx11-cu126-aarch64-linux/_ops.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from . import _rotary_cuda_4e81b67
3
+ ops = torch.ops._rotary_cuda_4e81b67
4
+
5
+ def add_op_namespace_prefix(op_name: str):
6
+ """
7
+ Prefix op by namespace.
8
+ """
9
+ return f"_rotary_cuda_4e81b67::{op_name}"
build/torch29-cxx11-cu126-aarch64-linux/{rotary/_rotary_6abd2a8.abi3.so → _rotary_cuda_4e81b67.abi3.so} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:5989f8b6f24625e8d23b888fb833d7c00ada8a4cfee0708868a45c63562d7f3e
3
- size 6904016
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0dba12829865f9420696f7d05da5c56518fbb55d932e8acc1eb271be97ee1acf
3
+ size 8280552
build/torch29-cxx11-cu126-aarch64-linux/metadata.json ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": 1,
3
+ "license": "BSD-3-Clause",
4
+ "python-depends": [],
5
+ "backend": {
6
+ "type": "cuda",
7
+ "archs": [
8
+ "7.0",
9
+ "7.2",
10
+ "7.5",
11
+ "8.0",
12
+ "8.6",
13
+ "8.7",
14
+ "8.9",
15
+ "9.0+PTX"
16
+ ]
17
+ }
18
+ }
build/torch29-cxx11-cu126-aarch64-linux/rotary/__init__.py CHANGED
@@ -1,19 +1,26 @@
1
- from typing import Tuple
2
- import torch
3
 
4
- from ._ops import ops
 
 
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
- def apply_rotary(
8
- x1: torch.Tensor,
9
- x2: torch.Tensor,
10
- cos: torch.Tensor,
11
- sin: torch.Tensor,
12
- out1: torch.Tensor,
13
- out2: torch.Tensor,
14
- conj: bool,
15
- ):
16
- ops.apply_rotary(x1, x2, cos, sin, out1, out2, conj)
17
 
18
-
19
- __all__ = ["apply_rotary"]
 
1
+ import ctypes
2
+ import sys
3
 
4
+ import importlib
5
+ from pathlib import Path
6
+ from types import ModuleType
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/torch29-cxx11-cu126-aarch64-linux/rotary/__pycache__/__init__.cpython-313.pyc DELETED
Binary file (813 Bytes)
 
build/torch29-cxx11-cu126-aarch64-linux/rotary/__pycache__/_ops.cpython-313.pyc DELETED
Binary file (515 Bytes)
 
build/torch29-cxx11-cu128-aarch64-linux/__init__.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Optional, Tuple
2
+ import torch
3
+
4
+ from ._ops import ops
5
+
6
+
7
+ def apply_rotary(
8
+ x1: torch.Tensor,
9
+ x2: torch.Tensor,
10
+ cos: torch.Tensor,
11
+ sin: torch.Tensor,
12
+ out1: torch.Tensor,
13
+ out2: torch.Tensor,
14
+ conj: bool,
15
+ ) -> None:
16
+ ops.apply_rotary(x1, x2, cos, sin, out1, out2, conj)
17
+
18
+
19
+ def apply_rotary_transformers(
20
+ q: torch.Tensor,
21
+ k: torch.Tensor,
22
+ cos: torch.Tensor,
23
+ sin: torch.Tensor,
24
+ unsqueeze_dim: int = 1,
25
+ ) -> Tuple[torch.Tensor, torch.Tensor]:
26
+ """
27
+ Rotary kernel implementation wrapper
28
+ Adapts rotary kernel implementation to match transformers apply_rotary_pos_emb signature
29
+ """
30
+ cos = cos.unsqueeze(unsqueeze_dim)
31
+ sin = sin.unsqueeze(unsqueeze_dim)
32
+
33
+ q_rotated = q.clone()
34
+ k_rotated = k.clone()
35
+
36
+ # Get half dimension for rotation
37
+ half_dim = q.shape[-1] // 2
38
+ q1 = q_rotated[..., :half_dim]
39
+ q2 = q_rotated[..., half_dim:]
40
+ k1 = k_rotated[..., :half_dim]
41
+ k2 = k_rotated[..., half_dim:]
42
+ if cos.shape[-1] != half_dim:
43
+ # Trim cos/sin to match half_dim
44
+ cos = cos[..., :half_dim]
45
+ sin = sin[..., :half_dim]
46
+
47
+ apply_rotary(q1, q2, cos, sin, q1, q2, False)
48
+ apply_rotary(k1, k2, cos, sin, k1, k2, False)
49
+ return q_rotated, k_rotated
50
+
51
+
52
+ __all__ = ["apply_rotary", "apply_rotary_transformers"]
build/torch29-cxx11-cu128-aarch64-linux/_ops.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from . import _rotary_cuda_4e81b67
3
+ ops = torch.ops._rotary_cuda_4e81b67
4
+
5
+ def add_op_namespace_prefix(op_name: str):
6
+ """
7
+ Prefix op by namespace.
8
+ """
9
+ return f"_rotary_cuda_4e81b67::{op_name}"
build/torch29-cxx11-cu128-aarch64-linux/_rotary_cuda_4e81b67.abi3.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:24ba03d9bdd3fbe264d722c2e066493fc7ab72de5014bf3ee548fc0f86bb30d7
3
+ size 12016752
build/torch29-cxx11-cu128-aarch64-linux/metadata.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": 1,
3
+ "license": "BSD-3-Clause",
4
+ "python-depends": [],
5
+ "backend": {
6
+ "type": "cuda",
7
+ "archs": [
8
+ "10.0",
9
+ "10.1",
10
+ "12.0+PTX",
11
+ "7.0",
12
+ "7.2",
13
+ "7.5",
14
+ "8.0",
15
+ "8.6",
16
+ "8.7",
17
+ "8.9",
18
+ "9.0"
19
+ ]
20
+ }
21
+ }
build/torch29-cxx11-cu128-aarch64-linux/rotary/__init__.py CHANGED
@@ -1,19 +1,26 @@
1
- from typing import Tuple
2
- import torch
3
 
4
- from ._ops import ops
 
 
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
- def apply_rotary(
8
- x1: torch.Tensor,
9
- x2: torch.Tensor,
10
- cos: torch.Tensor,
11
- sin: torch.Tensor,
12
- out1: torch.Tensor,
13
- out2: torch.Tensor,
14
- conj: bool,
15
- ):
16
- ops.apply_rotary(x1, x2, cos, sin, out1, out2, conj)
17
 
18
-
19
- __all__ = ["apply_rotary"]
 
1
+ import ctypes
2
+ import sys
3
 
4
+ import importlib
5
+ from pathlib import Path
6
+ from types import ModuleType
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/torch29-cxx11-cu128-aarch64-linux/rotary/__pycache__/__init__.cpython-313.pyc DELETED
Binary file (813 Bytes)
 
build/torch29-cxx11-cu128-aarch64-linux/rotary/__pycache__/_ops.cpython-313.pyc DELETED
Binary file (515 Bytes)
 
build/torch29-cxx11-cu130-aarch64-linux/__init__.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Optional, Tuple
2
+ import torch
3
+
4
+ from ._ops import ops
5
+
6
+
7
+ def apply_rotary(
8
+ x1: torch.Tensor,
9
+ x2: torch.Tensor,
10
+ cos: torch.Tensor,
11
+ sin: torch.Tensor,
12
+ out1: torch.Tensor,
13
+ out2: torch.Tensor,
14
+ conj: bool,
15
+ ) -> None:
16
+ ops.apply_rotary(x1, x2, cos, sin, out1, out2, conj)
17
+
18
+
19
+ def apply_rotary_transformers(
20
+ q: torch.Tensor,
21
+ k: torch.Tensor,
22
+ cos: torch.Tensor,
23
+ sin: torch.Tensor,
24
+ unsqueeze_dim: int = 1,
25
+ ) -> Tuple[torch.Tensor, torch.Tensor]:
26
+ """
27
+ Rotary kernel implementation wrapper
28
+ Adapts rotary kernel implementation to match transformers apply_rotary_pos_emb signature
29
+ """
30
+ cos = cos.unsqueeze(unsqueeze_dim)
31
+ sin = sin.unsqueeze(unsqueeze_dim)
32
+
33
+ q_rotated = q.clone()
34
+ k_rotated = k.clone()
35
+
36
+ # Get half dimension for rotation
37
+ half_dim = q.shape[-1] // 2
38
+ q1 = q_rotated[..., :half_dim]
39
+ q2 = q_rotated[..., half_dim:]
40
+ k1 = k_rotated[..., :half_dim]
41
+ k2 = k_rotated[..., half_dim:]
42
+ if cos.shape[-1] != half_dim:
43
+ # Trim cos/sin to match half_dim
44
+ cos = cos[..., :half_dim]
45
+ sin = sin[..., :half_dim]
46
+
47
+ apply_rotary(q1, q2, cos, sin, q1, q2, False)
48
+ apply_rotary(k1, k2, cos, sin, k1, k2, False)
49
+ return q_rotated, k_rotated
50
+
51
+
52
+ __all__ = ["apply_rotary", "apply_rotary_transformers"]
build/torch29-cxx11-cu130-aarch64-linux/_ops.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from . import _rotary_cuda_4e81b67
3
+ ops = torch.ops._rotary_cuda_4e81b67
4
+
5
+ def add_op_namespace_prefix(op_name: str):
6
+ """
7
+ Prefix op by namespace.
8
+ """
9
+ return f"_rotary_cuda_4e81b67::{op_name}"
build/torch29-cxx11-cu130-aarch64-linux/_rotary_cuda_4e81b67.abi3.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:82e09ee619e75dfcc66cabaebc1da15b08b2550449e1e598b16968a0a5b8dff0
3
+ size 10408984
build/torch29-cxx11-cu130-aarch64-linux/metadata.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": 1,
3
+ "license": "BSD-3-Clause",
4
+ "python-depends": [],
5
+ "backend": {
6
+ "type": "cuda",
7
+ "archs": [
8
+ "10.0",
9
+ "11.0",
10
+ "12.0+PTX",
11
+ "7.5",
12
+ "8.0",
13
+ "8.6",
14
+ "8.7",
15
+ "8.9",
16
+ "9.0"
17
+ ]
18
+ }
19
+ }
build/torch29-cxx11-cu130-aarch64-linux/rotary/__init__.py CHANGED
@@ -1,19 +1,26 @@
1
- from typing import Tuple
2
- import torch
3
 
4
- from ._ops import ops
 
 
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
- def apply_rotary(
8
- x1: torch.Tensor,
9
- x2: torch.Tensor,
10
- cos: torch.Tensor,
11
- sin: torch.Tensor,
12
- out1: torch.Tensor,
13
- out2: torch.Tensor,
14
- conj: bool,
15
- ):
16
- ops.apply_rotary(x1, x2, cos, sin, out1, out2, conj)
17
 
18
-
19
- __all__ = ["apply_rotary"]
 
1
+ import ctypes
2
+ import sys
3
 
4
+ import importlib
5
+ from pathlib import Path
6
+ from types import ModuleType
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/torch29-cxx11-cu130-aarch64-linux/rotary/__pycache__/__init__.cpython-313.pyc DELETED
Binary file (813 Bytes)
 
build/torch29-cxx11-cu130-aarch64-linux/rotary/__pycache__/_ops.cpython-313.pyc DELETED
Binary file (515 Bytes)