测试基建:🧪 补齐 FP8 融合算子精度测试支持,修复 GPU 测试模式#674
Merged
cangtianhuang merged 16 commits intoJul 15, 2026
Merged
Conversation
|
Thanks for your contribution! |
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.
🧭 背景
PaddleAPITest 通过将 Paddle API 转换为 Torch 参考实现来进行前向和反向精度对比。
paddle.incubate.nn.functional.fp8_quant_blockwise与fused_act_dequant涉及 FP8 量化、scale 计算及激活反量化路径,缺少对应转换规则时无法建立可比的 Torch 基线,相关算子的精度回归也无法纳入自动化验证。FP8 场景同时依赖 GPU 输入与输出的生命周期管理。此前
use_gpu_cache_mode的命名只能表达缓存语义,实际行为还包含 GPU 模式下的清理策略;并且 Paddle 的 NaN/Inf 数值检查错误未被归为paddle_error,会降低失败结果的可读性。🛠️ 实现方案
为两个 Paddle API 在映射表中注册专用 Rule,并在转换规则中生成独立的 Torch 参考计算。
fp8_quant_blockwise按内核语义计算 block-wise amax、量化 scale 和反向存储 scale,支持1x128、128x128两种量化方式以及转置、pow2 scale 和 UE8M0 scale 等配置;量化结果使用 Torch 的float8_e4m3fn表示。fused_act_dequant将 scale、反量化与激活逻辑转换为可执行的 Torch 路径。同时将全链路 GPU 开关统一为
use_gpu_mode/USE_GPU_MODE,使引擎、运行配置和输入构造共享同一语义,并保留 GPU 模式下跳过清理的行为。运行时错误分类补充 NaN/Inf 数值检查标识,确保该类 Paddle 侧失败被稳定记录。🔧 主要变更
1. 新增 FP8 算子的 Torch 参考实现
为
fp8_quant_blockwise与fused_act_dequant增加映射和转换规则,补齐必填参数默认值,使自动生成 case 可以转换并进入 Paddle/Torch 精度比对流程。fp8_quant_blockwise的参考实现覆盖 block-wise scale 计算、量化输出、scale 转置及仅返回转置结果等分支,并对不支持的量化方式显式报错,避免产生无效对比结果。2. 统一 GPU 模式配置
将
use_gpu_cache_mode统一更名为use_gpu_mode,同步更新 V2/V4 引擎、启动脚本、YAML 配置和配置 schema。GPU 模式不再只被理解为输入缓存开关,设备缓存清理与 Tensor 构造逻辑均由统一配置控制。3. 完善精度任务失败分类
将 Paddle 的
There are nan or inf与check_numerics错误归类为paddle_error,避免数值检查失败被错误归入其他运行时异常类别。📁 改动文件
tester/paddle_to_torch/mapping.jsontester/paddle_to_torch/rules.pytester/base.pyengineV2.py、engineV4.py、run.pytester/api_config/config_analyzer.py、tester/accuracy.pytest_pipeline/run_config.yaml、test_pipeline/run_config.schema.json、run-example.sh、run-v4.sh