Merged
[feat]add dsv4 kv cache fake-quantization support #881
caoshuyangAdd on Sep 20
[feat]add dsv4 kv cache fake-quantization support #881
Merged
Pull Request has been successfully merged by CANN-robot.
(Thank you for caoshuyang's contribution.)Sep 20 Created pull request, commit 3f24b35e
Sep 20 Modify description of pull request
examples/deepseek_v4/deepseek_v4_flash_cpt_4k_a5.sh
@@ -38,0 +38,2 @@
38+ --extension.quantization.kv-norm-quantization.format mxfp8
39+ --extension.quantization.kv-norm-quantization.fqns .attention.kv_norm,.attention.compressor.norm
40+ --extension.quantization.kv-norm-quantization.block-size 64
当前 deepseek v4 KV 的量化方式是否固定,固定的话可以使用一个传参控制 kv 量化,fqns 建议写到 torchao_converter.py 的 _DSV4_CONFIG_FILTERS 中


Sep 21 virtual merging failed, update merge request[project_id: 9028822, iid: 881, target_commit_sha: 3f24b35ed83be17c012207400984bf1917cd05f8], message: Conflict detected
Sep 21 virtual merging failed, update merge request[project_id: 9028822, iid: 881, target_commit_sha: 3f24b35ed83be17c012207400984bf1917cd05f8], message: Conflict detected
Sep 21 Pushed 1 commits:1548e5db-add kv cache quantization in examples/deepseek_v4/debug/deepseek_v4_flash_8p_cpt_4k_a5.sh
Sep 21 Pushed 1 commits:1548e5db-add kv cache quantization in examples/deepseek_v4/debug/deepseek_v4_flash_8p_cpt_4k_a5.sh
148 messages are collapsed here。 See more
27 days ago Deleted associated issue: [RFC] DeepSeek V4 支持 win/compress KV C8
27 days ago Associated issue: [RFC] DeepSeek V4 支持 win/compress KV C8
CANN-robot
27 days ago Comments:
27 days ago Comments:
Pull Request 已合并或已关闭。
If you want to solve this problem, you can click here to do it in the FAQs.


CANN-robot
27 days ago Comments:
27 days ago Comments:
Pull Request 已合并或已关闭。
If you want to solve this problem, you can click here to do it in the FAQs.


CANN-robot
27 days ago Comments:
27 days ago Comments:
Pull Request 已合并或已关闭。
If you want to solve this problem, you can click here to do it in the FAQs.


描述
增加DSV4模型kv cache的MXFP8(block size=64)伪量化支持。数学上,伪量化需要加在norm和rope之间。在不修改高精模型的约束下,选择将norm与伪量化合并,在模型中打包为FakeQuantizedNorm。接入方式不影响在override机制中通过类型匹配替换norm的融合算子。
通过在脚本中添加一下参数使能。
QUANTIZATION_ARGS=( # 其他量化参数 --extension.quantization.kv-norm-quantization.format mxfp8 # 伪量化格式,目前仅支持mxfp8。kv cache伪量化的总开关,不设置时默认不启用伪量化。 --extension.quantization.kv-norm-quantization.fqns .attention.kv_norm,.attention.compressor.norm # 需要增加伪量化的Norm模块的fqn --extension.quantization.kv-norm-quantization.block-size 64 # 伪量化时使用的块大小 # 其他量化参数 )类型
Checklist:
如何测试
伪量化在RMSNorm和inplace rope之间执行。override正常换入了RMSNorm的融合算子。

伪量化执行次数与预期一致。

loss 和 grad norm正常。

其他信息
在这里可以添加任何与这个 Pull Request 相关的其他说明。