Uploaded using `kernel-builder`.
Browse files- build/torch212-metal-aarch64-darwin/__init__.py +21 -1
- build/torch212-metal-aarch64-darwin/{_ggml_quantization_metal_091adac.abi3.so → _ggml_quantization_metal_9534e0b.abi3.so} +2 -2
- build/torch212-metal-aarch64-darwin/_ops.py +3 -3
- build/torch212-metal-aarch64-darwin/metadata.json +5 -5
- build/torch213-metal-aarch64-darwin/__init__.py +21 -1
- build/torch213-metal-aarch64-darwin/{_ggml_quantization_metal_091adac.abi3.so → _ggml_quantization_metal_9534e0b.abi3.so} +2 -2
- build/torch213-metal-aarch64-darwin/_ops.py +3 -3
- build/torch213-metal-aarch64-darwin/metadata.json +5 -5
build/torch212-metal-aarch64-darwin/__init__.py
CHANGED
|
@@ -14,7 +14,7 @@ import torch
|
|
| 14 |
from ._ops import add_op_namespace_prefix, ops
|
| 15 |
|
| 16 |
|
| 17 |
-
__all__ = ["GEMV_TYPES", "MAX_GEMV_ROWS", "dequantize", "get_rows", "mul_mat_vec"]
|
| 18 |
|
| 19 |
# Upstream's MMVQ_MAX_BATCH_SIZE: `mul_mat_vec` has no implementation beyond this many rows, so a
|
| 20 |
# caller with more (prefill) dequantizes and uses an ordinary matmul.
|
|
@@ -62,6 +62,21 @@ def mul_mat_vec(
|
|
| 62 |
return ops.mul_mat_vec(blocks, x, ggml_type, out_features)
|
| 63 |
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
# Without these, torch.compile cannot trace the ops and breaks the graph at every call.
|
| 66 |
@torch.library.register_fake(add_op_namespace_prefix("get_rows"))
|
| 67 |
def _get_rows_fake(blocks, indices, ggml_type, cols, dtype):
|
|
@@ -76,3 +91,8 @@ def _dequantize_fake(blocks, ggml_type, rows, cols, dtype):
|
|
| 76 |
@torch.library.register_fake(add_op_namespace_prefix("mul_mat_vec"))
|
| 77 |
def _mul_mat_vec_fake(blocks, x, ggml_type, out_features):
|
| 78 |
return x.new_empty((x.shape[0], out_features), dtype=torch.float32)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
from ._ops import add_op_namespace_prefix, ops
|
| 15 |
|
| 16 |
|
| 17 |
+
__all__ = ["GEMV_TYPES", "MAX_GEMV_ROWS", "dequantize", "get_rows", "mul_mat_id", "mul_mat_vec"]
|
| 18 |
|
| 19 |
# Upstream's MMVQ_MAX_BATCH_SIZE: `mul_mat_vec` has no implementation beyond this many rows, so a
|
| 20 |
# caller with more (prefill) dequantizes and uses an ordinary matmul.
|
|
|
|
| 62 |
return ops.mul_mat_vec(blocks, x, ggml_type, out_features)
|
| 63 |
|
| 64 |
|
| 65 |
+
def mul_mat_id(
|
| 66 |
+
blocks: torch.Tensor, x: torch.Tensor, ids: torch.Tensor, ggml_type: int, out_features: int
|
| 67 |
+
) -> torch.Tensor:
|
| 68 |
+
"""One dispatch for a bank of routed experts: ggml's `mul_mv_id`.
|
| 69 |
+
|
| 70 |
+
`blocks` is `(n_experts, out_features, bytes_per_row)`, `x` is `(n_tokens, in_features)`, and
|
| 71 |
+
`ids` is `(n_tokens, n_used)` naming the expert each of a token's slots picked. The result is
|
| 72 |
+
`(n_tokens, n_used, out_features)` f32, one row per slot.
|
| 73 |
+
|
| 74 |
+
The alternative is a gemv per expert per layer, whose arithmetic is dwarfed by the dispatch
|
| 75 |
+
around it -- which is most of what a MoE decode step costs.
|
| 76 |
+
"""
|
| 77 |
+
return ops.mul_mat_id(blocks, x, ids, ggml_type, out_features)
|
| 78 |
+
|
| 79 |
+
|
| 80 |
# Without these, torch.compile cannot trace the ops and breaks the graph at every call.
|
| 81 |
@torch.library.register_fake(add_op_namespace_prefix("get_rows"))
|
| 82 |
def _get_rows_fake(blocks, indices, ggml_type, cols, dtype):
|
|
|
|
| 91 |
@torch.library.register_fake(add_op_namespace_prefix("mul_mat_vec"))
|
| 92 |
def _mul_mat_vec_fake(blocks, x, ggml_type, out_features):
|
| 93 |
return x.new_empty((x.shape[0], out_features), dtype=torch.float32)
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
@torch.library.register_fake(add_op_namespace_prefix("mul_mat_id"))
|
| 97 |
+
def _mul_mat_id_fake(blocks, x, ids, ggml_type, out_features):
|
| 98 |
+
return x.new_empty((x.shape[0], ids.shape[1], out_features), dtype=torch.float32)
|
build/torch212-metal-aarch64-darwin/{_ggml_quantization_metal_091adac.abi3.so → _ggml_quantization_metal_9534e0b.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:cb93e4485ad772dddca1ee0510c8b2c50ddacae22914c6a6164ae37deb9430a6
|
| 3 |
+
size 3347416
|
build/torch212-metal-aarch64-darwin/_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 _ggml_quantization_metal_9534e0b
|
| 3 |
+
ops = torch.ops._ggml_quantization_metal_9534e0b
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_ggml_quantization_metal_9534e0b::{op_name}"
|
build/torch212-metal-aarch64-darwin/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "ggml-quantization",
|
| 3 |
-
"id": "
|
| 4 |
"version": 1,
|
| 5 |
"license": "MIT",
|
| 6 |
"python-depends": [],
|
|
@@ -10,9 +10,9 @@
|
|
| 10 |
"digest": {
|
| 11 |
"algorithm": "sha256",
|
| 12 |
"files": {
|
| 13 |
-
"__init__.py": "
|
| 14 |
-
"
|
| 15 |
-
"_ops.py": "
|
| 16 |
}
|
| 17 |
},
|
| 18 |
"provenance": {
|
|
@@ -22,7 +22,7 @@
|
|
| 22 |
"dirty": false
|
| 23 |
},
|
| 24 |
"kernel": {
|
| 25 |
-
"sha": "
|
| 26 |
"dirty": false
|
| 27 |
}
|
| 28 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"name": "ggml-quantization",
|
| 3 |
+
"id": "_ggml_quantization_metal_9534e0b",
|
| 4 |
"version": 1,
|
| 5 |
"license": "MIT",
|
| 6 |
"python-depends": [],
|
|
|
|
| 10 |
"digest": {
|
| 11 |
"algorithm": "sha256",
|
| 12 |
"files": {
|
| 13 |
+
"__init__.py": "iPXgZXBgY3CzpNUSjmCovMVNPLBol1KBaNoTzkXp5mM=",
|
| 14 |
+
"_ggml_quantization_metal_9534e0b.abi3.so": "y5PkSFrXct3coe4FEMiyxQ3ayuIpFMamFkrjfeuUMKY=",
|
| 15 |
+
"_ops.py": "sK+sDWDDfYKJPFFj+YTyiancoGDCqiBXKU7B6dK+xvg="
|
| 16 |
}
|
| 17 |
},
|
| 18 |
"provenance": {
|
|
|
|
| 22 |
"dirty": false
|
| 23 |
},
|
| 24 |
"kernel": {
|
| 25 |
+
"sha": "9534e0b885d397dae61825fd15c158b94e815650",
|
| 26 |
"dirty": false
|
| 27 |
}
|
| 28 |
}
|
build/torch213-metal-aarch64-darwin/__init__.py
CHANGED
|
@@ -14,7 +14,7 @@ import torch
|
|
| 14 |
from ._ops import add_op_namespace_prefix, ops
|
| 15 |
|
| 16 |
|
| 17 |
-
__all__ = ["GEMV_TYPES", "MAX_GEMV_ROWS", "dequantize", "get_rows", "mul_mat_vec"]
|
| 18 |
|
| 19 |
# Upstream's MMVQ_MAX_BATCH_SIZE: `mul_mat_vec` has no implementation beyond this many rows, so a
|
| 20 |
# caller with more (prefill) dequantizes and uses an ordinary matmul.
|
|
@@ -62,6 +62,21 @@ def mul_mat_vec(
|
|
| 62 |
return ops.mul_mat_vec(blocks, x, ggml_type, out_features)
|
| 63 |
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
# Without these, torch.compile cannot trace the ops and breaks the graph at every call.
|
| 66 |
@torch.library.register_fake(add_op_namespace_prefix("get_rows"))
|
| 67 |
def _get_rows_fake(blocks, indices, ggml_type, cols, dtype):
|
|
@@ -76,3 +91,8 @@ def _dequantize_fake(blocks, ggml_type, rows, cols, dtype):
|
|
| 76 |
@torch.library.register_fake(add_op_namespace_prefix("mul_mat_vec"))
|
| 77 |
def _mul_mat_vec_fake(blocks, x, ggml_type, out_features):
|
| 78 |
return x.new_empty((x.shape[0], out_features), dtype=torch.float32)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
from ._ops import add_op_namespace_prefix, ops
|
| 15 |
|
| 16 |
|
| 17 |
+
__all__ = ["GEMV_TYPES", "MAX_GEMV_ROWS", "dequantize", "get_rows", "mul_mat_id", "mul_mat_vec"]
|
| 18 |
|
| 19 |
# Upstream's MMVQ_MAX_BATCH_SIZE: `mul_mat_vec` has no implementation beyond this many rows, so a
|
| 20 |
# caller with more (prefill) dequantizes and uses an ordinary matmul.
|
|
|
|
| 62 |
return ops.mul_mat_vec(blocks, x, ggml_type, out_features)
|
| 63 |
|
| 64 |
|
| 65 |
+
def mul_mat_id(
|
| 66 |
+
blocks: torch.Tensor, x: torch.Tensor, ids: torch.Tensor, ggml_type: int, out_features: int
|
| 67 |
+
) -> torch.Tensor:
|
| 68 |
+
"""One dispatch for a bank of routed experts: ggml's `mul_mv_id`.
|
| 69 |
+
|
| 70 |
+
`blocks` is `(n_experts, out_features, bytes_per_row)`, `x` is `(n_tokens, in_features)`, and
|
| 71 |
+
`ids` is `(n_tokens, n_used)` naming the expert each of a token's slots picked. The result is
|
| 72 |
+
`(n_tokens, n_used, out_features)` f32, one row per slot.
|
| 73 |
+
|
| 74 |
+
The alternative is a gemv per expert per layer, whose arithmetic is dwarfed by the dispatch
|
| 75 |
+
around it -- which is most of what a MoE decode step costs.
|
| 76 |
+
"""
|
| 77 |
+
return ops.mul_mat_id(blocks, x, ids, ggml_type, out_features)
|
| 78 |
+
|
| 79 |
+
|
| 80 |
# Without these, torch.compile cannot trace the ops and breaks the graph at every call.
|
| 81 |
@torch.library.register_fake(add_op_namespace_prefix("get_rows"))
|
| 82 |
def _get_rows_fake(blocks, indices, ggml_type, cols, dtype):
|
|
|
|
| 91 |
@torch.library.register_fake(add_op_namespace_prefix("mul_mat_vec"))
|
| 92 |
def _mul_mat_vec_fake(blocks, x, ggml_type, out_features):
|
| 93 |
return x.new_empty((x.shape[0], out_features), dtype=torch.float32)
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
@torch.library.register_fake(add_op_namespace_prefix("mul_mat_id"))
|
| 97 |
+
def _mul_mat_id_fake(blocks, x, ids, ggml_type, out_features):
|
| 98 |
+
return x.new_empty((x.shape[0], ids.shape[1], out_features), dtype=torch.float32)
|
build/torch213-metal-aarch64-darwin/{_ggml_quantization_metal_091adac.abi3.so → _ggml_quantization_metal_9534e0b.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:1b6a747eb385d07f816173e4506930633a671e56a68cf52cd59c164344847381
|
| 3 |
+
size 3347416
|
build/torch213-metal-aarch64-darwin/_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 _ggml_quantization_metal_9534e0b
|
| 3 |
+
ops = torch.ops._ggml_quantization_metal_9534e0b
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_ggml_quantization_metal_9534e0b::{op_name}"
|
build/torch213-metal-aarch64-darwin/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "ggml-quantization",
|
| 3 |
-
"id": "
|
| 4 |
"version": 1,
|
| 5 |
"license": "MIT",
|
| 6 |
"python-depends": [],
|
|
@@ -10,9 +10,9 @@
|
|
| 10 |
"digest": {
|
| 11 |
"algorithm": "sha256",
|
| 12 |
"files": {
|
| 13 |
-
"__init__.py": "
|
| 14 |
-
"
|
| 15 |
-
"_ops.py": "
|
| 16 |
}
|
| 17 |
},
|
| 18 |
"provenance": {
|
|
@@ -22,7 +22,7 @@
|
|
| 22 |
"dirty": false
|
| 23 |
},
|
| 24 |
"kernel": {
|
| 25 |
-
"sha": "
|
| 26 |
"dirty": false
|
| 27 |
}
|
| 28 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"name": "ggml-quantization",
|
| 3 |
+
"id": "_ggml_quantization_metal_9534e0b",
|
| 4 |
"version": 1,
|
| 5 |
"license": "MIT",
|
| 6 |
"python-depends": [],
|
|
|
|
| 10 |
"digest": {
|
| 11 |
"algorithm": "sha256",
|
| 12 |
"files": {
|
| 13 |
+
"__init__.py": "iPXgZXBgY3CzpNUSjmCovMVNPLBol1KBaNoTzkXp5mM=",
|
| 14 |
+
"_ggml_quantization_metal_9534e0b.abi3.so": "G2p0frOF0H+BYXPkUGkwYzpnHlamjPUs1ZwWQ0SEc4E=",
|
| 15 |
+
"_ops.py": "sK+sDWDDfYKJPFFj+YTyiancoGDCqiBXKU7B6dK+xvg="
|
| 16 |
}
|
| 17 |
},
|
| 18 |
"provenance": {
|
|
|
|
| 22 |
"dirty": false
|
| 23 |
},
|
| 24 |
"kernel": {
|
| 25 |
+
"sha": "9534e0b885d397dae61825fd15c158b94e815650",
|
| 26 |
"dirty": false
|
| 27 |
}
|
| 28 |
}
|