Mirror torch210 build into torch211 dir (Q5_0/Q5_1 ops)
Browse files
.gitattributes
CHANGED
|
@@ -40,3 +40,4 @@ build/torch29-metal-aarch64-darwin/_gguf_dequant_530e374.abi3.so filter=lfs diff
|
|
| 40 |
build/torch210-metal-aarch64-darwin/_gguf_dequant_b5e6652.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 41 |
build/torch28-metal-aarch64-darwin/_gguf_dequant_b5e6652.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 42 |
build/torch29-metal-aarch64-darwin/_gguf_dequant_b5e6652.abi3.so filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 40 |
build/torch210-metal-aarch64-darwin/_gguf_dequant_b5e6652.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 41 |
build/torch28-metal-aarch64-darwin/_gguf_dequant_b5e6652.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 42 |
build/torch29-metal-aarch64-darwin/_gguf_dequant_b5e6652.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 43 |
+
build/torch211-metal-aarch64-darwin/_gguf_dequant_b5e6652.abi3.so filter=lfs diff=lfs merge=lfs -text
|
build/torch211-metal-aarch64-darwin/__init__.py
CHANGED
|
@@ -72,6 +72,8 @@ def _pipeline(fn_name: str):
|
|
| 72 |
# (kernel_name, bytes_per_block, elems_per_block, threads_per_block_group)
|
| 73 |
_FORMATS = {
|
| 74 |
"q4_0": ("dequantize_q4_0", 18, 32, 16),
|
|
|
|
|
|
|
| 75 |
"q8_0": ("dequantize_q8_0", 34, 32, 32),
|
| 76 |
"q4_K": ("dequantize_q4_K", 144, 256, 256),
|
| 77 |
"q5_K": ("dequantize_q5_K", 176, 256, 256),
|
|
@@ -148,6 +150,8 @@ def dequantize_bytes(fmt: str, quant_bytes) -> np.ndarray:
|
|
| 148 |
# --- Per-format convenience wrappers ----------------------------------------
|
| 149 |
|
| 150 |
def dequantize_q4_0_bytes(qb): return dequantize_bytes("q4_0", qb)
|
|
|
|
|
|
|
| 151 |
def dequantize_q8_0_bytes(qb): return dequantize_bytes("q8_0", qb)
|
| 152 |
def dequantize_q4_K_bytes(qb): return dequantize_bytes("q4_K", qb)
|
| 153 |
def dequantize_q5_K_bytes(qb): return dequantize_bytes("q5_K", qb)
|
|
@@ -156,6 +160,8 @@ def dequantize_iq4_nl_bytes(qb): return dequantize_bytes("iq4_nl", qb)
|
|
| 156 |
def dequantize_iq4_xs_bytes(qb): return dequantize_bytes("iq4_xs", qb)
|
| 157 |
|
| 158 |
def allocate_q4_0_plan(nblocks): return allocate_plan("q4_0", nblocks)
|
|
|
|
|
|
|
| 159 |
def allocate_q8_0_plan(nblocks): return allocate_plan("q8_0", nblocks)
|
| 160 |
def allocate_q4_K_plan(nblocks): return allocate_plan("q4_K", nblocks)
|
| 161 |
def allocate_q5_K_plan(nblocks): return allocate_plan("q5_K", nblocks)
|
|
@@ -164,6 +170,8 @@ def allocate_iq4_nl_plan(nblocks): return allocate_plan("iq4_nl", nblocks)
|
|
| 164 |
def allocate_iq4_xs_plan(nblocks): return allocate_plan("iq4_xs", nblocks)
|
| 165 |
|
| 166 |
def dispatch_q4_0(plan, **kw): return dispatch(plan, **kw)
|
|
|
|
|
|
|
| 167 |
def dispatch_q8_0(plan, **kw): return dispatch(plan, **kw)
|
| 168 |
def dispatch_q4_K(plan, **kw): return dispatch(plan, **kw)
|
| 169 |
def dispatch_q5_K(plan, **kw): return dispatch(plan, **kw)
|
|
@@ -196,6 +204,8 @@ def _require_ops():
|
|
| 196 |
|
| 197 |
|
| 198 |
def torch_dequantize_q4_0(input, output): _require_ops().dequantize_q4_0(input, output)
|
|
|
|
|
|
|
| 199 |
def torch_dequantize_q8_0(input, output): _require_ops().dequantize_q8_0(input, output)
|
| 200 |
def torch_dequantize_q4_K(input, output): _require_ops().dequantize_q4_K(input, output)
|
| 201 |
def torch_dequantize_q5_K(input, output): _require_ops().dequantize_q5_K(input, output)
|
|
@@ -373,6 +383,8 @@ _N_SIMDGROUP = 2 # Q4_0/Q8_0 matvec uses 2 simdgroups per threadgroup
|
|
| 373 |
# Q6_K → 2 simdgroups × 1 row = 2 rows per threadgroup
|
| 374 |
_MAT_FORMATS = {
|
| 375 |
"q4_0": (18, 32, 8),
|
|
|
|
|
|
|
| 376 |
"q8_0": (34, 32, 8),
|
| 377 |
"q4_K": (144, 256, 4),
|
| 378 |
"q5_K": (176, 256, 4),
|
|
@@ -525,7 +537,7 @@ def encode_matvec(plan: MatVecPlan, enc):
|
|
| 525 |
if plan.fmt == "q4_K":
|
| 526 |
rows_per_tg = _N_DST
|
| 527 |
tg_threads = _SIMD_WIDTH
|
| 528 |
-
elif plan.fmt in ("q4_0", "q8_0"):
|
| 529 |
rows_per_tg = _N_SIMDGROUP * _N_DST
|
| 530 |
tg_threads = _N_SIMDGROUP * _SIMD_WIDTH
|
| 531 |
elif plan.fmt == "q5_K":
|
|
@@ -572,7 +584,7 @@ def dispatch_matvec(plan: MatVecPlan, sync: bool = True):
|
|
| 572 |
if plan.fmt == "q4_K":
|
| 573 |
rows_per_tg = _N_DST
|
| 574 |
tg_threads = _SIMD_WIDTH
|
| 575 |
-
elif plan.fmt in ("q4_0", "q8_0"):
|
| 576 |
rows_per_tg = _N_SIMDGROUP * _N_DST
|
| 577 |
tg_threads = _N_SIMDGROUP * _SIMD_WIDTH
|
| 578 |
elif plan.fmt == "q5_K":
|
|
|
|
| 72 |
# (kernel_name, bytes_per_block, elems_per_block, threads_per_block_group)
|
| 73 |
_FORMATS = {
|
| 74 |
"q4_0": ("dequantize_q4_0", 18, 32, 16),
|
| 75 |
+
"q5_0": ("dequantize_q5_0", 22, 32, 16),
|
| 76 |
+
"q5_1": ("dequantize_q5_1", 24, 32, 16),
|
| 77 |
"q8_0": ("dequantize_q8_0", 34, 32, 32),
|
| 78 |
"q4_K": ("dequantize_q4_K", 144, 256, 256),
|
| 79 |
"q5_K": ("dequantize_q5_K", 176, 256, 256),
|
|
|
|
| 150 |
# --- Per-format convenience wrappers ----------------------------------------
|
| 151 |
|
| 152 |
def dequantize_q4_0_bytes(qb): return dequantize_bytes("q4_0", qb)
|
| 153 |
+
def dequantize_q5_0_bytes(qb): return dequantize_bytes("q5_0", qb)
|
| 154 |
+
def dequantize_q5_1_bytes(qb): return dequantize_bytes("q5_1", qb)
|
| 155 |
def dequantize_q8_0_bytes(qb): return dequantize_bytes("q8_0", qb)
|
| 156 |
def dequantize_q4_K_bytes(qb): return dequantize_bytes("q4_K", qb)
|
| 157 |
def dequantize_q5_K_bytes(qb): return dequantize_bytes("q5_K", qb)
|
|
|
|
| 160 |
def dequantize_iq4_xs_bytes(qb): return dequantize_bytes("iq4_xs", qb)
|
| 161 |
|
| 162 |
def allocate_q4_0_plan(nblocks): return allocate_plan("q4_0", nblocks)
|
| 163 |
+
def allocate_q5_0_plan(nblocks): return allocate_plan("q5_0", nblocks)
|
| 164 |
+
def allocate_q5_1_plan(nblocks): return allocate_plan("q5_1", nblocks)
|
| 165 |
def allocate_q8_0_plan(nblocks): return allocate_plan("q8_0", nblocks)
|
| 166 |
def allocate_q4_K_plan(nblocks): return allocate_plan("q4_K", nblocks)
|
| 167 |
def allocate_q5_K_plan(nblocks): return allocate_plan("q5_K", nblocks)
|
|
|
|
| 170 |
def allocate_iq4_xs_plan(nblocks): return allocate_plan("iq4_xs", nblocks)
|
| 171 |
|
| 172 |
def dispatch_q4_0(plan, **kw): return dispatch(plan, **kw)
|
| 173 |
+
def dispatch_q5_0(plan, **kw): return dispatch(plan, **kw)
|
| 174 |
+
def dispatch_q5_1(plan, **kw): return dispatch(plan, **kw)
|
| 175 |
def dispatch_q8_0(plan, **kw): return dispatch(plan, **kw)
|
| 176 |
def dispatch_q4_K(plan, **kw): return dispatch(plan, **kw)
|
| 177 |
def dispatch_q5_K(plan, **kw): return dispatch(plan, **kw)
|
|
|
|
| 204 |
|
| 205 |
|
| 206 |
def torch_dequantize_q4_0(input, output): _require_ops().dequantize_q4_0(input, output)
|
| 207 |
+
def torch_dequantize_q5_0(input, output): _require_ops().dequantize_q5_0(input, output)
|
| 208 |
+
def torch_dequantize_q5_1(input, output): _require_ops().dequantize_q5_1(input, output)
|
| 209 |
def torch_dequantize_q8_0(input, output): _require_ops().dequantize_q8_0(input, output)
|
| 210 |
def torch_dequantize_q4_K(input, output): _require_ops().dequantize_q4_K(input, output)
|
| 211 |
def torch_dequantize_q5_K(input, output): _require_ops().dequantize_q5_K(input, output)
|
|
|
|
| 383 |
# Q6_K → 2 simdgroups × 1 row = 2 rows per threadgroup
|
| 384 |
_MAT_FORMATS = {
|
| 385 |
"q4_0": (18, 32, 8),
|
| 386 |
+
"q5_0": (22, 32, 8),
|
| 387 |
+
"q5_1": (24, 32, 8),
|
| 388 |
"q8_0": (34, 32, 8),
|
| 389 |
"q4_K": (144, 256, 4),
|
| 390 |
"q5_K": (176, 256, 4),
|
|
|
|
| 537 |
if plan.fmt == "q4_K":
|
| 538 |
rows_per_tg = _N_DST
|
| 539 |
tg_threads = _SIMD_WIDTH
|
| 540 |
+
elif plan.fmt in ("q4_0", "q5_0", "q5_1", "q8_0"):
|
| 541 |
rows_per_tg = _N_SIMDGROUP * _N_DST
|
| 542 |
tg_threads = _N_SIMDGROUP * _SIMD_WIDTH
|
| 543 |
elif plan.fmt == "q5_K":
|
|
|
|
| 584 |
if plan.fmt == "q4_K":
|
| 585 |
rows_per_tg = _N_DST
|
| 586 |
tg_threads = _SIMD_WIDTH
|
| 587 |
+
elif plan.fmt in ("q4_0", "q5_0", "q5_1", "q8_0"):
|
| 588 |
rows_per_tg = _N_SIMDGROUP * _N_DST
|
| 589 |
tg_threads = _N_SIMDGROUP * _SIMD_WIDTH
|
| 590 |
elif plan.fmt == "q5_K":
|
build/torch211-metal-aarch64-darwin/_gguf_dequant_b5e6652.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b63257ac532059de9a913434d4653f070828f0202d42777510c7868bdf4387a0
|
| 3 |
+
size 287104
|
build/torch211-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 _gguf_dequant_b5e6652
|
| 3 |
+
ops = torch.ops._gguf_dequant_b5e6652
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_gguf_dequant_b5e6652::{op_name}"
|