Kernels:
Trusted publisher
Uploaded using `kernel-builder`.
Browse files- build/torch210-cxx11-cu126-x86_64-linux/_ops.py +3 -3
- build/torch210-cxx11-cu126-x86_64-linux/{_rotary_cuda_86f75d9.abi3.so → _rotary_cuda_725ebfc.abi3.so} +1 -1
- build/torch210-cxx11-cu126-x86_64-linux/metadata.json +1 -1
- build/torch210-cxx11-cu128-x86_64-linux/_ops.py +3 -3
- build/torch210-cxx11-cu128-x86_64-linux/{_rotary_cuda_86f75d9.abi3.so → _rotary_cuda_725ebfc.abi3.so} +1 -1
- build/torch210-cxx11-cu128-x86_64-linux/metadata.json +1 -1
- build/torch210-cxx11-cu130-x86_64-linux/_ops.py +3 -3
- build/torch210-cxx11-cu130-x86_64-linux/{_rotary_cuda_86f75d9.abi3.so → _rotary_cuda_725ebfc.abi3.so} +1 -1
- build/torch210-cxx11-cu130-x86_64-linux/metadata.json +1 -1
- build/torch210-cxx11-xpu20253-x86_64-linux/_ops.py +3 -3
- build/{torch211-cxx11-xpu20253-x86_64-linux/_rotary_xpu_86f75d9.abi3.so → torch210-cxx11-xpu20253-x86_64-linux/_rotary_xpu_725ebfc.abi3.so} +1 -1
- build/torch210-cxx11-xpu20253-x86_64-linux/metadata.json +1 -1
- build/torch211-cxx11-cu126-x86_64-linux/_ops.py +3 -3
- build/torch211-cxx11-cu126-x86_64-linux/{_rotary_cuda_86f75d9.abi3.so → _rotary_cuda_725ebfc.abi3.so} +1 -1
- build/torch211-cxx11-cu126-x86_64-linux/metadata.json +1 -1
- build/torch211-cxx11-cu128-x86_64-linux/_ops.py +3 -3
- build/torch211-cxx11-cu128-x86_64-linux/{_rotary_cuda_86f75d9.abi3.so → _rotary_cuda_725ebfc.abi3.so} +1 -1
- build/torch211-cxx11-cu128-x86_64-linux/metadata.json +1 -1
- build/torch211-cxx11-cu130-x86_64-linux/_ops.py +3 -3
- build/torch211-cxx11-cu130-x86_64-linux/{_rotary_cuda_86f75d9.abi3.so → _rotary_cuda_725ebfc.abi3.so} +1 -1
- build/torch211-cxx11-cu130-x86_64-linux/metadata.json +1 -1
- build/torch211-cxx11-xpu20253-x86_64-linux/_ops.py +3 -3
- build/{torch210-cxx11-xpu20253-x86_64-linux/_rotary_xpu_86f75d9.abi3.so → torch211-cxx11-xpu20253-x86_64-linux/_rotary_xpu_725ebfc.abi3.so} +1 -1
- build/torch211-cxx11-xpu20253-x86_64-linux/metadata.json +1 -1
- build/torch212-cxx11-cu126-x86_64-linux/__init__.py +52 -0
- build/torch212-cxx11-cu126-x86_64-linux/_ops.py +9 -0
- build/torch212-cxx11-cu126-x86_64-linux/_rotary_cuda_725ebfc.abi3.so +3 -0
- build/torch212-cxx11-cu126-x86_64-linux/metadata.json +20 -0
- build/torch212-cxx11-cu126-x86_64-linux/rotary/__init__.py +26 -0
- build/torch212-cxx11-cu130-x86_64-linux/__init__.py +52 -0
- build/torch212-cxx11-cu130-x86_64-linux/_ops.py +9 -0
- build/torch212-cxx11-cu130-x86_64-linux/_rotary_cuda_725ebfc.abi3.so +3 -0
- build/torch212-cxx11-cu130-x86_64-linux/metadata.json +21 -0
- build/torch212-cxx11-cu130-x86_64-linux/rotary/__init__.py +26 -0
- build/torch212-cxx11-cu132-x86_64-linux/__init__.py +52 -0
- build/torch212-cxx11-cu132-x86_64-linux/_ops.py +9 -0
- build/torch212-cxx11-cu132-x86_64-linux/_rotary_cuda_725ebfc.abi3.so +3 -0
- build/torch212-cxx11-cu132-x86_64-linux/metadata.json +21 -0
- build/torch212-cxx11-cu132-x86_64-linux/rotary/__init__.py +26 -0
- build/torch212-cxx11-xpu20253-x86_64-linux/__init__.py +52 -0
- build/torch212-cxx11-xpu20253-x86_64-linux/_ops.py +9 -0
- build/torch212-cxx11-xpu20253-x86_64-linux/_rotary_xpu_725ebfc.abi3.so +3 -0
- build/torch212-cxx11-xpu20253-x86_64-linux/metadata.json +10 -0
- build/torch212-cxx11-xpu20253-x86_64-linux/rotary/__init__.py +26 -0
build/torch210-cxx11-cu126-x86_64-linux/_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_cuda_725ebfc
|
| 3 |
+
ops = torch.ops._rotary_cuda_725ebfc
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_rotary_cuda_725ebfc::{op_name}"
|
build/torch210-cxx11-cu126-x86_64-linux/{_rotary_cuda_86f75d9.abi3.so → _rotary_cuda_725ebfc.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 8200568
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:39d341299aaec16caebbdebde5fa235e8d2fe93304f64f39d5d25aca27bb1e47
|
| 3 |
size 8200568
|
build/torch210-cxx11-cu126-x86_64-linux/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "rotary",
|
| 3 |
-
"id": "
|
| 4 |
"version": 1,
|
| 5 |
"license": "BSD-3-Clause",
|
| 6 |
"python-depends": [],
|
|
|
|
| 1 |
{
|
| 2 |
"name": "rotary",
|
| 3 |
+
"id": "_rotary_cuda_725ebfc",
|
| 4 |
"version": 1,
|
| 5 |
"license": "BSD-3-Clause",
|
| 6 |
"python-depends": [],
|
build/torch210-cxx11-cu128-x86_64-linux/_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_cuda_725ebfc
|
| 3 |
+
ops = torch.ops._rotary_cuda_725ebfc
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_rotary_cuda_725ebfc::{op_name}"
|
build/torch210-cxx11-cu128-x86_64-linux/{_rotary_cuda_86f75d9.abi3.so → _rotary_cuda_725ebfc.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 11905904
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cc218cdb6a055456094a6f518d2f3b43fb1a0d516907cc8dedee3d6511b3217b
|
| 3 |
size 11905904
|
build/torch210-cxx11-cu128-x86_64-linux/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "rotary",
|
| 3 |
-
"id": "
|
| 4 |
"version": 1,
|
| 5 |
"license": "BSD-3-Clause",
|
| 6 |
"python-depends": [],
|
|
|
|
| 1 |
{
|
| 2 |
"name": "rotary",
|
| 3 |
+
"id": "_rotary_cuda_725ebfc",
|
| 4 |
"version": 1,
|
| 5 |
"license": "BSD-3-Clause",
|
| 6 |
"python-depends": [],
|
build/torch210-cxx11-cu130-x86_64-linux/_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_cuda_725ebfc
|
| 3 |
+
ops = torch.ops._rotary_cuda_725ebfc
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_rotary_cuda_725ebfc::{op_name}"
|
build/torch210-cxx11-cu130-x86_64-linux/{_rotary_cuda_86f75d9.abi3.so → _rotary_cuda_725ebfc.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 10307160
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:51653f32f84e840f9e7182eb129bf31e528c513d59802f8560909cfcc3707b85
|
| 3 |
size 10307160
|
build/torch210-cxx11-cu130-x86_64-linux/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "rotary",
|
| 3 |
-
"id": "
|
| 4 |
"version": 1,
|
| 5 |
"license": "BSD-3-Clause",
|
| 6 |
"python-depends": [],
|
|
|
|
| 1 |
{
|
| 2 |
"name": "rotary",
|
| 3 |
+
"id": "_rotary_cuda_725ebfc",
|
| 4 |
"version": 1,
|
| 5 |
"license": "BSD-3-Clause",
|
| 6 |
"python-depends": [],
|
build/torch210-cxx11-xpu20253-x86_64-linux/_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_xpu_725ebfc
|
| 3 |
+
ops = torch.ops._rotary_xpu_725ebfc
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_rotary_xpu_725ebfc::{op_name}"
|
build/{torch211-cxx11-xpu20253-x86_64-linux/_rotary_xpu_86f75d9.abi3.so → torch210-cxx11-xpu20253-x86_64-linux/_rotary_xpu_725ebfc.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 2301504
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c1a6425022ede63a5cdaa95626f393fde741b34037d7bd588044d324c64a0588
|
| 3 |
size 2301504
|
build/torch210-cxx11-xpu20253-x86_64-linux/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "rotary",
|
| 3 |
-
"id": "
|
| 4 |
"version": 1,
|
| 5 |
"license": "BSD-3-Clause",
|
| 6 |
"python-depends": [],
|
|
|
|
| 1 |
{
|
| 2 |
"name": "rotary",
|
| 3 |
+
"id": "_rotary_xpu_725ebfc",
|
| 4 |
"version": 1,
|
| 5 |
"license": "BSD-3-Clause",
|
| 6 |
"python-depends": [],
|
build/torch211-cxx11-cu126-x86_64-linux/_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_cuda_725ebfc
|
| 3 |
+
ops = torch.ops._rotary_cuda_725ebfc
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_rotary_cuda_725ebfc::{op_name}"
|
build/torch211-cxx11-cu126-x86_64-linux/{_rotary_cuda_86f75d9.abi3.so → _rotary_cuda_725ebfc.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 8193600
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7b43b3223ec25d835af8c4020d87eca05c60efc111211a2a7196c3d692e77179
|
| 3 |
size 8193600
|
build/torch211-cxx11-cu126-x86_64-linux/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "rotary",
|
| 3 |
-
"id": "
|
| 4 |
"version": 1,
|
| 5 |
"license": "BSD-3-Clause",
|
| 6 |
"python-depends": [],
|
|
|
|
| 1 |
{
|
| 2 |
"name": "rotary",
|
| 3 |
+
"id": "_rotary_cuda_725ebfc",
|
| 4 |
"version": 1,
|
| 5 |
"license": "BSD-3-Clause",
|
| 6 |
"python-depends": [],
|
build/torch211-cxx11-cu128-x86_64-linux/_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_cuda_725ebfc
|
| 3 |
+
ops = torch.ops._rotary_cuda_725ebfc
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_rotary_cuda_725ebfc::{op_name}"
|
build/torch211-cxx11-cu128-x86_64-linux/{_rotary_cuda_86f75d9.abi3.so → _rotary_cuda_725ebfc.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 11894840
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3037fcf467a2bddcc34cfa70d188ae2ed190a87c6b56818f20c0c39b9bc2342f
|
| 3 |
size 11894840
|
build/torch211-cxx11-cu128-x86_64-linux/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "rotary",
|
| 3 |
-
"id": "
|
| 4 |
"version": 1,
|
| 5 |
"license": "BSD-3-Clause",
|
| 6 |
"python-depends": [],
|
|
|
|
| 1 |
{
|
| 2 |
"name": "rotary",
|
| 3 |
+
"id": "_rotary_cuda_725ebfc",
|
| 4 |
"version": 1,
|
| 5 |
"license": "BSD-3-Clause",
|
| 6 |
"python-depends": [],
|
build/torch211-cxx11-cu130-x86_64-linux/_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_cuda_725ebfc
|
| 3 |
+
ops = torch.ops._rotary_cuda_725ebfc
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_rotary_cuda_725ebfc::{op_name}"
|
build/torch211-cxx11-cu130-x86_64-linux/{_rotary_cuda_86f75d9.abi3.so → _rotary_cuda_725ebfc.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 10296096
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5d95c0078ab5f1e7462f6b607890d58044d40bd02a5ecd749c9e6cac33424faf
|
| 3 |
size 10296096
|
build/torch211-cxx11-cu130-x86_64-linux/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "rotary",
|
| 3 |
-
"id": "
|
| 4 |
"version": 1,
|
| 5 |
"license": "BSD-3-Clause",
|
| 6 |
"python-depends": [],
|
|
|
|
| 1 |
{
|
| 2 |
"name": "rotary",
|
| 3 |
+
"id": "_rotary_cuda_725ebfc",
|
| 4 |
"version": 1,
|
| 5 |
"license": "BSD-3-Clause",
|
| 6 |
"python-depends": [],
|
build/torch211-cxx11-xpu20253-x86_64-linux/_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_xpu_725ebfc
|
| 3 |
+
ops = torch.ops._rotary_xpu_725ebfc
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_rotary_xpu_725ebfc::{op_name}"
|
build/{torch210-cxx11-xpu20253-x86_64-linux/_rotary_xpu_86f75d9.abi3.so → torch211-cxx11-xpu20253-x86_64-linux/_rotary_xpu_725ebfc.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 2301504
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8482e87f3cb8d30070a9367ea2d01398497f52fc7e2369db3d763118c3c92566
|
| 3 |
size 2301504
|
build/torch211-cxx11-xpu20253-x86_64-linux/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "rotary",
|
| 3 |
-
"id": "
|
| 4 |
"version": 1,
|
| 5 |
"license": "BSD-3-Clause",
|
| 6 |
"python-depends": [],
|
|
|
|
| 1 |
{
|
| 2 |
"name": "rotary",
|
| 3 |
+
"id": "_rotary_xpu_725ebfc",
|
| 4 |
"version": 1,
|
| 5 |
"license": "BSD-3-Clause",
|
| 6 |
"python-depends": [],
|
build/torch212-cxx11-cu126-x86_64-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/torch212-cxx11-cu126-x86_64-linux/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _rotary_cuda_725ebfc
|
| 3 |
+
ops = torch.ops._rotary_cuda_725ebfc
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_rotary_cuda_725ebfc::{op_name}"
|
build/torch212-cxx11-cu126-x86_64-linux/_rotary_cuda_725ebfc.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b7e9bd09e74ab8c1a7468d01fc6c21185ef9fce899f24e020d09c17e8cfe4a08
|
| 3 |
+
size 8195384
|
build/torch212-cxx11-cu126-x86_64-linux/metadata.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "rotary",
|
| 3 |
+
"id": "_rotary_cuda_725ebfc",
|
| 4 |
+
"version": 1,
|
| 5 |
+
"license": "BSD-3-Clause",
|
| 6 |
+
"python-depends": [],
|
| 7 |
+
"backend": {
|
| 8 |
+
"type": "cuda",
|
| 9 |
+
"archs": [
|
| 10 |
+
"7.0",
|
| 11 |
+
"7.2",
|
| 12 |
+
"7.5",
|
| 13 |
+
"8.0",
|
| 14 |
+
"8.6",
|
| 15 |
+
"8.7",
|
| 16 |
+
"8.9",
|
| 17 |
+
"9.0+PTX"
|
| 18 |
+
]
|
| 19 |
+
}
|
| 20 |
+
}
|
build/torch212-cxx11-cu126-x86_64-linux/rotary/__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/torch212-cxx11-cu130-x86_64-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/torch212-cxx11-cu130-x86_64-linux/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _rotary_cuda_725ebfc
|
| 3 |
+
ops = torch.ops._rotary_cuda_725ebfc
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_rotary_cuda_725ebfc::{op_name}"
|
build/torch212-cxx11-cu130-x86_64-linux/_rotary_cuda_725ebfc.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:720b8c363ad2feaeda8476661c5627265524b8cd704a1b5f4c7946ef9e2d0c9c
|
| 3 |
+
size 10301968
|
build/torch212-cxx11-cu130-x86_64-linux/metadata.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "rotary",
|
| 3 |
+
"id": "_rotary_cuda_725ebfc",
|
| 4 |
+
"version": 1,
|
| 5 |
+
"license": "BSD-3-Clause",
|
| 6 |
+
"python-depends": [],
|
| 7 |
+
"backend": {
|
| 8 |
+
"type": "cuda",
|
| 9 |
+
"archs": [
|
| 10 |
+
"10.0",
|
| 11 |
+
"11.0",
|
| 12 |
+
"12.0+PTX",
|
| 13 |
+
"7.5",
|
| 14 |
+
"8.0",
|
| 15 |
+
"8.6",
|
| 16 |
+
"8.7",
|
| 17 |
+
"8.9",
|
| 18 |
+
"9.0"
|
| 19 |
+
]
|
| 20 |
+
}
|
| 21 |
+
}
|
build/torch212-cxx11-cu130-x86_64-linux/rotary/__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/torch212-cxx11-cu132-x86_64-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/torch212-cxx11-cu132-x86_64-linux/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _rotary_cuda_725ebfc
|
| 3 |
+
ops = torch.ops._rotary_cuda_725ebfc
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_rotary_cuda_725ebfc::{op_name}"
|
build/torch212-cxx11-cu132-x86_64-linux/_rotary_cuda_725ebfc.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:eb233b9be14a2d9c5bbb7b860973db6dd48aad4f5b760dd358880d079bff3b23
|
| 3 |
+
size 10490208
|
build/torch212-cxx11-cu132-x86_64-linux/metadata.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "rotary",
|
| 3 |
+
"id": "_rotary_cuda_725ebfc",
|
| 4 |
+
"version": 1,
|
| 5 |
+
"license": "BSD-3-Clause",
|
| 6 |
+
"python-depends": [],
|
| 7 |
+
"backend": {
|
| 8 |
+
"type": "cuda",
|
| 9 |
+
"archs": [
|
| 10 |
+
"10.0",
|
| 11 |
+
"11.0",
|
| 12 |
+
"12.0+PTX",
|
| 13 |
+
"7.5",
|
| 14 |
+
"8.0",
|
| 15 |
+
"8.6",
|
| 16 |
+
"8.7",
|
| 17 |
+
"8.9",
|
| 18 |
+
"9.0"
|
| 19 |
+
]
|
| 20 |
+
}
|
| 21 |
+
}
|
build/torch212-cxx11-cu132-x86_64-linux/rotary/__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/torch212-cxx11-xpu20253-x86_64-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/torch212-cxx11-xpu20253-x86_64-linux/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _rotary_xpu_725ebfc
|
| 3 |
+
ops = torch.ops._rotary_xpu_725ebfc
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_rotary_xpu_725ebfc::{op_name}"
|
build/torch212-cxx11-xpu20253-x86_64-linux/_rotary_xpu_725ebfc.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:42a11c6606ad23c9cd2f3e8dff22be3a2349efefff46a1e42cb87f7785b7fcb6
|
| 3 |
+
size 2301512
|
build/torch212-cxx11-xpu20253-x86_64-linux/metadata.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "rotary",
|
| 3 |
+
"id": "_rotary_xpu_725ebfc",
|
| 4 |
+
"version": 1,
|
| 5 |
+
"license": "BSD-3-Clause",
|
| 6 |
+
"python-depends": [],
|
| 7 |
+
"backend": {
|
| 8 |
+
"type": "xpu"
|
| 9 |
+
}
|
| 10 |
+
}
|
build/torch212-cxx11-xpu20253-x86_64-linux/rotary/__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")))
|