【训练营】MXFP8/NVFP4低精度模拟与反量化 - #73
Open
crashingby wants to merge 2 commits into
Open
crashingby wants to merge 2 commits into
crashingby wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
项目概述
完成 MXFP8 / NVFP4 低精度浮点软件模拟与 CUDA 反量化项目。
程序支持从 QDTENSOR 文件读取 FP16 / FP32 行主序矩阵,完成 CUDA 量化、真实位宽打包、QDWGT 文件写入与校验、CUDA 反量化为 FP16 / BF16 / FP32,并输出误差、压缩率、kernel 时间和有效带宽报告。
完整技术总结见:
02_quant_dequant/黄新颖/Conclusion.md02_quant_dequant/黄新颖/README.md低精度格式与缩放策略
MXFP8
S EEEE MMM),最大有限值为448。block_size = 32、每块一个 E8M0 scale。x_hat = decode_E4M3(payload) × scale。NVFP4
S EE M),两个元素打包到一个字节中。x_hat = decode_E2M1(payload) × decode_E4M3(local_scale) × global_scale。支持 RNE(round-to-nearest, ties-to-even)和可复现的 stochastic rounding;随机舍入使用基于全局线性下标和 seed 的无状态 SplitMix64 映射。
实现与优化
amax规约,并使用 persistent grid 降低小 CTA 调度开销。partial reduction -> finalize scale -> encode三段 kernel,正确处理跨 CTA 的全局amax。正确性验证
代表性实验结果
实验环境:NVIDIA RTX 4060(SM89),
rtx4060-release。在
1024 × 1025、FP32 输入/输出、RNE 下:在
4096 × 4097FP32 normal 输入、10 次 warmup、30 次 repeat 的 CUDA Event benchmark 中:MXFP8 提供更低误差;NVFP4 以更高的量化计算开销换取约
7.1×的 FP32 存储压缩率。随机舍入的额外开销主要出现在量化阶段。软件模拟与依赖边界
可继续优化方向