mlx-ternary / src /mlx_ternary /__init__.py
Jakevin's picture
Sync GitHub e6270bc: group 128 option, ragged-batch GEMM split, cleanup
8e6dc72 verified
Raw History Blame Contribute Delete
1 kB
# Copyright 2026 Jakevin
# SPDX-License-Identifier: Apache-2.0
"""Ternary linear layers for MLX.
Ternary carries about 1.85 bits of information per weight; it is stored
in 2-bit slots, so the resident size is 2.25 bits at group 64, the same as MLX 2-bit,
or 2.125 bits with the group 128 option.
"""
from mlx_ternary.convert import from_mlx_2bit, unpack_mlx_2bit
from mlx_ternary.kernel import configure, set_cache_limit, tern_matmul
from mlx_ternary.linear import TernaryLinear, replace_quantized_linears
from mlx_ternary.pack import (
GROUP,
GROUPS,
dequantize,
info_bits_per_weight,
pack_trits,
stored_bits_per_weight,
unpack_trits,
)
__version__ = "0.3.0"
__all__ = [
"GROUP",
"GROUPS",
"TernaryLinear",
"configure",
"dequantize",
"from_mlx_2bit",
"info_bits_per_weight",
"pack_trits",
"replace_quantized_linears",
"set_cache_limit",
"stored_bits_per_weight",
"tern_matmul",
"unpack_mlx_2bit",
"unpack_trits",
]