合并受阻
变更摘要
本 PR 为 Kineto profiler 后端新增可选的 ACLprof CPU↔NPU 相关性诊断与硬件校验能力,默认关闭诊断,不影响既有 profiling 行为。核心改动包括:新增 NPUActivityProfiler 抽象层与 NPUActivityProfilerFactory,依据 _NPUExperimentalConfig 注入的 custom_profiler_config(JSON {"backend":"aclprof"})在 AclprofActivityProfiler 与默认 MsptiActivityProfiler 之间选择后端,并移除旧 MsptiActivityProfilerPoc 的注册逻辑;AclprofActivityProfiler 在 TORCH_NPU_ACLPROF_CORRELATION_DEBUG=1 时通过 AclprofDiagnostics 记录 correlation 捕获、任务队列标记、HostToDevice 转换、kernel 解析、时钟转换、匹配结果(FOUND/NOT_FOUND/AMBIGUOUS)与最终 Kineto 链接等结构化事件,以 JSONL 保留至 TORCH_NPU_ACLPROF_DIAGNOSTICS_DIR,并将诊断格式化与文件 I/O 推迟到相关性互斥锁释放之后;同时新增 AclrtGetPhyDevIdByUserDevId 接口、任务队列事件上报接入、硬件校验脚本 tools/kineto_aclprof_correlation_validation.py 及配套单测与诊断文档。
主要改动
- 新增统一 NPU profiler 抽象与后端选择:新增
npu_activity_profiler.h/cpp,定义NPUActivityProfiler基类、NPUActivityProfilerFactory::create(解析config.getCustomConfig()中的backend字段,返回AclprofActivityProfiler或默认MsptiActivityProfiler)、PrivateUse1ProfilerManager与NPUActivityProfilerPlugin注册;同时从mspti_activity_profiler.cpp/h删除MsptiActivityProfilerPoc及其注册代码,MsptiActivityProfiler改为继承NPUActivityProfiler。 - 新增 ACLprof 相关性诊断与采集实现:新增
aclprof_activity_profiler.cpp/h与aclprof_activity_profiler_internal.h,AclprofActivityProfiler实现 ACLprof 时间线解析(parseAclprofTimeline、convertTimelineRecords)、任务队列时钟偏移加载与 correlation 解析(resolveCorrelations);AclprofDiagnostics按TORCH_NPU_ACLPROF_DIAGNOSTICS_DIR输出 JSONL 诊断事件,通过ACLPROF_DIAG_DEFERRED将格式化与 I/O 推迟到correlationMutex_释放后进行,并输出每会话ACLPROF_CORRELATION_SUMMARY计数(含kineto_correlations_captured、final_links等)。 - 新增设备接口与任务队列事件上报:
AclInterface.cpp/h新增AclrtGetPhyDevIdByUserDevId的动态加载与声明(用户设备号到物理设备号映射);npu_profiler.cpp的reportMarkDataToNpuProfiler增加recordAclprofTaskQueueEvent调用并在常规上报未启用时提前返回;NpuUtils.cpp的ProfReportMarkDataToNpuProfiler在aclprofTaskQueueCaptureEnabled()为真时也执行标记数据上报。 - 新增 Python 配置与硬件校验工具:新增
_kineto_config.py的_NPUExperimentalConfig(继承 Kineto_ExperimentalConfig,将{"backend": ...}序列化到custom_profiler_config)并在torch_npu/profiler/__init__.py导出;新增tools/kineto_aclprof_correlation_validation.py,设置TORCH_NPU_ACLPROF_CORRELATION_DEBUG、TORCH_NPU_ACLPROF_DIAGNOSTICS_DIR等环境变量,连续运行两次 ACLprof profiling 会话并校验 HostToDevice→KERNEL_RESOLVE→MATCH_RESULT→LINK完整链路、会话隔离与产物完整性。 - 补充测试覆盖:新增
test/cpp/api/profiler.cpp(GTest 覆盖诊断启停、会话重置、成功匹配、歧义/缺失匹配、时钟转换失败、回退路径、诊断 I/O 失败与生命周期场景);test/profiler/test_experimental_config.py新增test_kineto_backend_config,校验pickle.dumps后{"backend":"aclprof"}仅出现在_NPUExperimentalConfig中。


Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
PR Approval Progress
⚠️ This PR does not yet meet the following requirements:lgtm (requires ≥ 2 person(s) per module)、approve (requires ≥ 1 person(s) per module)
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| **/*.md | ❌ (0/2)(You can also ask: LQ1206, zhenyu10, chujinjin, li_jing_hw, 楚浩田) | ❌ (0/1)(You can also ask: liangsongwei, chenrayray, zhenyu10, kisnwang, wjlflyer) |
| repo-Ascend/pytorch | ❌ (0/2)(You can also ask: wangqiang160, liangsongwei, zqwenn, hbhu_bin, zichun_ye) | ❌ (0/1)(You can also ask: chengpeng25, 楚浩田, kisnwang, huangjingwei, wasd1111222) |
| test | ❌ (0/2)(You can also ask: suhaibo, guoqi1024, wanglijun55, 陈豪, crazyDannyBoy) | ❌ (0/1)(You can also ask: chujinjin, suhaibo, anyrenwei, liangsongwei, 王朝) |
| torch_npu/csrc/profiler | ❌ (0/2)(You can also ask: 褚博宁, wjlflyer, liujunzhu, luochao60, huangyunlong2022) | ❌ (0/1)(You can also ask: huangjingwei, 陈豪, chujinjin, wangqiang160, chengpeng25) |
| torch_npu/profiler | ❌ (0/2)(You can also ask: rmch, kisnwang, luochao60, zqwenn, liangsongwei) | ❌ (0/1)(You can also ask: liujunzhu, wangqiang160, chengpeng25, wjlflyer, zyw-hw) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
denis_g, thanks for your pull request. All authors of the commits have signed the CLA. 👍


当前仓库存在以下 保护分支 :
| Protected Branch | Version | Release |
|---|---|---|
| master | ||
| v2.12.0 | ||
| v2.11.0 | ||
| v2.10.0 | ||
| v2.9.0 | ||
| v2.7.1 | ||
| v2.7.1-26.1.0 | ||
| v2.9.0-26.1.0 | ||
| v2.10.0-26.1.0 | ||
| v2.11.0-26.1.0 | ||
| v2.12.0-26.1.0 | ||
| ci-test |
评论 /sync <branch1> <branch2> ... 可将当前 PR 修改同步到其它分支(创建同步 PR):
a) 如果当前 PR 是 Open 状态,同步操作将延迟到 PR 被合并时执行
b) 如果当前 PR 已经 Merged,将立即执行同步操作
注意:
- /sync 命令可以指定同步到多个分支,仅最后一个 /sync 命令生效
- 如果创建的同步 PR 不正确,可通过向同步 PR 的源分支提交轻量级 PR 完善,或使用 /close 命令关闭


Linking Issue Notice
@denis_g , the pull request must be linked to at least one issue.
If an issue has already been linked, but the needs-issue label remains, you can remove the label by commenting /check-issue .


ascend docs pipeline is running...


| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_X86 | 🟣 INIT | >>> |
| Build_ARM | 🟣 INIT | >>> | |
| Build_X86_torchair | 🟣 INIT | >>> | |
| Build_ARM_torchair | 🟣 INIT | >>> | |
| patch_test | 🟣 INIT | >>> | |
| Build_X86_213 | 🟣 INIT | >>> | |
| Build_ARM_213 | 🟣 INIT | >>> | |
| 恶意代码检查 | Antipoison | ✅ COMPLETED | >>> |
| 编码安全与规范检查 | codecheck_pre-commit | ❌ FAILED | >>> |
| check_error | ✅ COMPLETED | >>> | |
| lintrunner | ❌ FAILED | >>> | |
| 开源片段检查 | SCA | ✅ COMPLETED | >>> |
| 开发者测试 | UT_ARM_A3_Part_01 | 🟣 INIT | >>> |
| UT_ARM_A3_Part_02 | 🟣 INIT | >>> | |
| UT_ARM_A2_Part_01 | 🟣 INIT | >>> | |
| UT_ARM_A2_Part_02 | 🟣 INIT | >>> | |
| UT_ARM_A2_Part_03 | 🟣 INIT | >>> | |
| UT_inductor_Part_01 | 🟣 INIT | >>> | |
| UT_inductor_Part_02 | 🟣 INIT | >>> | |
| UT_inductor_Part_03 | 🟣 INIT | >>> | |
| UT_inductor_Part_04 | 🟣 INIT | >>> | |
| UT_DIST_ARM_Part_01 | 🟣 INIT | >>> | |
| UT_DIST_ARM_Part_02 | 🟣 INIT | >>> | |
| UT_DIST_ARM_Part_03 | 🟣 INIT | >>> | |
| UT_DIST_ARM_Part_04 | 🟣 INIT | >>> | |
| UT_ARM_A2_Select_Part_01 | 🟣 INIT | >>> | |
| UT_ARM_A2_Select_Part_02 | 🟣 INIT | >>> | |
| UT_inductor_Part_213 | 🟣 INIT | >>> | |
| 流水线 | PR-pipeline_pytorch | ❌ FAILED | >>> |
- compile、compile_inductor、compile_torchair : 运行流水线
- retry : 重试流水线所有失败子任务
- retry <任务名> : 仅重试指定失败子任务
- stop : 停止流水线


| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_X86 | 🟣 INIT | >>> |
| Build_ARM | 🟣 INIT | >>> | |
| Build_X86_torchair | 🟣 INIT | >>> | |
| Build_ARM_torchair | 🟣 INIT | >>> | |
| patch_test | 🟣 INIT | >>> | |
| Build_X86_213 | 🟣 INIT | >>> | |
| Build_ARM_213 | 🟣 INIT | >>> | |
| 恶意代码检查 | Antipoison | ✅ COMPLETED | >>> |
| 编码安全与规范检查 | codecheck_pre-commit | ❌ FAILED | >>> |
| check_error | ✅ COMPLETED | >>> | |
| lintrunner | ❌ FAILED | >>> | |
| 开源片段检查 | SCA | ✅ COMPLETED | >>> |
| 开发者测试 | UT_ARM_A3_Part_01 | 🟣 INIT | >>> |
| UT_ARM_A3_Part_02 | 🟣 INIT | >>> | |
| UT_ARM_A2_Part_01 | 🟣 INIT | >>> | |
| UT_ARM_A2_Part_02 | 🟣 INIT | >>> | |
| UT_ARM_A2_Part_03 | 🟣 INIT | >>> | |
| UT_inductor_Part_01 | 🟣 INIT | >>> | |
| UT_inductor_Part_02 | 🟣 INIT | >>> | |
| UT_inductor_Part_03 | 🟣 INIT | >>> | |
| UT_inductor_Part_04 | 🟣 INIT | >>> | |
| UT_DIST_ARM_Part_01 | 🟣 INIT | >>> | |
| UT_DIST_ARM_Part_02 | 🟣 INIT | >>> | |
| UT_DIST_ARM_Part_03 | 🟣 INIT | >>> | |
| UT_DIST_ARM_Part_04 | 🟣 INIT | >>> | |
| UT_ARM_A2_Select_Part_01 | 🟣 INIT | >>> | |
| UT_ARM_A2_Select_Part_02 | 🟣 INIT | >>> | |
| UT_inductor_Part_213 | 🟣 INIT | >>> | |
| 流水线 | PR-pipeline_pytorch | ❌ FAILED | >>> |
- compile、compile_inductor、compile_torchair : 运行流水线
- retry : 重试流水线所有失败子任务
- retry <任务名> : 仅重试指定失败子任务
- stop : 停止流水线


This PR is blocked by feat(profiler): add CPU-to-NPU correlation for ACLprof
【合入来源】
【修改方案】
This PR adds opt-in diagnostics and hardware validation support for ACLprof CPU↔NPU correlation in the Kineto profiler backend. The existing correlation behavior remains unchanged when diagnostics are disabled.
Add opt-in ACLprof correlation diagnostics
TORCH_NPU_ACLPROF_CORRELATION_DEBUG.Add correlation and lifecycle counters
FOUND,NOT_FOUND, andAMBIGUOUS.Keep diagnostic work outside correlation-critical locking where possible
Improve correlation failure observability
Add hardware-independent unit-test coverage
Add a manual hardware validation tool
tools/kineto_aclprof_correlation_validation.pyfor validation on real Ascend hardware.Add correlation diagnostics documentation
【资料变更】
Documentation is updated.
Added
docs/aclprof_correlation_diagnostics.mddescribing:【接口变更】
No cross-repository or customer-visible API changes.
The added diagnostic environment variables, diagnostic artifacts, and validation script are intended for profiler diagnostics and maintainer validation. Existing profiler APIs and the default profiling behavior are unchanged.
【功能验证】
The changes were validated with both hardware-independent unit tests and a manual hardware validation run on Ascend hardware.
Profiler unit tests
Static/script validation
git diff --checkpassed.python3 -m py_compile tools/kineto_aclprof_correlation_validation.pypassed.python3 tools/kineto_aclprof_correlation_validation.py --helppassed.Real Ascend hardware validation
mkdir -p ./kineto_aclprof_cor_output python3 tools/kineto_aclprof_correlation_validation.py \ --output-dir ./kineto_aclprof_cor_output \ --device 0Two consecutive ACLprof profiling sessions were validated.
Each session produced:
converted_launches = 24successful_clock_conversions = 24FOUND = 24NOT_FOUND = 0AMBIGUOUS = 0final_links = 24Both sessions completed successfully and the tool reported:
This confirms that CPU↔NPU correlation is correctly captured, converted, matched, linked, and reset across consecutive profiling sessions on real Ascend hardware.
【CheckList】