Tencent/AngelSlim

GitHub: Tencent/AngelSlim

腾讯开源的大模型压缩工具包,提供量化、投机解码、蒸馏等多种压缩策略的统一框架。

Stars: 1503 | Forks: 171

English | [简体中文](README_cn.md)

AngelSlim

A more accessible, comprehensive, and efficient toolkit for large model compression.

✒️ TechnicalReport   |    📖 Documentation   |   🤗 Hugging Face   |   🤖 ModelScope

💬 WeChat |   🫨 Discord

## 📣Latest News
Previous News
## 🌟Key Features - **Highly Integrated**: This toolkit integrates mainstream compression algorithms into a unified framework, offering developers one-click access with exceptional ease of use. - **Continuous Innovation**: Beyond integrating widely-used industry algorithms, we are continuously researching better compression algorithms, which will be gradually open-sourced in the future. - **Performance-Driven**: We continuously optimize end-to-end performance in model compression workflows and algorithm deployment, such as enabling quantization of models like Qwen3-235B and DeepSeek-R1 on a single GPU. ## 💼Technical Overview
Scenario Model Compression Strategy
Quantization Speculative Decoding Other Techniques
Large Language Models (LLMs)
Vision Language Models (VLMs)
Diffusion Models -
Speech Models​ (TTS/ASR)
  • Token Pruning
    • Under Development
