• Stars
    star
    167
  • Rank 225,339 (Top 5 %)
  • Language
    C++
  • License
    Apache License 2.0
  • Created 11 months ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Repository for the QUIK project, enabling the use of 4bit kernels for generative inference

QUIK

This repository contains the code for QUIK, a method for quantizing the majority of the weights and activations to 4bit post-training.

QUIK is described in the following paper: https://arxiv.org/abs/2310.09259

Install

Dependencies

  • cmake
  • C++ compiler (GCC/clang/...)
  • nvcc

Instructions

git clone https://github.com/IST-DASLab/QUIK.git
cd QUIK
pip install -e .  # or pip install .

Example

LLama example

cd experiments
pip install -r requirements.txt
python llama.py --fp_features_num 256 --model meta-llama/Llama-2-7b-hf --hf_token <your_hf_token> --dataset c4 \ 
--w_bits 4 --w_clip --a_bits 4 --save_qmodel_path save_gptq_model_path --int8_down_proj --sim_eval --benchmark 

Benchmark will be run on all available GPUs.

Linear layer benchmarks

Linear layer benchmarks can be run with python layer_benchmark.py. One can vary input size with command line parameters.

Model adapt to QUIK

First, one has to quantize the model weights using GPTQ algorithm. In llama.py it is done with llama_sequential function. From that we get quantized weights (that are still stored in torch.float16). Then ones needs create QUIK Linear layers using qlinear.MixedQLinear.from_float that must replace original Linear layers. See llama_replace_with_kernels in llama.py. Now the quantized model is ready for use.

Fake Quantization examples

To run the fake quantization example, check fake_quant directory.

Citation

The full paper is available on arxiv. The full citation is

@article{QUIK,
  title={QUIK: Towards End-to-end 4-Bit Inference on Generative Large Language Models},
  author={Ashkboos, Saleh and Markov, Ilia and Frantar, Elias and Zhong, Tingxuan and Wang, Xincheng and Ren, Jie and Hoefler, Torsten and Alistarh, Dan},
  journal={arXiv preprint arXiv:2310.09259},
  year={2023}
}

More Repositories

1

gptq

Code for the ICLR 2023 paper "GPTQ: Accurate Post-training Quantization of Generative Pretrained Transformers".
Python
1,872
star
2

sparsegpt

Code for the ICML 2023 paper "SparseGPT: Massive Language Models Can Be Accurately Pruned in One-Shot".
Python
694
star
3

marlin

FP16xINT4 LLM inference kernel that can achieve near-ideal ~4x speedups up to medium batchsizes of 16-32 tokens.
Python
557
star
4

qmoe

Code for the paper "QMoE: Practical Sub-1-Bit Compression of Trillion-Parameter Models".
Python
258
star
5

PanzaMail

Python
254
star
6

OBC

Code for the NeurIPS 2022 paper "Optimal Brain Compression: A Framework for Accurate Post-Training Quantization and Pruning".
Python
95
star
7

Sparse-Marlin

Boosting 4-bit inference kernels with 2:4 Sparsity
Cuda
46
star
8

WoodFisher

Code accompanying the NeurIPS 2020 paper: WoodFisher (Singh & Alistarh, 2020)
Python
45
star
9

SparseFinetuning

Repository for Sparse Finetuning of LLMs via modified version of the MosaicML llmfoundry
Python
36
star
10

RoSA

Python
29
star
11

QIGen

Repository for CPU Kernel Generation for LLM Inference
Python
25
star
12

ACDC

Code for reproducing "AC/DC: Alternating Compressed/DeCompressed Training of Deep Neural Networks" (NeurIPS 2021)
Python
20
star
13

spdy

Code for ICML 2022 paper "SPDY: Accurate Pruning with Speedup Guarantees"
Python
18
star
14

M-FAC

Efficient reference implementations of the static & dynamic M-FAC algorithms (for pruning and optimization)
Python
16
star
15

torch_cgx

Pytorch distributed backend extension with compression support
C++
14
star
16

sparseprop

C++
13
star
17

peft-rosa

A fork of the PEFT library, supporting Robust Adaptation (RoSA)
Python
13
star
18

sparse-imagenet-transfer

Code for reproducing the results in "How Well do Sparse Imagenet Models Transfer?", presented at CVPR 2022
Python
8
star
19

CrAM

Code for reproducing the results from "CrAM: A Compression-Aware Minimizer" accepted at ICLR 2023
Python
8
star
20

MicroAdam

This repository contains code for the MicroAdam paper.
Python
8
star
21

spops

C++
6
star
22

ISTA-DASLab-Optimizers

Python
5
star
23

EFCP

The repository contains code to reproduce the experiments from our paper Error Feedback Can Accurately Compress Preconditioners available below:
Python
4
star
24

pruned-vision-model-bias

Code for reproducing the paper "Bias in Pruned Vision Models: In-Depth Analysis and Countermeasures"
Jupyter Notebook
4
star
25

Mathador-LM

Code for the paper "Mathador-LM: A Dynamic Benchmark for Mathematical Reasoning on LLMs".
Python
4
star
26

CAP

Repository for Correlation Aware Prune (NeurIPS23) source and experimental code
Python
4
star
27

evolution-strategies

Python
2
star
28

TACO4NLP

Task aware compression for various NLP tasks
Python
2
star
29

smart-quantizer

Repository for Vitaly's implementation of the distribution-adaptive quantizer
Python
1
star
30

ZipLM

Code for the NeurIPS 2023 paper: "ZipLM: Inference-Aware Structured Pruning of Language Models".
1
star
31

QRGD

Repository for the implementation of "Distributed Principal Component Analysis with Limited Communication" (Alimisis et al., NeurIPS 2021). Parts of this code were originally based on code from "Communication-Efficient Distributed PCA by Riemannian Optimization" (Huang and Pan, ICML 2020).
MATLAB
1
star
32

KDVR

Code for the experiments in Knowledge Distillation Performs Partial Variance Reduction, NeurIPS 2023
Python
1
star