Files
FastDeploy/docs/zh/quantization
YuBaoku 425205b03c
Some checks failed
CE Compile Job / ce_job_pre_check (push) Has been cancelled
CE Compile Job / print_ce_job_pre_check_outputs (push) Has been cancelled
CE Compile Job / FD-Clone-Linux (push) Has been cancelled
CE Compile Job / Show Code Archive Output (push) Has been cancelled
CE Compile Job / BUILD_SM8090 (push) Has been cancelled
CE Compile Job / BUILD_SM8689 (push) Has been cancelled
CE Compile Job / CE_UPLOAD (push) Has been cancelled
Deploy GitHub Pages / deploy (push) Has been cancelled
Publish Job / publish_pre_check (push) Has been cancelled
Publish Job / print_publish_pre_check_outputs (push) Has been cancelled
Publish Job / FD-Clone-Linux (push) Has been cancelled
Publish Job / Show Code Archive Output (push) Has been cancelled
Publish Job / BUILD_SM8090 (push) Has been cancelled
Publish Job / BUILD_SM8689 (push) Has been cancelled
Publish Job / PADDLE_PYPI_UPLOAD_8090 (push) Has been cancelled
Publish Job / PADDLE_PYPI_UPLOAD_8689 (push) Has been cancelled
Publish Job / Run FD Image Build (push) Has been cancelled
Publish Job / Run FastDeploy Unit Tests and Coverage (push) Has been cancelled
Publish Job / Run FastDeploy LogProb Tests (push) Has been cancelled
Publish Job / Extracted partial CE model tasks to run in CI. (push) Has been cancelled
Publish Job / Run Base Tests (push) Has been cancelled
Publish Job / Run Accuracy Tests (push) Has been cancelled
Publish Job / Run Stable Tests (push) Has been cancelled
CI Images Build / FD-Clone-Linux (push) Has been cancelled
CI Images Build / Show Code Archive Output (push) Has been cancelled
CI Images Build / CI Images Build (push) Has been cancelled
CI Images Build / BUILD_SM8090 (push) Has been cancelled
CI Images Build / Run FastDeploy Unit Tests and Coverage (push) Has been cancelled
CI Images Build / Run FastDeploy LogProb Tests (push) Has been cancelled
CI Images Build / Extracted partial CE model tasks to run in CI. (push) Has been cancelled
CI Images Build / Run Base Tests (push) Has been cancelled
CI Images Build / Run Accuracy Tests (push) Has been cancelled
CI Images Build / Run Stable Tests (push) Has been cancelled
CI Images Build / Publish Docker Images Pre Check (push) Has been cancelled
[Doc] fix the port conflict issue in the usage example (#4379)
2025-10-13 20:17:06 +08:00
..
2025-09-08 15:53:09 +08:00
2025-09-08 15:53:09 +08:00

量化

FastDeploy支持FP8、INT8、INT4、2-bit等多种量化推理精度支持模型权重、激活和KVCache 3种张量的不同精度推理可以满足低成本、低时延、长上下文等不同场景的推理需求。

1. 精度支持列表

量化方法 权重精度 激活精度 KVCache精度 在线/离线 支持硬件
WINT8 INT8 BF16 BF16 在线 GPU, XPU
WINT4 INT4 BF16 BF16 在线 GPU, XPU
block_wise_fp8 block-wise static FP8 token-wise dynamic FP8 BF16 在线 GPU
WINT2 2Bits BF16 BF16 离线 GPU
MixQuant INT4/INT8 INT8/BF16 INT8/BF16 离线 GPU, XPU

说明

  1. 量化方法:对应量化配置文件中的"quantization"字段;
  2. 在线/离线量化:主要用于区分权重的量化时间
    • 在线量化:推理引擎在加载 BF16 权重后,再对权重做量化;
    • 离线量化:在推理之前,将权重离线地量化并存储为低比特数值类型,推理时,加载量化后的低比特数值。
  3. 动态量化/静态量化:主要用于区别激活的量化方式
    • 静态量化static在推理之前确定并存储量化系数推理时加载提前计算好的量化系数。因为量化系数在推理时是固定不变的所以叫静态量化static quantization
    • 动态量化dynamic在推理时即时地统计当前batch的量化系数。因为量化系数在推理时是动态地变化的所以叫动态量化dynamic quantization

2. 模型支持列表

模型名称 支持量化精度
ERNIE-4.5-300B-A47B WINT8, WINT4, Block_wise= FP8, MixQuant

3. 量化精度术语

FastDeploy 按以下格式命名各种量化精度:

{tensor缩写}{数值类型}{tensor缩写}{数值类型}{tensor缩写}{数值类型}

部分示例如下:

  • W8A8C8W=weightsA=activationsC=CacheKV8默认为INT8
  • W8A8C1616默认为BF16其它同上
  • W4A16C16 / WInt4 / weight-only int44默认为INT4
  • WNF4A8C8NF4指4bit norm-float数值类型
  • Wfp8Afp8权重和激活均为FP8精度
  • W4Afp8权重为INT4, 激活为FP8