测试优化:统一任务运行与日志可靠性,优化测试错误诊断及大 Tensor 性能 - #711
Merged
Merged
Conversation
cangtianhuang
enabled auto-merge (squash)
August 18, 2026 11:05
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.
PR 标题:统一任务运行与日志可靠性,优化测试错误诊断及大 Tensor 性能
📌 背景
dev分支本次合入同时覆盖任务运行管理、后台日志可靠性、测试错误分类、输入生成和多 worker 性能。目标是在保持既有小配置随机输入行为和测试模式语义的前提下,降低同一输出目录的并发竞态,保证进程异常退出后日志可以恢复,并让失败位置能够被稳定识别。🔎 主要问题
run.py、示例脚本和 V4 批量脚本各自按脚本名维护 PID 文件,同一输出目录可能被不同入口重复启动或互相清理。phase和自由文本报告错误,输入、框架执行、CUDA 同步、比较和显存预检的边界不一致。INT32_MAX的配置会放大临时显存和执行开销。take_along_axis的 Tensor method 使用x作为接收者,但输入规则只查找函数形式的arr参数。🛠️ 实现方案
1. 按输出目录统一任务锁
run.py移除可配置的runner.pid_file,将 PID 文件固定为output.log_dir/.paddleapitest.pid,锁文件为同目录的.paddleapitest.pid.lock。fcntl.flock,启动前检查同一输出目录是否已有任务。run-example.sh和全部test_pipeline/V4/*.sh同步使用输出目录级 PID/锁协议,并始终打印日志跟踪入口。pid_file说明。2. 使后台日志聚合可恢复
flush + fsync;主进程在收到完成偏移前确保 worker 日志已落盘。.log_inorder.build构建文件,异常重启时截断到最后一个安全提交点。os.replace原子发布;所有派生结果成功后才清理 source,失败时可重试。3. 统一错误阶段协议
tester/reporting/log_schema.py定义统一的Stage,覆盖Input、Paddle/Torch 前向与反向、CUDA 同步、Compare和Memory preflight。accuracy、accuracy_stable、paddle_only、CINN、设备对比和性能测试统一通过阶段常量报告错误,比较错误不再混入任一框架执行阶段。allow_ignore_paddle/paddle_error_dismiss依赖,避免未分类异常被错误标记为 pass。4. 优化多 worker 和超大 Tensor
1 << 20个元素时,float16 随机输入可直接按目标 storage dtype 生成;满足 int32 边界约束时,randint 可直接生成 int32。5. 修复输入规则边界
take_along_axis输入规则同时支持函数参数arr和 Tensor method 接收者x,并继续按 axis 维度限制索引范围。📁 主要改动文件
run.py、run-example.sh、test_pipeline/V4/*.shdocs/CLI_REFERENCE.md、test_pipeline/run_config.schema.json、test_pipeline/run_config.yamlengineV4.pytester/reporting/log_aggregation.py、log_runtime.py、log_worker.py、reporting/__init__.pytester/reporting/log_schema.py、log_comparison.py、tester/base.py及各测试模式tester/input_generation/backend.py、generation_rules.py、tester/runtime/gpu_memory_preflight.py