用途:该技能用于分析 AgentSDK 与 Agentic RL 代码库,在昇腾 NPU 上定位精度问题、性能瓶颈并给出可执行方案。适用于用户提到 NPU、Ascend、CANN,或出现 NaN、溢出、下溢、dtype 不匹配、训练变慢、显存泄漏、GRPO 训练缓慢、torch.npu 等情况。
硬件与软件栈:硬件为 Ascend 910/910B/910C;框架为 torch_npu(PyTorch 的昇腾扩展);编译器为 CANN;后端为 DaVinci Compiler。常见 NPU 对应关系包括 torch.cuda 对 torch.npu、.cuda() 对 .npu()、torch.cuda.set_device() 对 torch.npu.set_device()、内存统计与 empty_cache、混合精度 autocast 与 GradScaler 等。
使用方式:先确定目标路径、关注点(精度/性能/两者)、输出格式与受众;随后运行命令,例如 python -m scripts.analyze_precision <target_path> [--output report.json] 与 python -m scripts.analyze_performance <target_path> [--output report.json],再用 python -m scripts.generate_solutions <analysis_report.json> [--output fixes.md] 生成修复建议。安装依赖为 pip install torch torch-npu,可用 python -c "import torch; print(torch.npu.is_available())" 验证。也可不依赖 AgentSDK,直接导入 PrecisionAnalyzer 与 PerformanceAnalyzer 分析本地代码。集成入口包括 quick_check、verify_perf、generate_report。
主要能力:精度检查涵盖 dtype 一致性、NPU API 使用、float64 到 float32 转换、数值稳定性、NPU 混合精度与梯度裁剪;性能检查涵盖 NPU 内存管理、CANN 优化与批处理、数据加载、HCCL 通信与训练循环。输出支持控制台、JSON 与 Markdown,JSON 报告含问题严重级别、分类、文件行号、描述与建议。
限制:技能不会在未经明确许可时修改用户代码,只生成报告与建议供人工审阅。资料未提供具体价格、许可、支持版本范围与实测加速数据。