SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2407.00088 · 2024

T-MAC: CPU Renaissance via Table Lookup for Low-Bit LLM Deployment on Edge

arXiv · PDF · Open in the Atlas

Code that ran

We lifted 8 functions out of this paper's own repositories and ran 5 of them in a sandbox. "Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results.

RepositoryRoleRan
microsoft/t-mac canonical 5 of 8
FunctionStatusWhere it lives
get_arch Ran microsoft/t-mac/python/t_mac/platform.py
code served (permissive licence) · get_code("412a24552d314af7")
get_bits_alphas Ran microsoft/t-mac/python/t_mac/utils.py
code served (permissive licence) · get_code("be89b3398da1efcf")
get_default_device_kwargs Ran microsoft/t-mac/python/t_mac/platform.py
code served (permissive licence) · get_code("50425b60439fb8d5")
nmse Ran microsoft/t-mac/python/t_mac/utils.py
code served (permissive licence) · get_code("5b5ce60e0071b862")
parse_gptqv2 Ran microsoft/t-mac/python/t_mac/model_utils.py
code served (permissive licence) · get_code("9d3bb76a4b171ef5")
extract_kernel_shapes Not yet run microsoft/t-mac/python/t_mac/model_utils.py
code served (permissive licence) · get_code("6813bd471865aed7")
preprocess_weights Not yet run microsoft/t-mac/python/t_mac/weights.py
code served (permissive licence) · get_code("ba0a4cb84015268a")
unpack_gptqv2 Not yet run microsoft/t-mac/python/t_mac/model_utils.py
code served (permissive licence) · get_code("e9bdf6ffe908f77e")

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

The deployment of Large Language Models (LLMs) on edge devices is increasingly important to enhance on-device intelligence. Weight quantization is crucial for reducing the memory footprint of LLMs on devices. However, low-bit LLMs necessitate mixed precision matrix multiplication (mpGEMM) of low precision weights and high precision activations during inference. Existing systems, lacking native support for mpGEMM, resort to dequantize weights for high precision computation. Such an indirect way can lead to a significant inference overhead. In this paper, we introduce T-MAC, an innovative lookup table(LUT)-based method designed for efficient low-bit LLM (i.e., weight-quantized LLM) inference on CPUs. T-MAC directly supports mpGEMM without dequantization, while simultaneously eliminating multiplications and reducing additions required. Specifically, T-MAC transforms the traditional data-type-centric multiplication to bit-wise table lookup, and enables a unified and scalable mpGEMM solution. Our LUT-based kernels scale linearly to the weight bit-width. Evaluated on low-bit Llama and BitNet models, T-MAC demonstrates up to 4x increase in throughput and 70% reduction in energy consumption compared to llama.cpp. For BitNet-b1.58-3B, T-MAC delivers a token generation throughput of 30 tokens/s with a single core and 71 tokens/s with eight cores on M2-Ultra, and 11 tokens/s on lower-end devices like Raspberry Pi 5, which significantly exceeds the adult average reading speed. T-MAC with LUT-based computing paradigm, paves the way for the practical deployment of low-bit LLMs on resource-constrained edge devices without compromising computational efficiency. The system is open-sourced at https://github.com/microsoft/T-MAC .

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2407.00088")
get_code_for_paper("2407.00088")
have("2407.00088")

Connect an agent — have() is free.