Uploaded using `kernel-builder`.
Browse files- .gitattributes +3 -0
- build/torch210-cxx11-cpu-x86_64-linux/_ops.py +3 -3
- build/torch210-cxx11-cpu-x86_64-linux/{_quantization_bitsandbytes_cpu_86f75d9.abi3.so → _quantization_bitsandbytes_cpu_817f262.abi3.so} +1 -1
- build/torch210-cxx11-cpu-x86_64-linux/metadata.json +1 -1
- build/torch211-cxx11-cpu-x86_64-linux/_ops.py +3 -3
- build/torch211-cxx11-cpu-x86_64-linux/{_quantization_bitsandbytes_cpu_86f75d9.abi3.so → _quantization_bitsandbytes_cpu_817f262.abi3.so} +1 -1
- build/torch211-cxx11-cpu-x86_64-linux/metadata.json +1 -1
- build/torch212-cxx11-cpu-x86_64-linux/__init__.py +3 -0
- build/torch212-cxx11-cpu-x86_64-linux/_ops.py +9 -0
- build/torch212-cxx11-cpu-x86_64-linux/_quantization_bitsandbytes_cpu_817f262.abi3.so +3 -0
- build/torch212-cxx11-cpu-x86_64-linux/custom_ops.py +19 -0
- build/torch212-cxx11-cpu-x86_64-linux/metadata.json +10 -0
- build/torch212-cxx11-cpu-x86_64-linux/quantization_bitsandbytes/__init__.py +26 -0
.gitattributes
CHANGED
|
@@ -59,3 +59,6 @@ build/torch210-cxx11-cpu-x86_64-linux/_quantization_bitsandbytes_cpu_e09894a.abi
|
|
| 59 |
build/torch211-cxx11-cpu-x86_64-linux/_quantization_bitsandbytes_cpu_e09894a.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 60 |
build/torch210-cxx11-cpu-x86_64-linux/_quantization_bitsandbytes_cpu_86f75d9.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 61 |
build/torch211-cxx11-cpu-x86_64-linux/_quantization_bitsandbytes_cpu_86f75d9.abi3.so filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
build/torch211-cxx11-cpu-x86_64-linux/_quantization_bitsandbytes_cpu_e09894a.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 60 |
build/torch210-cxx11-cpu-x86_64-linux/_quantization_bitsandbytes_cpu_86f75d9.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 61 |
build/torch211-cxx11-cpu-x86_64-linux/_quantization_bitsandbytes_cpu_86f75d9.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 62 |
+
build/torch210-cxx11-cpu-x86_64-linux/_quantization_bitsandbytes_cpu_817f262.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 63 |
+
build/torch211-cxx11-cpu-x86_64-linux/_quantization_bitsandbytes_cpu_817f262.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 64 |
+
build/torch212-cxx11-cpu-x86_64-linux/_quantization_bitsandbytes_cpu_817f262.abi3.so filter=lfs diff=lfs merge=lfs -text
|
build/torch210-cxx11-cpu-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 _quantization_bitsandbytes_cpu_817f262
|
| 3 |
+
ops = torch.ops._quantization_bitsandbytes_cpu_817f262
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_quantization_bitsandbytes_cpu_817f262::{op_name}"
|
build/torch210-cxx11-cpu-x86_64-linux/{_quantization_bitsandbytes_cpu_86f75d9.abi3.so → _quantization_bitsandbytes_cpu_817f262.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 1993840
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ead6baa630df2338c3a3b09107d51e7af1e5014e4ee2d4960d1a43a360e85b1f
|
| 3 |
size 1993840
|
build/torch210-cxx11-cpu-x86_64-linux/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "quantization-bitsandbytes",
|
| 3 |
-
"id": "
|
| 4 |
"version": 1,
|
| 5 |
"license": "MIT",
|
| 6 |
"python-depends": [],
|
|
|
|
| 1 |
{
|
| 2 |
"name": "quantization-bitsandbytes",
|
| 3 |
+
"id": "_quantization_bitsandbytes_cpu_817f262",
|
| 4 |
"version": 1,
|
| 5 |
"license": "MIT",
|
| 6 |
"python-depends": [],
|
build/torch211-cxx11-cpu-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 _quantization_bitsandbytes_cpu_817f262
|
| 3 |
+
ops = torch.ops._quantization_bitsandbytes_cpu_817f262
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_quantization_bitsandbytes_cpu_817f262::{op_name}"
|
build/torch211-cxx11-cpu-x86_64-linux/{_quantization_bitsandbytes_cpu_86f75d9.abi3.so → _quantization_bitsandbytes_cpu_817f262.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 1993840
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d040bd66e1feb75b566ff987f9ac4baf00520ee9252608f5427f96dd458d59fc
|
| 3 |
size 1993840
|
build/torch211-cxx11-cpu-x86_64-linux/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "quantization-bitsandbytes",
|
| 3 |
-
"id": "
|
| 4 |
"version": 1,
|
| 5 |
"license": "MIT",
|
| 6 |
"python-depends": [],
|
|
|
|
| 1 |
{
|
| 2 |
"name": "quantization-bitsandbytes",
|
| 3 |
+
"id": "_quantization_bitsandbytes_cpu_817f262",
|
| 4 |
"version": 1,
|
| 5 |
"license": "MIT",
|
| 6 |
"python-depends": [],
|
build/torch212-cxx11-cpu-x86_64-linux/__init__.py
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .custom_ops import gemm_4bit_forward
|
| 2 |
+
|
| 3 |
+
__all__ = ["gemm_4bit_forward"]
|
build/torch212-cxx11-cpu-x86_64-linux/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _quantization_bitsandbytes_cpu_817f262
|
| 3 |
+
ops = torch.ops._quantization_bitsandbytes_cpu_817f262
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_quantization_bitsandbytes_cpu_817f262::{op_name}"
|
build/torch212-cxx11-cpu-x86_64-linux/_quantization_bitsandbytes_cpu_817f262.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ba7d51e9f9a7f540f80697163c3caffdae7c2f036904cee93e6d9406f28a4741
|
| 3 |
+
size 1993856
|
build/torch212-cxx11-cpu-x86_64-linux/custom_ops.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from ._ops import ops
|
| 3 |
+
|
| 4 |
+
def gemm_4bit_forward(
|
| 5 |
+
input: torch.Tensor,
|
| 6 |
+
weight: torch.Tensor,
|
| 7 |
+
absmax: torch.Tensor,
|
| 8 |
+
blocksize: int,
|
| 9 |
+
quant_type: int,
|
| 10 |
+
) -> torch.Tensor:
|
| 11 |
+
original_dtype = input.dtype
|
| 12 |
+
if original_dtype != torch.bfloat16:
|
| 13 |
+
input = input.to(torch.bfloat16)
|
| 14 |
+
|
| 15 |
+
output = ops.gemm_4bit_forward(input, weight, absmax, blocksize, quant_type)
|
| 16 |
+
if original_dtype != torch.bfloat16:
|
| 17 |
+
output = output.to(original_dtype)
|
| 18 |
+
|
| 19 |
+
return output
|
build/torch212-cxx11-cpu-x86_64-linux/metadata.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "quantization-bitsandbytes",
|
| 3 |
+
"id": "_quantization_bitsandbytes_cpu_817f262",
|
| 4 |
+
"version": 1,
|
| 5 |
+
"license": "MIT",
|
| 6 |
+
"python-depends": [],
|
| 7 |
+
"backend": {
|
| 8 |
+
"type": "cpu"
|
| 9 |
+
}
|
| 10 |
+
}
|
build/torch212-cxx11-cpu-x86_64-linux/quantization_bitsandbytes/__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")))
|