跳转至

dynamic_cache 配置说明

1. 配置概述

KV cache 量化处理器配置。

项目 内容
配置类 DynamicCacheProcessorConfig
源码 attention.py

2. 参数列表

2.1 DynamicCacheProcessorConfig

字段路径 类型 必选/可选 默认值 取值范围或格式 含义 引用配置
type string 可选 dynamic_cache dynamic_cache 处理器类型,固定为 dynamic_cache
qconfig object 必选 KV cache 张量的量化配置,见《QConfig 配置说明》。 本页 §2.2
include list[string] 可选 [] 包含的模块名称模式
exclude list[string] 可选 [] 排除的模块名称模式,优先级高于 include

配置约束

  • 无。

2.2 QConfig

描述单个张量(权重或激活)的量化方式。

字段路径 类型 必选/可选 默认值 取值范围或格式 含义 引用配置
dtype string 必选 floatint8int4mxfp8mxfp4fp8_e4m3 量化数据类型,如 int8int4mxfp8mxfp4fp8_e4m3float 表示该张量不量化。
scope string 必选 per_tensorper_channelper_groupper_blockper_tokenpd_mixper_headdual_scale 量化粒度,即 scale/zero_point 的计算范围:per_tensor(整张量一个尺度)、per_channel(按通道)、per_group/per_block(按分组或固定块)、per_token(按 token)、per_head(按注意力头)、dual_scale(双尺度)等;合法取值组合取决于 dtype 与量化器实现。
symmetric bool 必选 是否对称量化。对称量化只保存 scale;非对称量化额外保存 zero_point,可用性取决于 dtype/scope 组合。
method string 必选 量化参数估计算法,如 minmaxmse_roundhistogramssznone 等;可用取值取决于 dtype/scope/symmetric 组合,none 表示不估计参数(配合 float 使用)。
ext object 可选 {} 量化器扩展参数,随 method 与量化器实现而定(如 gptq 的 percdamp/group_size);空对象表示无扩展参数。

配置约束

  • 无。

3. 完整配置参考

apiversion: modelslim_v1
spec:
  process:
  - type: dynamic_cache
    qconfig:
      dtype: int8
      scope: per_channel
      symmetric: true
      method: minmax
      ext: {}
    include: []
    exclude: []