已合并
fix: correct mixed Chinese/English punctuation in documentation #3570
fix: correct mixed Chinese/English punctuation in documentation #3570
已合并
tanmengjie创建于 8 天前
2 个文件变更+7-7
Mexamples/_kernel_extension_aclgraph/torch_library/README.md+2-2
@@ -49,7 +49,7 @@
49### 原地三角函数算子49### 原地三角函数算子
50 50 
51- 算子功能:51- 算子功能:
52- 该算子入参为x, out_sin ,out_cos, 算子调用后,out_sin会被原地修改为sin(x)计算结果,out_cos会被原地修改为cos(x)计算结果,返回值tan(x)计算结果。对应的算子原型为:52+ 该算子入参为xout_sinout_cos算子调用后,out_sin会被原地修改为sin(x)计算结果,out_cos会被原地修改为cos(x)计算结果,返回值tan(x)计算结果。对应的算子原型为:
53 53 
54 ```python54 ```python
55 ascendc_trig(Tensor x, Tensor(a!) out_sin, Tensor(b!) out_cos) -> Tensor55 ascendc_trig(Tensor x, Tensor(a!) out_sin, Tensor(b!) out_cos) -> Tensor
@@ -96,7 +96,7 @@
96 96 
97 - 注册Meta函数:97 - 注册Meta函数:
98 98 
99- 注册Meta函数使faketensor流程正常工作,在使用fx, compile等功能涉及,注册代码如下:99+ 注册Meta函数使faketensor流程正常工作,在使用fxcompile等功能涉及,注册代码如下:
100 100 
101 ```c++101 ```c++
102 TORCH_LIBRARY_IMPL(ascendc_ops, Meta, m)102 TORCH_LIBRARY_IMPL(ascendc_ops, Meta, m)
Mnpugraph_ex/design_principles.md+5-5
@@ -133,7 +133,7 @@
133| 限核功能冲突 | 同时开启限核(core limit)和静态 Kernel 编译时,CANN < 9.0.0 仅保留限核,自动禁用 static_kernel_compile | `graph_pass.py:780-791` |133| 限核功能冲突 | 同时开启限核(core limit)和静态 Kernel 编译时,CANN < 9.0.0 仅保留限核,自动禁用 static_kernel_compile | `graph_pass.py:780-791` |
134| Profiler 冲突 | Ascend PyTorch Profiler 开启算子信息统计(`record_op_args=True`)且 `skip_first=0` 时,不支持同时使用 | 文档约束 `docs/zh/npugraph_ex/basic/static_kernel_compile.md:18` |134| Profiler 冲突 | Ascend PyTorch Profiler 开启算子信息统计(`record_op_args=True`)且 `skip_first=0` 时,不支持同时使用 | 文档约束 `docs/zh/npugraph_ex/basic/static_kernel_compile.md:18` |
135| 路径安全检查 | `safe_resolve_output_dir()` 校验 build_dir 不含 null byte、`..` 遍历、恶意符号链接 | `static_kernel.py:804-843` |135| 路径安全检查 | `safe_resolve_output_dir()` 校验 build_dir 不含 null byte、`..` 遍历、恶意符号链接 | `static_kernel.py:804-843` |
136-| 缓存有效性条件 | 缓存命中需同时满足:CANN 版本不变、硬件型号不变、算子属性一致、确定性配置一致、super_kernel_optimize 一致 | `static_kernel.py:535-566`, 文档 `docs/zh/npugraph_ex/basic/static_kernel_compile.md:57-63` |136+| 缓存有效性条件 | 缓存命中需同时满足:CANN 版本不变、硬件型号不变、算子属性一致、确定性配置一致、super_kernel_optimize 一致 | `static_kernel.py:535-566`文档 `docs/zh/npugraph_ex/basic/static_kernel_compile.md:57-63` |
137| 缓存文件锁 | 使用 `fcntl.flock` 的共享锁(`LOCK_SH`)查询、排他锁(`LOCK_EX`)更新,通过 tmp 文件 + rename 实现原子更新 | `static_kernel.py:998-1045` |137| 缓存文件锁 | 使用 `fcntl.flock` 的共享锁(`LOCK_SH`)查询、排他锁(`LOCK_EX`)更新,通过 tmp 文件 + rename 实现原子更新 | `static_kernel.py:998-1045` |
138| 缓存目录归属 | 缓存目录必须由当前用户创建(ownership 校验),防止读取其他用户的编译产物 | `static_kernel.py:535-566` |138| 缓存目录归属 | 缓存目录必须由当前用户创建(ownership 校验),防止读取其他用户的编译产物 | `static_kernel.py:535-566` |
139| 算子黑名单 | 通过 `_set_static_kernel_blacklist()` 排除特定算子(如不支持静态编译的算子),黑名单中的 JSON 不参与编译 | `static_kernel.py:1048-1084` |139| 算子黑名单 | 通过 `_set_static_kernel_blacklist()` 排除特定算子(如不支持静态编译的算子),黑名单中的 JSON 不参与编译 | `static_kernel.py:1048-1084` |
@@ -144,7 +144,7 @@
144| CANN >= 9.0.0 适配 | CANN >= 9.0.0 时 `op_compiler` 需额外传入 `-f true` 参数 | `static_kernel.py:487-532` |144| CANN >= 9.0.0 适配 | CANN >= 9.0.0 时 `op_compiler` 需额外传入 `-f true` 参数 | `static_kernel.py:487-532` |
145| .run 包安装去重 | 安装 .run 包时通过内容哈希去重,已安装的相同包不重复执行 | `static_kernel.py:636-657` |145| .run 包安装去重 | 安装 .run 包时通过内容哈希去重,已安装的相同包不重复执行 | `static_kernel.py:636-657` |
146| 进程退出清理 | `atexit` 注册 `_finalize()` 调用 `uninstall_static_kernel()` 执行卸载脚本 | `__init__.py:29-44` |146| 进程退出清理 | `atexit` 注册 `_finalize()` 调用 `uninstall_static_kernel()` 执行卸载脚本 | `__init__.py:29-44` |
147-| 编译产物目录结构 | 固定产物目录名 `static_kernel_compile_outputs`,子目录按 `ts{timestamp}_pid{pid}_outputs` 组织 | `static_kernel.py:829`, 文档 `docs/zh/npugraph_ex/basic/static_kernel_compile.md:72-98` |147+| 编译产物目录结构 | 固定产物目录名 `static_kernel_compile_outputs`,子目录按 `ts{timestamp}_pid{pid}_outputs` 组织 | `static_kernel.py:829`文档 `docs/zh/npugraph_ex/basic/static_kernel_compile.md:72-98` |
148| 多卡编译汇聚 | 多卡场景仅 local rank 0 执行合并编译,生成一份 .run 文件,其他 rank 等待 barrier 后 reselect | `static_kernel.py:275-344` |148| 多卡编译汇聚 | 多卡场景仅 local rank 0 执行合并编译,生成一份 .run 文件,其他 rank 等待 barrier 后 reselect | `static_kernel.py:275-344` |
149| Gloo 超时配置 | 探测组超时 3 分钟,正式组超时 30 分钟 | `static_kernel.py:705-754` |149| Gloo 超时配置 | 探测组超时 3 分钟,正式组超时 30 分钟 | `static_kernel.py:705-754` |
150 150 
@@ -226,15 +226,15 @@
226 226 
227| 约束项 | 说明 | 代码位置 |227| 约束项 | 说明 | 代码位置 |
228|--------|------|----------|228|--------|------|----------|
229-| 环境变量时机约束 | `TORCH_COMPILE_DEBUG` 必须在 `import torchair` 前设置,否则 `debug.log` 文件不会创建(日志级别在模块导入时确定) | `core/utils.py:129`, 文档约束 `docs/zh/npugraph_ex/dfx/debug_save.md` |229+| 环境变量时机约束 | `TORCH_COMPILE_DEBUG` 必须在 `import torchair` 前设置,否则 `debug.log` 文件不会创建(日志级别在模块导入时确定) | `core/utils.py:129`文档约束 `docs/zh/npugraph_ex/dfx/debug_save.md` |
230| 路径安全检查 | 所有文件写入通过 `PathManager.check_path_writeable_and_safety()` 校验:路径长度 ≤ 4096、非符号链接、文件名 ≤ 255、正则字符白名单、目录权限 `0o750`、文件权限 `0o640`、属主校验 | `graph_transform_observer.py:154-165` |230| 路径安全检查 | 所有文件写入通过 `PathManager.check_path_writeable_and_safety()` 校验:路径长度 ≤ 4096、非符号链接、文件名 ≤ 255、正则字符白名单、目录权限 `0o750`、文件权限 `0o640`、属主校验 | `graph_transform_observer.py:154-165` |
231| output_code.py 文件锁 | `_dump_run_codegen()` 使用 `fcntl.LOCK_EX` 排他锁防止并发写入,文件权限 `0o600` | `npu_fx_compiler.py:1014-1033` |231| output_code.py 文件锁 | `_dump_run_codegen()` 使用 `fcntl.LOCK_EX` 排他锁防止并发写入,文件权限 `0o600` | `npu_fx_compiler.py:1014-1033` |
232| 分布式导入顺序 | 分布式场景下必须在脚本开头 `import npugraph_ex`,确保 `get_debug_dir()` 的 rank 后缀补丁在任何编译前生效 | 文档约束 `docs/zh/npugraph_ex/dfx/debug_save.md:22` |232| 分布式导入顺序 | 分布式场景下必须在脚本开头 `import npugraph_ex`,确保 `get_debug_dir()` 的 rank 后缀补丁在任何编译前生效 | 文档约束 `docs/zh/npugraph_ex/dfx/debug_save.md:22` |
233-| compile_fx 路径差异 | 使用 `compile_fx` API 时不生成 `dynamo_out_graph.txt`(AOT 前 FX 图),因为该路径不经过 `_compile_graph_with_aot()` | `npu_fx_compiler.py:943-945`, 文档约束 `docs/zh/npugraph_ex/dfx/debug_save.md:21` |233+| compile_fx 路径差异 | 使用 `compile_fx` API 时不生成 `dynamo_out_graph.txt`(AOT 前 FX 图),因为该路径不经过 `_compile_graph_with_aot()` | `npu_fx_compiler.py:943-945`文档约束 `docs/zh/npugraph_ex/dfx/debug_save.md:21` |
234| ACL 图 JSON 容错 | aclgraph 捕获后的 JSON dump 用 `try/except` 包裹,dump 失败不中断编译流程,异常记录到日志 | `acl_graph.py:1261-1269` |234| ACL 图 JSON 容错 | aclgraph 捕获后的 JSON dump 用 `try/except` 包裹,dump 失败不中断编译流程,异常记录到日志 | `acl_graph.py:1261-1269` |
235| 日志单例初始化 | `_init_debug_logging()` 通过全局 `_torchair_debug_log_path` 守卫确保 `FileHandler` 仅附加一次 | `core/utils.py:29-43` |235| 日志单例初始化 | `_init_debug_logging()` 通过全局 `_torchair_debug_log_path` 守卫确保 `FileHandler` 仅附加一次 | `core/utils.py:29-43` |
236| 分布式目录命名 | 分布式场景下运行目录追加 `-rank_<rank_id>` 后缀(如 `run_<时间>-pid_<进程号>-rank_<rank_id>`) | `core/utils.py:46-76` |236| 分布式目录命名 | 分布式场景下运行目录追加 `-rank_<rank_id>` 后缀(如 `run_<时间>-pid_<进程号>-rank_<rank_id>`) | `core/utils.py:46-76` |
237| ACL JSON 文件命名 | JSON 文件名包含 `rank_<device>` 标识,格式为 `graph_<N>_id_<id>_rank_<rank>_pid_<pid>_ts_<timestamp>.json` | `acl_graph.py:1261-1269` |237| ACL JSON 文件命名 | JSON 文件名包含 `rank_<device>` 标识,格式为 `graph_<N>_id_<id>_rank_<rank>_pid_<pid>_ts_<timestamp>.json` | `acl_graph.py:1261-1269` |
238| 线程安全阶段跟踪 | `debug_ctx = threading.local()` 确保并发编译(如有)的阶段跟踪互不干扰 | `graph_transform_observer.py:11` |238| 线程安全阶段跟踪 | `debug_ctx = threading.local()` 确保并发编译(如有)的阶段跟踪互不干扰 | `graph_transform_observer.py:11` |
239| C++ 日志级别静态初始化 | C++ 端 `tng_status.cpp` 在库加载时读取 `TORCH_COMPILE_DEBUG`,设置 TNG 日志级别为 DEBUG | `torchair/concrete_graph/tng_status.cpp:33-38` |239| C++ 日志级别静态初始化 | C++ 端 `tng_status.cpp` 在库加载时读取 `TORCH_COMPILE_DEBUG`,设置 TNG 日志级别为 DEBUG | `torchair/concrete_graph/tng_status.cpp:33-38` |
240-| 产物目录结构 | 固定位于 `torch_compile_debug/run_<时间>-pid_<进程号>[-rank_<rank_id>]/torchair/model__<N>/<phase>/` | `graph_transform_observer.py:91-123`, 文档 `docs/zh/npugraph_ex/dfx/debug_save.md:59-77` |240+| 产物目录结构 | 固定位于 `torch_compile_debug/run_<时间>-pid_<进程号>[-rank_<rank_id>]/torchair/model__<N>/<phase>/` | `graph_transform_observer.py:91-123`文档 `docs/zh/npugraph_ex/dfx/debug_save.md:59-77` |