## 🛎️How to Use ### 1. Install AngelSlim We recommend using `pip` to install the latest stable version of `AngelSlim`: pip install angelslim Alternatively, you can clone the repository and install from source in editable mode: cd AngelSlim && python setup.py install For more detailed installation instructions and platform-specific guidance, please refer to the [Installation Documentation](https://angelslim.readthedocs.io/zh-cn/latest/getting_started/installation.html). ### 2. Quick Start #### 2.1 Speculative Decoding After installing AngelSlim, you can quickly start Eagle3 training with the following scripts: # Start the vLLM server bash scripts/speculative/run_vllm_server.sh # Generate training data bash scripts/speculative/generate_data_for_target_model.sh # Perform online training for the Eagle3 model bash scripts/speculative/train_eagle3_online.sh Training and Deployment Guide for Eagle3: [LLM](https://angelslim.readthedocs.io/zh-cn/latest/features/speculative_decoding/eagle/eagle.html) | [VLM](https://angelslim.readthedocs.io/zh-cn/latest/features/speculative_decoding/eagle/vlm_eagle.html) | [Audio(ASR)](https://angelslim.readthedocs.io/zh-cn/latest/features/speculative_decoding/eagle/audio_asr_eagle.html) | [Audio(TTS)](https://angelslim.readthedocs.io/zh-cn/latest/features/speculative_decoding/eagle/audio_tts_eagle.html). #### 2.2 LLM/VLM/Audio Model Quantization After installing `AngelSlim`, you can launch static FP8 quantization for the Qwen3-1.7B model with the following one-command script: python3 tools/run.py -c configs/qwen3/fp8_static/qwen3-1_7b_fp8_static.yaml This example produces quantized model weights by performing PTQ calibration on a model loaded from HuggingFace. For **Hy3-preview** (MoE A20B) FP8-Static quantization: python tools/run.py -c configs/hunyuan/fp8_static/hunyuanv3_a20b_fp8_static_c8.yaml
Code-based Start To perform dynamic `FP8` quantization on `Qwen3-1.7B`: from angelslim.engine import Engine slim_engine = Engine() # Prepare model slim_engine.prepare_model(model_name="Qwen", model_path="Qwen/Qwen3-1.7B",) # Initialize compressor slim_engine.prepare_compressor("PTQ", default_method="fp8_dynamic") # Compress model slim_engine.run() # Save compressed model slim_engine.save("./output")
For more details, please refer to the [Quick Start Documentation](https://angelslim.readthedocs.io/zh-cn/latest/getting_started/quickstrat.html). #### 2.3 Diffusion Model Quantization Use the `scripts/diffusion/run_diffusion.py` for quantization and inference: # Online quantization and inference python scripts/diffusion/run_diffusion.py \ --model-name-or-path black-forest-labs/FLUX.1-schnell \ --quant-type fp8-per-tensor \ --prompt "A cat holding a sign that says hello world" \ --height 1024 --width 1024 --steps 4 --guidance 0.0 --seed 0 For more quantization inference methods, please refer to [the Diffusion Model Quantization Documentation](https://angelslim.readthedocs.io/zh-cn/latest/features/diffusion/quantization.html). #### 2.4 Token Compression (VLM) AngelSlim provides a universal metadata-driven framework for vision token pruning and merging. You can quickly verify a compression strategy (e.g., **VisionZip**) with a smoke test: python tools/test_universal_pruning.py \ --model_path "Qwen/Qwen2.5-VL-3B-Instruct" \ --config "configs/qwen2_5_vl/pruning/visionzip_r0.9.yaml" For more details on implementing new strategies, please refer to the [Token Compressor Documentation](https://angelslim.readthedocs.io/zh-cn/latest/features/token_compressor/index.html). ### 3. Deployment and Testing #### 3.1 Offline Inference To test offline inference with a quantized model loaded via `transformers`.
Run script details python scripts/deploy/offline.py $MODEL_PATH "Hello, my name is" Where `MODEL_PATH` is the path to the quantized model output.
#### 3.2 API Service Deployment After specifying the quantized model path `MODEL_PATH`, you can deploy an OpenAI-compatible API service using **vLLM** and **SGLang** inference frameworks.
Run script details - **vLLM** Use the following script to launch a [vLLM](https://github.com/vllm-project/vllm) server, recommended version `vllm>=0.8.5.post1`. For MOE INT8 quantized models, vllm>=0.9.0 is required. bash scripts/deploy/run_vllm.sh --model-path $MODEL_PATH --port 8080 -d 0,1,2,3 -t 4 -p 1 -g 0.8 --max-model-len 4096 Where `-d` is the visible devices, `-t` is tensor parallel size, `-p` is pipeline parallel size, and `-g` is the GPU memory utilization. - **SGLang** Use the following script to launch a [SGLang](https://github.com/sgl-project/sglang) server, recommended version `sglang>=0.4.6.post1`. bash scripts/deploy/run_sglang.sh --model-path $MODEL_PATH --port 8080 -d 0,1,2,3 -t 4 -g 0.8
#### 3.3 Service Invocation Invoke requests via [OpenAI's API format](https://platform.openai.com/docs/api-reference/introduction).
Run script details bash scripts/deploy/openai.sh -m $MODEL_PATH -p "Hello, my name is" --port 8080 --max-tokens 4096 --temperature 0.7 --top-p 0.8 --top-k 20 --repetition-penalty 1.05 --system-prompt "You are a helpful assistant." where `-p` is the input prompt.
#### 3.4 Performance Evaluation Evaluate the performance of quantized model using [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness), recommended version`lm-eval>=0.4.8`.
Run script details bash scripts/deploy/lm_eval.sh -d 0,1 -t 2 -g 0.8 -r $RESULT_PATH -b "auto" --tasks ceval-valid,mmlu,gsm8k,humaneval -n 0 $MODEL_PATH where `RESULT_PATH` is the directory for saving test results, `-b` is batch size, `--tasks` specifies the evaluation tasks, and `-n` is the number of few-shot examples.
For more detaileds, please refer to the [Deployment Documentation](https://angelslim.readthedocs.io/zh-cn/latest/deployment/deploy.html). ## 📈 Benchmark ### 1. Speculative Decoding We evaluated the Eagle3 model trained by AngelSlim on tasks including code generation, mathematical reasoning, instruction following, text generation, and multimodal understanding using vLLM. The inference acceleration and context length performance of our trained model under the settings of num_speculative_tokens = 2 or 4 are presented as follows, with an accept length of 1.8–3.5 and a maximum speedup of 1.4–1.9×.

AngelSlim

#### 1.1 Qwen3 Series Models Benchmark results for Qwen3 series models using Eagle3 speculative decoding on vLLM (v0.11.2) across **MT-bench**, **HumanEval**, **GSM8K** and **Alpaca**, using a single GPU (**tp=1, ep=1, num_speculative_tokens=2, batch_size=1, output_len=1024**).
Model Method GSM8K Alpaca HumanEval MT-bench Mean
throughput (tokens/s)accept length throughput (tokens/s)accept length throughput (tokens/s)accept length throughput (tokens/s)accept length throughput (tokens/s)accept length
Qwen3-1.7B Vanilla 376.421 378.861 378.381 390.531 381.051
Eagle3 616.92.13 653.292.19 680.12.2 621.442.17 642.932.17
Qwen3-4B Vanilla 229.051 235.291 234.661 234.041 233.261
Eagle3 389.352.07 395.972.1 377.842.08 384.62.07 386.942.08
Qwen3-8B Vanilla 149.631 149.931 153.851 153.811 151.811
Eagle3 257.322 266.692.02 244.891.97 258.21.97 257.521.99
Qwen3-14B Vanilla 92.971 92.661 92.941 94.461 93.261
Eagle3 153.721.87 140.461.78 144.681.76 142.451.74 145.331.79
Qwen3-32B Vanilla 43.491 43.381 43.191 43.31 43.321
Eagle3 80.432.01 72.491.9 71.571.86 74.11.86 74.11.91
Qwen3-30B-A3B Vanilla 311.841 320.431 325.771 325.421 320.871
Eagle3 453.972.1 432.452.04 428.812.02 437.062.01 438.072.04
#### 1.2 VLM Models ##### 1.2.1 Qwen3-VL Series Models Benchmark results for Qwen3-VL series models using Eagle3 speculative decoding on vLLM (v0.12.0) across language and multimodal tasks, using a single GPU (**tp=1, ep=1, num_speculative_tokens=4, batch_size=1, output_len=1024**).
Model Method GSM8K Alpaca HumanEval MT-bench MATH-500 MMMU MMStar Mean
throughput (tokens/s) accept length throughput (tokens/s) accept length throughput (tokens/s) accept length throughput (tokens/s) accept length throughput (tokens/s) accept length throughput (tokens/s) accept length throughput (tokens/s) accept length throughput (tokens/s) accept length
Qwen3-VL-2B-Instruct Vanilla 348.55 1 350.9 1 346.07 1 346.31 1 82.96 1 83.27 1 81.63 1 234.24 1
Eagle3 511.52 2.11 560.55 2.26 826.01 3.39 555.22 2.29 163.09 2.57 154.18 2.55 139.73 2.31 415.76 2.5
Qwen3-VL-4B-Instruct Vanilla 212.87 1 213.24 1 211.69 1 212.1 1 67.96 1 65.88 1 67.75 1 150.21 1
Eagle3 415.29 2.57 372.89 2.26 459.37 2.82 382.33 2.34 141.87 2.72 104.44 2.05 107.07 2.1 283.32 2.41
Qwen3-VL-30B-A3B-Instruct Vanilla 179.94 1 184.6 1 168.68 1 180.57 1 31.08 1 31.51 1 30.93 1 115.33 1
Eagle3 281.93 2.82 241.42 2.13 223.05 2.57 240.47 2.19 75.31 2.79 48.47 1.78 52.57 1.94 166.17 2.32
##### 1.2.2 HunyuanOCR Model Benchmark results for HunyuanOCR using Eagle3 speculative decoding on vLLM (v0.13.0) across **[OmniDocBench](https://huggingface.co/datasets/opendatalab/OmniDocBench)** dataset, using a single GPU (**tp=1, ep=1, num_speculative_tokens=4, batch_size=1, output_len=1024**).
Model Method OmniDocBench
throughput (tokens/s) accept length
Hunyuan-OCR Vanilla 70.12 1
Eagle3 108.1 2.08
#### 1.3 Audio Models ##### 1.3.1 Qwen2-Audio Model Benchmark results for Qwen2-Audio using Eagle3 speculative decoding on vLLM (v0.12.0) across **[LibriSpeech](https://www.openslr.org/12)** dataset, using a single GPU (**tp=1, ep=1, num_speculative_tokens=4, batch_size=1, output_len=1024**).
Model Method LibriSpeech
throughput (tokens/s) accept length
Qwen2-Audio Vanilla 78.76 1
Eagle3 146.66 3.51
##### 1.3.2 Fun-CosyVoice3 Model Benchmark results for Fun-CosyVoice3 using Eagle3 speculative decoding across **[LibriTTS](https://www.openslr.org/60/)** dataset, using a single GPU (**tp=1, ep=1, num_speculative_tokens=4, batch_size=1, output_len=1024**).
Model Method LibriTTS
throughput (tokens/s) accept length
Fun-CosyVoice3 Vanilla - 1
Eagle3 - 1.96
### 2. Quantization The performance test results for selected models are shown below. For the complete benchmark, refer to the [Benchmark documentation](https://angelslim.readthedocs.io/zh-cn/latest/performance/quantization/benchmarks.html) #### 2.1 Hunyuan Series Models Benchmark results for the `Hunyuan-Instruct` model with `FP8`, `INT4-AWQ` and `INT4-GPTQ` quantization algorithms on datasets including`OlympiadBench`, `AIME 2024` and `DROP`:
ModelQuantizationOlympiadBenchAIME 2024DROPGPQA-Diamond
Hunyuan-A13B-Instruct BF1682.787.3091.171.2
FP8-Static83.086.791.1-
Int4-GPTQ82.786.791.1-
Int4-AWQ82.685.691.0-
Hunyuan-7B-Instruct BF16 76.581.185.960.1
FP8-Static76.680.986.060.1
Int4-GPTQ76.281.085.760.0
Int4-AWQ76.480.985.960.1
Hunyuan-4B-Instruct BF16 73.178.378.261.1
FP8-Static73.176.678.360.2
Int4-GPTQ72.9-78.158.1
Int4-AWQ72.8-78.2-
Hunyuan-1.8B-Instruct BF16 63.456.776.747.2
FP8-Static62.555.275.147.7
Int4-GPTQ60.9-73.044.4
Int4-AWQ61.7-71.743.6
Hunyuan-0.5B-Instruct BF16 29.617.252.823.3
FP8-Static29.617.251.622.5
Int4-GPTQ26.8-50.923.3
Int4-AWQ26.3-48.923.3
#### 2.2 Qwen3 Series Models Benchmark results for Qwen3 series models with `FP8-Static`, `FP8-Dynamic`, `INT4-GPTQ`, and `INT4-AWQ` quantization algorithms on datasets including `CEVAL`, `MMLU`, `GSM8K`, and `HUMANEVAL`:
ModelQuantizationCEVALMMLUGSM8KHUMANEVAL
Qwen3-0.6BBF1645.8447.2142.9919.51
FP8-Static45.9946.8738.0618.90
FP8-Dynamic45.9946.9338.2920.73
INT8-Dynamic45.1746.9541.1721.34
Qwen3-8BBF1679.2774.7887.7963.41
FP8-Static78.2374.7986.9662.20
FP8-Dynamic78.4574.7587.6462.80
INT8-Dynamic78.0174.8486.9667.07
INT4-GPTQ77.1973.2686.4362.20
INT4-AWQ76.1573.5986.9663.41
Qwen3-14BBF1683.0678.9088.4055.49
FP8-Static82.6278.5789.4657.32
FP8-Dynamic82.2478.9288.3252.44
INT8-Dynamic81.8778.1386.2856.10
INT4-GPTQ81.0578.0287.3457.93
INT4-AWQ82.0277.6884.2361.59
Qwen3-32BBF1686.5582.0074.5337.80
FP8-Static86.9281.7870.2039.63
FP8-Dynamic86.5581.8970.4338.41
INT4-GPTQ86.1881.01-43.29
INT4-AWQ86.1881.54-36.59
Qwen3-30B-A3BBF1683.6679.3689.9931.71
FP8-Static83.9579.4789.0131.10
FP8-Dynamic84.1079.4089.1632.93
INT8-Dynamic83.3679.4889.1634.15
Qwen3-235B-A22BBF1689.6086.2885.2927.44
FP8-Static89.6786.1986.9627.44
FP8-Dynamic89.6786.1885.2228.05
INT8-Dynamic88.9386.2086.2023.78
#### 2.3 DeepSeek Series Models Benchmark results for DeepSeek-R1-0528 series models with `FP8-Block-Wise` and `W4A8-FP8` quantization algorithms on datasets including `GPQA Diamond`、`AIME 2024`、`SimpleQA` and `LiveCodeBench`:
ModelQuantizationGPQA DiamondAIME 2024SimpleQALiveCodeBench
DeepSeek-R1-0528FP8-Block-Wise78.2888.6727.877.1
W4A8-FP877.3788.6726.8378.86
Note
#### 2.4 Qwen-VL Series Models **Qwen3-VL Benchmark** Benchmark results for Qwen3VL series models with `BF16`、`FP8-Static` and `FP8-Dynamic` quantization algorithms on datasets including `MMMU_VAL`、`DocVQA_VAL` and `ChartQA_TEST`:
ModelQuantizationMMMU_VALDocVQA_VALChartQA_TEST
Qwen3-VL-32B-InstructBF1660.1196.0894.64
FP8-Static61.2296.0094.64
FP8-Dynamic60.7896.1994.72
Qwen3-VL-30B-A3B-InstructBF1650.4495.2895.36
FP8-Dynamic50.6795.2595.20
Qwen2.5VL Benchmark Benchmark results for Qwen2.5VL series models with `BF16`、`FP8-Static`、`FP8-Dynamic`、`INT4-GPTQ`、`INT4-AWQ` quantization algorithms on datasets including `MMMU_VAL`、`DocVQA_VAL` and `ChartQA_TEST`:
ModelQuantizationMMMU_VALMMLDocVQA_VALUChartQA_TEST
Qwen2.5VL-3BBF1647.1178.5780.32
FP8-Static47.3379.3479.68
FP8-Dynamic45.9946.9338.29
INT4-GPTQ46.5677.2078.96
INT4-AWQ45.78-79.60
Qwen2.5VL-7BBF1645.4489.7184.64
FP8-Static47.0089.8385.92
FP8-Dynamic47.2289.8088.64
INT4-GPTQ46.6790.45-
INT4-AWQ45.6789.28-
Qwen2.5VL-32BBF1657.0090.03-
FP8-Static57.0089.88-
FP8-Dynamic56.4489.88-
INT4-GPTQ55.2289.80 -
INT4-AWQ55.2290.30-
Qwen2.5VL-72BBF1658.7894.3985.60
FP8-Static57.8994.4185.84
FP8-Dynamic58.6794.3885.60
INT4-GPTQ57.5694.4686.48
INT4-AWQ58.7894.1987.28
#### 2.5 Qwen-Omni Series Models **Qwen3-Omni Text to Text Benchmark** Benchmark results for Qwen3-Omni series models in BF16, FP8-Static, and FP8-Dynamic on aime25, gpqa_diamond, and mmlu_redux are as follows:
ModelQuantizationaime25gpqa_diamondmmlu_redux
Qwen3-Omni-30B-A3B-InstructBF1673.3256.7788.09
FP8-Static71.3356.5787.91
FP8-Dynamic73.3355.1588.07
Note
#### 2.6 Other Models Other models such as GLM-4.6, Qwen2.5, and Seed-OSS have been evaluated on benchmarks like `CEVAL`, `MMLU`, and `GSM8K` using quantization strategies including `FP8-Static`, `FP8-Dynamic`, `INT4-GPTQ`, and `INT4-AWQ`.
Benchmark Experiment Details
ModelQuantizationCEVALMMLUGSM8K
Qwen2.5-1.5B-InstructBF1667.0160.0554.28
FP8-Static66.2760.23-
FP8-Dynamic66.7960.0851.71
Qwen2.5-7B-InstructBF1681.2074.5579.98
FP8-Static81.1374.0379.30
FP8-Dynamic80.3174.0779.00
INT4-GPTQ79.0573.0574.75
INT4-AWQ79.3573.2279.38
Qwen2.5-32B-InstructBF1687.3083.2181.73
FP8-Static87.5983.0881.58
FP8-Dynamic87.3083.0481.58
INT4-GPTQ86.7082.4582.03
INT4-AWQ87.0082.64-
DeepSeek-R1-Distill-Qwen-7BBF1653.4953.8075.74
FP8-Static53.5754.1776.19
FP8-Dynamic52.9754.1374.15
INT4-GPTQ51.8652.4475.89
INT4-AWQ53.4953.70-
DeepSeek-R1-Distill-Qwen-14BBF1677.7174.2885.67
FP8-Static77.5674.6686.73
FP8-Dynamic76.8274.6387.11
INT4-GPTQ74.2972.3784.61
INT4-AWQ74.8173.0086.05
DeepSeek-R1-Distill-Qwen-32BBF1684.1880.8987.41
FP8-Static83.4380.9087.57
FP8-Dynamic83.7381.1086.43
INT4-GPTQ84.1079.8086.73
INT4-AWQ82.8480.1587.19
### 3. Token Compression (VLM) We evaluated various vision token compression strategies on the **Qwen2.5-VL-3B-Instruct** model across multiple multimodal benchmarks. You can replicate these results using the following command: python tools/run_pruning_eval.py \ --model_path "Qwen/Qwen2.5-VL-3B-Instruct" \ --configs "configs/qwen2_5_vl/pruning/visionzip_r0.9.yaml" \ --tasks "textvqa" \ --output_dir "./results/visionzip_test"
Detailed Benchmark Results (Qwen2.5-VL-3B-Instruct)
Method AI2D ChartQA DocVQA MMBCN MMB MME MMStar OCRBench POPE SQA VQAText Avg
Baseline 79.11 83.56 92.48 73.28 77.32 1517 56.05 80.10 87.41 80.81 78.79 100.0%
Retain 25% Tokens (75% Compression Ratio)
FastV72.7070.0475.9863.4066.92143747.3936.6086.4279.3373.5186.02%
VisionZip74.1971.3270.1167.3571.22145249.3742.5085.5181.3668.1287.34%
HiPrune73.8372.7672.1067.2772.34144948.9341.3085.8680.9169.2787.67%
VisionSelector75.1973.7290.2468.8172.59152149.9761.8085.3680.3776.8693.62%
DivPrune73.0662.9678.4667.1071.82145948.3851.4086.8180.2268.9188.15%
DART71.0865.2079.7265.3871.05142848.7841.8080.9780.9168.2586.17%
VisPruner74.2968.2072.5267.3570.88145849.7444.8086.5981.4669.6287.87%
SCOPE75.8474.0082.4068.8172.94147150.3556.0086.6280.9674.0491.98%
IDPruner75.9475.8490.0069.4273.80150549.4964.9086.2680.4276.9094.42%
Retain 10% Tokens (90% Compression Ratio)
FastV65.8729.7236.8948.3751.98125737.2813.9079.5077.0557.7565.30%
VisionZip67.6551.6037.8859.6263.06133842.8221.4081.1480.4751.5672.75%
HiPrune67.7553.2041.1559.4563.14132641.0820.3080.9080.9653.3173.00%
VisionSelector70.5065.9279.9459.9764.69137442.8645.2082.6680.6171.5784.42%
DivPrune67.7143.1258.0361.2565.12138940.4327.9082.2479.1856.8775.50%
DART67.4947.5660.2357.9963.83129942.1823.4074.2078.6358.0274.09%
VisPruner67.7547.9248.6559.2863.32130541.5122.5078.7479.7754.9573.19%
SCOPE69.7556.2455.0164.2667.18139044.3530.8083.3480.4762.5879.37%
IDPruner71.7963.3279.3863.5768.21143844.0545.5084.5180.5770.0285.71%
## 📝 License The code for this project is open-sourced under the [License for AngelSlim](LICENSE). ## 🔗 Citation @article{angelslim2026, title={AngelSlim: A more accessible, comprehensive, and efficient toolkit for large model compression}, author={Hunyuan AI Infra Team}, journal={arXiv preprint arXiv:2602.21233}, year={2026} } ## 💬 Technical Discussion * AngelSlim is developed by the Tencent Hunyuan AI Infra team, with new features being iteratively updated. If you have any questions or suggestions, please submit them on [GitHub Issues](https://github.com/Tencent/AngelSlim/issues) or join our [WeChat discussion group](./docs/source/assets/angel_slim_wechat.png). * ⭐ Star this repo to follow our latest progress. And if you are interested in joining us for an internship or full-time position, send your resume to: lucayu@tencent.com.
标签:Vectored Exception Handling, 凭据扫描, 逆向工具