Build uploaded using `kernels`.
Browse files- build/torch28-cxx11-cu126-x86_64-linux/rotary/__init__.py +37 -3
- build/torch28-cxx11-cu126-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc +0 -0
- build/torch28-cxx11-cu126-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc +0 -0
- build/torch28-cxx11-cu126-x86_64-linux/rotary/_ops.py +3 -3
- build/torch28-cxx11-cu126-x86_64-linux/rotary/{_rotary_98ffc18.abi3.so → _rotary_dba7d1e.abi3.so} +2 -2
- build/torch28-cxx11-cu128-x86_64-linux/rotary/__init__.py +37 -3
- build/torch28-cxx11-cu128-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc +0 -0
- build/torch28-cxx11-cu128-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc +0 -0
- build/torch28-cxx11-cu128-x86_64-linux/rotary/_ops.py +3 -3
- build/torch28-cxx11-cu128-x86_64-linux/rotary/_rotary_98ffc18.abi3.so +0 -3
- build/{torch29-cxx11-cu126-x86_64-linux/rotary/_rotary_98ffc18.abi3.so → torch28-cxx11-cu128-x86_64-linux/rotary/_rotary_dba7d1e.abi3.so} +2 -2
- build/torch28-cxx11-cu129-x86_64-linux/rotary/__init__.py +37 -3
- build/torch28-cxx11-cu129-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc +0 -0
- build/torch28-cxx11-cu129-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc +0 -0
- build/torch28-cxx11-cu129-x86_64-linux/rotary/_ops.py +3 -3
- build/torch28-cxx11-cu129-x86_64-linux/rotary/_rotary_98ffc18.abi3.so +0 -3
- build/{torch29-cxx11-cu130-x86_64-linux/rotary/_rotary_98ffc18.abi3.so → torch28-cxx11-cu129-x86_64-linux/rotary/_rotary_dba7d1e.abi3.so} +2 -2
- build/torch28-cxx11-xpu20251-x86_64-linux/rotary/__init__.py +37 -3
- build/torch28-cxx11-xpu20251-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc +0 -0
- build/torch28-cxx11-xpu20251-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc +0 -0
- build/torch28-cxx11-xpu20251-x86_64-linux/rotary/_ops.py +3 -3
- build/torch28-cxx11-xpu20251-x86_64-linux/rotary/{_rotary_98ffc18.abi3.so → _rotary_dba7d1e.abi3.so} +1 -1
- build/torch29-cxx11-cu126-x86_64-linux/rotary/__init__.py +37 -3
- build/torch29-cxx11-cu126-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc +0 -0
- build/torch29-cxx11-cu126-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc +0 -0
- build/torch29-cxx11-cu126-x86_64-linux/rotary/_ops.py +3 -3
- build/torch29-cxx11-cu126-x86_64-linux/rotary/_rotary_dba7d1e.abi3.so +3 -0
- build/torch29-cxx11-cu128-x86_64-linux/rotary/__init__.py +37 -3
- build/torch29-cxx11-cu128-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc +0 -0
- build/torch29-cxx11-cu128-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc +0 -0
- build/torch29-cxx11-cu128-x86_64-linux/rotary/_ops.py +3 -3
- build/torch29-cxx11-cu128-x86_64-linux/rotary/_rotary_98ffc18.abi3.so +0 -3
- build/torch29-cxx11-cu128-x86_64-linux/rotary/_rotary_dba7d1e.abi3.so +3 -0
- build/torch29-cxx11-cu130-x86_64-linux/rotary/__init__.py +37 -3
- build/torch29-cxx11-cu130-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc +0 -0
- build/torch29-cxx11-cu130-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc +0 -0
- build/torch29-cxx11-cu130-x86_64-linux/rotary/_ops.py +3 -3
- build/torch29-cxx11-cu130-x86_64-linux/rotary/_rotary_dba7d1e.abi3.so +3 -0
- build/torch29-cxx11-xpu20252-x86_64-linux/rotary/__init__.py +37 -3
- build/torch29-cxx11-xpu20252-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc +0 -0
- build/torch29-cxx11-xpu20252-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc +0 -0
- build/torch29-cxx11-xpu20252-x86_64-linux/rotary/_ops.py +3 -3
- build/torch29-cxx11-xpu20252-x86_64-linux/rotary/{_rotary_98ffc18.abi3.so → _rotary_dba7d1e.abi3.so} +1 -1
build/torch28-cxx11-cu126-x86_64-linux/rotary/__init__.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from typing import Tuple
|
| 2 |
import torch
|
| 3 |
|
| 4 |
from ._ops import ops
|
|
@@ -12,8 +12,42 @@ def apply_rotary(
|
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Optional, Tuple
|
| 2 |
import torch
|
| 3 |
|
| 4 |
from ._ops import ops
|
|
|
|
| 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 |
+
position_ids: Optional[torch.Tensor] = None,
|
| 25 |
+
unsqueeze_dim: int = 1,
|
| 26 |
+
) -> Tuple[torch.Tensor, torch.Tensor]:
|
| 27 |
+
"""
|
| 28 |
+
Rotary kernel implementation wrapper
|
| 29 |
+
Adapts rotary kernels implementation to match transformers apply_rotary_pos_emb signature
|
| 30 |
+
"""
|
| 31 |
+
cos = cos.unsqueeze(unsqueeze_dim)
|
| 32 |
+
sin = sin.unsqueeze(unsqueeze_dim)
|
| 33 |
+
|
| 34 |
+
q_rotated = q.clone()
|
| 35 |
+
k_rotated = k.clone()
|
| 36 |
+
|
| 37 |
+
# Get half dimension for rotation
|
| 38 |
+
half_dim = q.shape[-1] // 2
|
| 39 |
+
q1 = q_rotated[..., :half_dim]
|
| 40 |
+
q2 = q_rotated[..., half_dim:]
|
| 41 |
+
k1 = k_rotated[..., :half_dim]
|
| 42 |
+
k2 = k_rotated[..., half_dim:]
|
| 43 |
+
if cos.shape[-1] != half_dim:
|
| 44 |
+
# Trim cos/sin to match half_dim
|
| 45 |
+
cos = cos[..., :half_dim]
|
| 46 |
+
sin = sin[..., :half_dim]
|
| 47 |
+
|
| 48 |
+
apply_rotary(q1, q2, cos, sin, q1, q2, False)
|
| 49 |
+
apply_rotary(k1, k2, cos, sin, k1, k2, False)
|
| 50 |
+
return q_rotated, k_rotated
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
__all__ = ["apply_rotary", "apply_rotary_transformers"]
|
build/torch28-cxx11-cu126-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc
CHANGED
|
Binary files a/build/torch28-cxx11-cu126-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc and b/build/torch28-cxx11-cu126-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc differ
|
|
|
build/torch28-cxx11-cu126-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc
CHANGED
|
Binary files a/build/torch28-cxx11-cu126-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc and b/build/torch28-cxx11-cu126-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc differ
|
|
|
build/torch28-cxx11-cu126-x86_64-linux/rotary/_ops.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import torch
|
| 2 |
-
from . import
|
| 3 |
-
ops = torch.ops.
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
-
return f"
|
|
|
|
| 1 |
import torch
|
| 2 |
+
from . import _rotary_dba7d1e
|
| 3 |
+
ops = torch.ops._rotary_dba7d1e
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_rotary_dba7d1e::{op_name}"
|
build/torch28-cxx11-cu126-x86_64-linux/rotary/{_rotary_98ffc18.abi3.so → _rotary_dba7d1e.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:afcfe44855a3e4bd60283a3c0e9b838a81177942d4997e48ff58e0542f168790
|
| 3 |
+
size 5462056
|
build/torch28-cxx11-cu128-x86_64-linux/rotary/__init__.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from typing import Tuple
|
| 2 |
import torch
|
| 3 |
|
| 4 |
from ._ops import ops
|
|
@@ -12,8 +12,42 @@ def apply_rotary(
|
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Optional, Tuple
|
| 2 |
import torch
|
| 3 |
|
| 4 |
from ._ops import ops
|
|
|
|
| 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 |
+
position_ids: Optional[torch.Tensor] = None,
|
| 25 |
+
unsqueeze_dim: int = 1,
|
| 26 |
+
) -> Tuple[torch.Tensor, torch.Tensor]:
|
| 27 |
+
"""
|
| 28 |
+
Rotary kernel implementation wrapper
|
| 29 |
+
Adapts rotary kernels implementation to match transformers apply_rotary_pos_emb signature
|
| 30 |
+
"""
|
| 31 |
+
cos = cos.unsqueeze(unsqueeze_dim)
|
| 32 |
+
sin = sin.unsqueeze(unsqueeze_dim)
|
| 33 |
+
|
| 34 |
+
q_rotated = q.clone()
|
| 35 |
+
k_rotated = k.clone()
|
| 36 |
+
|
| 37 |
+
# Get half dimension for rotation
|
| 38 |
+
half_dim = q.shape[-1] // 2
|
| 39 |
+
q1 = q_rotated[..., :half_dim]
|
| 40 |
+
q2 = q_rotated[..., half_dim:]
|
| 41 |
+
k1 = k_rotated[..., :half_dim]
|
| 42 |
+
k2 = k_rotated[..., half_dim:]
|
| 43 |
+
if cos.shape[-1] != half_dim:
|
| 44 |
+
# Trim cos/sin to match half_dim
|
| 45 |
+
cos = cos[..., :half_dim]
|
| 46 |
+
sin = sin[..., :half_dim]
|
| 47 |
+
|
| 48 |
+
apply_rotary(q1, q2, cos, sin, q1, q2, False)
|
| 49 |
+
apply_rotary(k1, k2, cos, sin, k1, k2, False)
|
| 50 |
+
return q_rotated, k_rotated
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
__all__ = ["apply_rotary", "apply_rotary_transformers"]
|
build/torch28-cxx11-cu128-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc
CHANGED
|
Binary files a/build/torch28-cxx11-cu128-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc and b/build/torch28-cxx11-cu128-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc differ
|
|
|
build/torch28-cxx11-cu128-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc
CHANGED
|
Binary files a/build/torch28-cxx11-cu128-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc and b/build/torch28-cxx11-cu128-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc differ
|
|
|
build/torch28-cxx11-cu128-x86_64-linux/rotary/_ops.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import torch
|
| 2 |
-
from . import
|
| 3 |
-
ops = torch.ops.
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
-
return f"
|
|
|
|
| 1 |
import torch
|
| 2 |
+
from . import _rotary_dba7d1e
|
| 3 |
+
ops = torch.ops._rotary_dba7d1e
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_rotary_dba7d1e::{op_name}"
|
build/torch28-cxx11-cu128-x86_64-linux/rotary/_rotary_98ffc18.abi3.so
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:99b283e0cc88386e746276ce9866dcd8d59c93bbff49ce02474357cca897d2a0
|
| 3 |
-
size 10526400
|
|
|
|
|
|
|
|
|
|
|
|
build/{torch29-cxx11-cu126-x86_64-linux/rotary/_rotary_98ffc18.abi3.so → torch28-cxx11-cu128-x86_64-linux/rotary/_rotary_dba7d1e.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9092efc80c61670f0e9634e7b96a59c45c35cac470f85da5ba1a8ea184a15750
|
| 3 |
+
size 7893120
|
build/torch28-cxx11-cu129-x86_64-linux/rotary/__init__.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from typing import Tuple
|
| 2 |
import torch
|
| 3 |
|
| 4 |
from ._ops import ops
|
|
@@ -12,8 +12,42 @@ def apply_rotary(
|
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Optional, Tuple
|
| 2 |
import torch
|
| 3 |
|
| 4 |
from ._ops import ops
|
|
|
|
| 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 |
+
position_ids: Optional[torch.Tensor] = None,
|
| 25 |
+
unsqueeze_dim: int = 1,
|
| 26 |
+
) -> Tuple[torch.Tensor, torch.Tensor]:
|
| 27 |
+
"""
|
| 28 |
+
Rotary kernel implementation wrapper
|
| 29 |
+
Adapts rotary kernels implementation to match transformers apply_rotary_pos_emb signature
|
| 30 |
+
"""
|
| 31 |
+
cos = cos.unsqueeze(unsqueeze_dim)
|
| 32 |
+
sin = sin.unsqueeze(unsqueeze_dim)
|
| 33 |
+
|
| 34 |
+
q_rotated = q.clone()
|
| 35 |
+
k_rotated = k.clone()
|
| 36 |
+
|
| 37 |
+
# Get half dimension for rotation
|
| 38 |
+
half_dim = q.shape[-1] // 2
|
| 39 |
+
q1 = q_rotated[..., :half_dim]
|
| 40 |
+
q2 = q_rotated[..., half_dim:]
|
| 41 |
+
k1 = k_rotated[..., :half_dim]
|
| 42 |
+
k2 = k_rotated[..., half_dim:]
|
| 43 |
+
if cos.shape[-1] != half_dim:
|
| 44 |
+
# Trim cos/sin to match half_dim
|
| 45 |
+
cos = cos[..., :half_dim]
|
| 46 |
+
sin = sin[..., :half_dim]
|
| 47 |
+
|
| 48 |
+
apply_rotary(q1, q2, cos, sin, q1, q2, False)
|
| 49 |
+
apply_rotary(k1, k2, cos, sin, k1, k2, False)
|
| 50 |
+
return q_rotated, k_rotated
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
__all__ = ["apply_rotary", "apply_rotary_transformers"]
|
build/torch28-cxx11-cu129-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc
CHANGED
|
Binary files a/build/torch28-cxx11-cu129-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc and b/build/torch28-cxx11-cu129-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc differ
|
|
|
build/torch28-cxx11-cu129-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc
CHANGED
|
Binary files a/build/torch28-cxx11-cu129-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc and b/build/torch28-cxx11-cu129-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc differ
|
|
|
build/torch28-cxx11-cu129-x86_64-linux/rotary/_ops.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import torch
|
| 2 |
-
from . import
|
| 3 |
-
ops = torch.ops.
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
-
return f"
|
|
|
|
| 1 |
import torch
|
| 2 |
+
from . import _rotary_dba7d1e
|
| 3 |
+
ops = torch.ops._rotary_dba7d1e
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_rotary_dba7d1e::{op_name}"
|
build/torch28-cxx11-cu129-x86_64-linux/rotary/_rotary_98ffc18.abi3.so
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:50a460190d5b7e5f66016f23ce23989a66fa6e0bee967bf8b6ce9472706d55a6
|
| 3 |
-
size 10586824
|
|
|
|
|
|
|
|
|
|
|
|
build/{torch29-cxx11-cu130-x86_64-linux/rotary/_rotary_98ffc18.abi3.so → torch28-cxx11-cu129-x86_64-linux/rotary/_rotary_dba7d1e.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:001611c5afea6f19fa26720bd93cca352fcb0eb9b50fb9786b03e80d0eefd1db
|
| 3 |
+
size 7949960
|
build/torch28-cxx11-xpu20251-x86_64-linux/rotary/__init__.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from typing import Tuple
|
| 2 |
import torch
|
| 3 |
|
| 4 |
from ._ops import ops
|
|
@@ -12,8 +12,42 @@ def apply_rotary(
|
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Optional, Tuple
|
| 2 |
import torch
|
| 3 |
|
| 4 |
from ._ops import ops
|
|
|
|
| 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 |
+
position_ids: Optional[torch.Tensor] = None,
|
| 25 |
+
unsqueeze_dim: int = 1,
|
| 26 |
+
) -> Tuple[torch.Tensor, torch.Tensor]:
|
| 27 |
+
"""
|
| 28 |
+
Rotary kernel implementation wrapper
|
| 29 |
+
Adapts rotary kernels implementation to match transformers apply_rotary_pos_emb signature
|
| 30 |
+
"""
|
| 31 |
+
cos = cos.unsqueeze(unsqueeze_dim)
|
| 32 |
+
sin = sin.unsqueeze(unsqueeze_dim)
|
| 33 |
+
|
| 34 |
+
q_rotated = q.clone()
|
| 35 |
+
k_rotated = k.clone()
|
| 36 |
+
|
| 37 |
+
# Get half dimension for rotation
|
| 38 |
+
half_dim = q.shape[-1] // 2
|
| 39 |
+
q1 = q_rotated[..., :half_dim]
|
| 40 |
+
q2 = q_rotated[..., half_dim:]
|
| 41 |
+
k1 = k_rotated[..., :half_dim]
|
| 42 |
+
k2 = k_rotated[..., half_dim:]
|
| 43 |
+
if cos.shape[-1] != half_dim:
|
| 44 |
+
# Trim cos/sin to match half_dim
|
| 45 |
+
cos = cos[..., :half_dim]
|
| 46 |
+
sin = sin[..., :half_dim]
|
| 47 |
+
|
| 48 |
+
apply_rotary(q1, q2, cos, sin, q1, q2, False)
|
| 49 |
+
apply_rotary(k1, k2, cos, sin, k1, k2, False)
|
| 50 |
+
return q_rotated, k_rotated
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
__all__ = ["apply_rotary", "apply_rotary_transformers"]
|
build/torch28-cxx11-xpu20251-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc
CHANGED
|
Binary files a/build/torch28-cxx11-xpu20251-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc and b/build/torch28-cxx11-xpu20251-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc differ
|
|
|
build/torch28-cxx11-xpu20251-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc
CHANGED
|
Binary files a/build/torch28-cxx11-xpu20251-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc and b/build/torch28-cxx11-xpu20251-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc differ
|
|
|
build/torch28-cxx11-xpu20251-x86_64-linux/rotary/_ops.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import torch
|
| 2 |
-
from . import
|
| 3 |
-
ops = torch.ops.
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
-
return f"
|
|
|
|
| 1 |
import torch
|
| 2 |
+
from . import _rotary_dba7d1e
|
| 3 |
+
ops = torch.ops._rotary_dba7d1e
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_rotary_dba7d1e::{op_name}"
|
build/torch28-cxx11-xpu20251-x86_64-linux/rotary/{_rotary_98ffc18.abi3.so → _rotary_dba7d1e.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 2324536
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:036b2a03719657cb135cb93629f9da21c4d9d9f9537ff2792d151b32c2488c59
|
| 3 |
size 2324536
|
build/torch29-cxx11-cu126-x86_64-linux/rotary/__init__.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from typing import Tuple
|
| 2 |
import torch
|
| 3 |
|
| 4 |
from ._ops import ops
|
|
@@ -12,8 +12,42 @@ def apply_rotary(
|
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Optional, Tuple
|
| 2 |
import torch
|
| 3 |
|
| 4 |
from ._ops import ops
|
|
|
|
| 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 |
+
position_ids: Optional[torch.Tensor] = None,
|
| 25 |
+
unsqueeze_dim: int = 1,
|
| 26 |
+
) -> Tuple[torch.Tensor, torch.Tensor]:
|
| 27 |
+
"""
|
| 28 |
+
Rotary kernel implementation wrapper
|
| 29 |
+
Adapts rotary kernels implementation to match transformers apply_rotary_pos_emb signature
|
| 30 |
+
"""
|
| 31 |
+
cos = cos.unsqueeze(unsqueeze_dim)
|
| 32 |
+
sin = sin.unsqueeze(unsqueeze_dim)
|
| 33 |
+
|
| 34 |
+
q_rotated = q.clone()
|
| 35 |
+
k_rotated = k.clone()
|
| 36 |
+
|
| 37 |
+
# Get half dimension for rotation
|
| 38 |
+
half_dim = q.shape[-1] // 2
|
| 39 |
+
q1 = q_rotated[..., :half_dim]
|
| 40 |
+
q2 = q_rotated[..., half_dim:]
|
| 41 |
+
k1 = k_rotated[..., :half_dim]
|
| 42 |
+
k2 = k_rotated[..., half_dim:]
|
| 43 |
+
if cos.shape[-1] != half_dim:
|
| 44 |
+
# Trim cos/sin to match half_dim
|
| 45 |
+
cos = cos[..., :half_dim]
|
| 46 |
+
sin = sin[..., :half_dim]
|
| 47 |
+
|
| 48 |
+
apply_rotary(q1, q2, cos, sin, q1, q2, False)
|
| 49 |
+
apply_rotary(k1, k2, cos, sin, k1, k2, False)
|
| 50 |
+
return q_rotated, k_rotated
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
__all__ = ["apply_rotary", "apply_rotary_transformers"]
|
build/torch29-cxx11-cu126-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc
CHANGED
|
Binary files a/build/torch29-cxx11-cu126-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc and b/build/torch29-cxx11-cu126-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc differ
|
|
|
build/torch29-cxx11-cu126-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc
CHANGED
|
Binary files a/build/torch29-cxx11-cu126-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc and b/build/torch29-cxx11-cu126-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc differ
|
|
|
build/torch29-cxx11-cu126-x86_64-linux/rotary/_ops.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import torch
|
| 2 |
-
from . import
|
| 3 |
-
ops = torch.ops.
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
-
return f"
|
|
|
|
| 1 |
import torch
|
| 2 |
+
from . import _rotary_dba7d1e
|
| 3 |
+
ops = torch.ops._rotary_dba7d1e
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_rotary_dba7d1e::{op_name}"
|
build/torch29-cxx11-cu126-x86_64-linux/rotary/_rotary_dba7d1e.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:747406a42e14287a3cab577e65abf26cee64ec6324e2692be5ade3d22a1be2b3
|
| 3 |
+
size 5461944
|
build/torch29-cxx11-cu128-x86_64-linux/rotary/__init__.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from typing import Tuple
|
| 2 |
import torch
|
| 3 |
|
| 4 |
from ._ops import ops
|
|
@@ -12,8 +12,42 @@ def apply_rotary(
|
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Optional, Tuple
|
| 2 |
import torch
|
| 3 |
|
| 4 |
from ._ops import ops
|
|
|
|
| 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 |
+
position_ids: Optional[torch.Tensor] = None,
|
| 25 |
+
unsqueeze_dim: int = 1,
|
| 26 |
+
) -> Tuple[torch.Tensor, torch.Tensor]:
|
| 27 |
+
"""
|
| 28 |
+
Rotary kernel implementation wrapper
|
| 29 |
+
Adapts rotary kernels implementation to match transformers apply_rotary_pos_emb signature
|
| 30 |
+
"""
|
| 31 |
+
cos = cos.unsqueeze(unsqueeze_dim)
|
| 32 |
+
sin = sin.unsqueeze(unsqueeze_dim)
|
| 33 |
+
|
| 34 |
+
q_rotated = q.clone()
|
| 35 |
+
k_rotated = k.clone()
|
| 36 |
+
|
| 37 |
+
# Get half dimension for rotation
|
| 38 |
+
half_dim = q.shape[-1] // 2
|
| 39 |
+
q1 = q_rotated[..., :half_dim]
|
| 40 |
+
q2 = q_rotated[..., half_dim:]
|
| 41 |
+
k1 = k_rotated[..., :half_dim]
|
| 42 |
+
k2 = k_rotated[..., half_dim:]
|
| 43 |
+
if cos.shape[-1] != half_dim:
|
| 44 |
+
# Trim cos/sin to match half_dim
|
| 45 |
+
cos = cos[..., :half_dim]
|
| 46 |
+
sin = sin[..., :half_dim]
|
| 47 |
+
|
| 48 |
+
apply_rotary(q1, q2, cos, sin, q1, q2, False)
|
| 49 |
+
apply_rotary(k1, k2, cos, sin, k1, k2, False)
|
| 50 |
+
return q_rotated, k_rotated
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
__all__ = ["apply_rotary", "apply_rotary_transformers"]
|
build/torch29-cxx11-cu128-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc
CHANGED
|
Binary files a/build/torch29-cxx11-cu128-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc and b/build/torch29-cxx11-cu128-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc differ
|
|
|
build/torch29-cxx11-cu128-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc
CHANGED
|
Binary files a/build/torch29-cxx11-cu128-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc and b/build/torch29-cxx11-cu128-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc differ
|
|
|
build/torch29-cxx11-cu128-x86_64-linux/rotary/_ops.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import torch
|
| 2 |
-
from . import
|
| 3 |
-
ops = torch.ops.
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
-
return f"
|
|
|
|
| 1 |
import torch
|
| 2 |
+
from . import _rotary_dba7d1e
|
| 3 |
+
ops = torch.ops._rotary_dba7d1e
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_rotary_dba7d1e::{op_name}"
|
build/torch29-cxx11-cu128-x86_64-linux/rotary/_rotary_98ffc18.abi3.so
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:8d39655db220a21ec886c5a896359755e247410999679e9bea86f51ee539b0b3
|
| 3 |
-
size 10526504
|
|
|
|
|
|
|
|
|
|
|
|
build/torch29-cxx11-cu128-x86_64-linux/rotary/_rotary_dba7d1e.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9316296204902f06352d27d5702e11b54dc7580adec50fdde4be15d8351de03a
|
| 3 |
+
size 7897320
|
build/torch29-cxx11-cu130-x86_64-linux/rotary/__init__.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from typing import Tuple
|
| 2 |
import torch
|
| 3 |
|
| 4 |
from ._ops import ops
|
|
@@ -12,8 +12,42 @@ def apply_rotary(
|
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Optional, Tuple
|
| 2 |
import torch
|
| 3 |
|
| 4 |
from ._ops import ops
|
|
|
|
| 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 |
+
position_ids: Optional[torch.Tensor] = None,
|
| 25 |
+
unsqueeze_dim: int = 1,
|
| 26 |
+
) -> Tuple[torch.Tensor, torch.Tensor]:
|
| 27 |
+
"""
|
| 28 |
+
Rotary kernel implementation wrapper
|
| 29 |
+
Adapts rotary kernels implementation to match transformers apply_rotary_pos_emb signature
|
| 30 |
+
"""
|
| 31 |
+
cos = cos.unsqueeze(unsqueeze_dim)
|
| 32 |
+
sin = sin.unsqueeze(unsqueeze_dim)
|
| 33 |
+
|
| 34 |
+
q_rotated = q.clone()
|
| 35 |
+
k_rotated = k.clone()
|
| 36 |
+
|
| 37 |
+
# Get half dimension for rotation
|
| 38 |
+
half_dim = q.shape[-1] // 2
|
| 39 |
+
q1 = q_rotated[..., :half_dim]
|
| 40 |
+
q2 = q_rotated[..., half_dim:]
|
| 41 |
+
k1 = k_rotated[..., :half_dim]
|
| 42 |
+
k2 = k_rotated[..., half_dim:]
|
| 43 |
+
if cos.shape[-1] != half_dim:
|
| 44 |
+
# Trim cos/sin to match half_dim
|
| 45 |
+
cos = cos[..., :half_dim]
|
| 46 |
+
sin = sin[..., :half_dim]
|
| 47 |
+
|
| 48 |
+
apply_rotary(q1, q2, cos, sin, q1, q2, False)
|
| 49 |
+
apply_rotary(k1, k2, cos, sin, k1, k2, False)
|
| 50 |
+
return q_rotated, k_rotated
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
__all__ = ["apply_rotary", "apply_rotary_transformers"]
|
build/torch29-cxx11-cu130-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc
CHANGED
|
Binary files a/build/torch29-cxx11-cu130-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc and b/build/torch29-cxx11-cu130-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc differ
|
|
|
build/torch29-cxx11-cu130-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc
CHANGED
|
Binary files a/build/torch29-cxx11-cu130-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc and b/build/torch29-cxx11-cu130-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc differ
|
|
|
build/torch29-cxx11-cu130-x86_64-linux/rotary/_ops.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import torch
|
| 2 |
-
from . import
|
| 3 |
-
ops = torch.ops.
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
-
return f"
|
|
|
|
| 1 |
import torch
|
| 2 |
+
from . import _rotary_dba7d1e
|
| 3 |
+
ops = torch.ops._rotary_dba7d1e
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_rotary_dba7d1e::{op_name}"
|
build/torch29-cxx11-cu130-x86_64-linux/rotary/_rotary_dba7d1e.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c55687a6b3ec5f6fce8841387ca647eb2e57a4b387ea09e12c672a95040ea5c4
|
| 3 |
+
size 7659376
|
build/torch29-cxx11-xpu20252-x86_64-linux/rotary/__init__.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from typing import Tuple
|
| 2 |
import torch
|
| 3 |
|
| 4 |
from ._ops import ops
|
|
@@ -12,8 +12,42 @@ def apply_rotary(
|
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Optional, Tuple
|
| 2 |
import torch
|
| 3 |
|
| 4 |
from ._ops import ops
|
|
|
|
| 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 |
+
position_ids: Optional[torch.Tensor] = None,
|
| 25 |
+
unsqueeze_dim: int = 1,
|
| 26 |
+
) -> Tuple[torch.Tensor, torch.Tensor]:
|
| 27 |
+
"""
|
| 28 |
+
Rotary kernel implementation wrapper
|
| 29 |
+
Adapts rotary kernels implementation to match transformers apply_rotary_pos_emb signature
|
| 30 |
+
"""
|
| 31 |
+
cos = cos.unsqueeze(unsqueeze_dim)
|
| 32 |
+
sin = sin.unsqueeze(unsqueeze_dim)
|
| 33 |
+
|
| 34 |
+
q_rotated = q.clone()
|
| 35 |
+
k_rotated = k.clone()
|
| 36 |
+
|
| 37 |
+
# Get half dimension for rotation
|
| 38 |
+
half_dim = q.shape[-1] // 2
|
| 39 |
+
q1 = q_rotated[..., :half_dim]
|
| 40 |
+
q2 = q_rotated[..., half_dim:]
|
| 41 |
+
k1 = k_rotated[..., :half_dim]
|
| 42 |
+
k2 = k_rotated[..., half_dim:]
|
| 43 |
+
if cos.shape[-1] != half_dim:
|
| 44 |
+
# Trim cos/sin to match half_dim
|
| 45 |
+
cos = cos[..., :half_dim]
|
| 46 |
+
sin = sin[..., :half_dim]
|
| 47 |
+
|
| 48 |
+
apply_rotary(q1, q2, cos, sin, q1, q2, False)
|
| 49 |
+
apply_rotary(k1, k2, cos, sin, k1, k2, False)
|
| 50 |
+
return q_rotated, k_rotated
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
__all__ = ["apply_rotary", "apply_rotary_transformers"]
|
build/torch29-cxx11-xpu20252-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc
CHANGED
|
Binary files a/build/torch29-cxx11-xpu20252-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc and b/build/torch29-cxx11-xpu20252-x86_64-linux/rotary/__pycache__/__init__.cpython-313.pyc differ
|
|
|
build/torch29-cxx11-xpu20252-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc
CHANGED
|
Binary files a/build/torch29-cxx11-xpu20252-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc and b/build/torch29-cxx11-xpu20252-x86_64-linux/rotary/__pycache__/_ops.cpython-313.pyc differ
|
|
|
build/torch29-cxx11-xpu20252-x86_64-linux/rotary/_ops.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import torch
|
| 2 |
-
from . import
|
| 3 |
-
ops = torch.ops.
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
-
return f"
|
|
|
|
| 1 |
import torch
|
| 2 |
+
from . import _rotary_dba7d1e
|
| 3 |
+
ops = torch.ops._rotary_dba7d1e
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_rotary_dba7d1e::{op_name}"
|
build/torch29-cxx11-xpu20252-x86_64-linux/rotary/{_rotary_98ffc18.abi3.so → _rotary_dba7d1e.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 2273032
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:70148df322edfbbcd55554ade33f184dcae0003a2f2b75e89d91f2a955dee7ca
|
| 3 |
size 2273032
|