| Files | Last commit | Last update |
|---|---|---|
style(all): Fix ruff-check lint errors across the codebase Co-authored-by: junjieHuang<huangjunjie38@h-partners.com> # message auto-generated for no-merge-commit merge: !4934 merge style-python-format into master style(all): Fix ruff-check lint errors across the codebase Created-by: junjieHuang Commit-by: junjieHuang Merged-by: cann-robot Description: Fix ruff-check lint errors across the codebase See merge request: cann/pypto!4934 | 4 months ago | |
fix(front): fix issue #3272 and #3274 add assemble parameter validation Co-authored-by: HuYiSheng01<hys123456aaa@163.com> # message auto-generated for no-merge-commit merge: !6098 merge fix/assemble-param-validation into master fix(front): fix issue #3272 and #3274 add assemble parameter validation Created-by: HuYiSheng01 Commit-by: HuYiSheng01 Merged-by: cann-robot Description: 额外修复了一个之前提交的文档的问题#3245 本 PR 包含 issue #3272 与 #3274 的两项配套修复: pypto.assemble 前端实现(operation.py)对参数数量与类型零校验,用户按 @overload 签名调用时,任何偏差都会泄露 Python 内部解包/迭代错误(无函数名、无签名提示、无源码位置)。 - #3272:参数顺序/类型传错(如 offsets 位置传 Tensor)时,深层调用链报 FeError: Tensor is not iterable 等内部错误,与用户实际意图完全脱节; - #3274:模块级 assemble 声明了 @overload 签名但运行时零校验,且缺少 @source_location 装饰器(对比 Tensor.assemble 方法),错误无法定位到用户调用点。 - assemble() 入口显式校验参数数量(单源 3 参 / 多源 2 参),其余情况抛出语义化错误; - 校验 src/dst 为 pypto.Tensor、offsets 为 list/tuple、srcs 为序列,错误信息包含函数名、参数位置、期望类型与实际类型; - 2 参形式且首参为 Tensor 时,附加提示"可能想使用单源形式但缺少 offsets 参数"。 Related Issue: #3272, #3274 #3245 See merge request: cann/pypto!6098 | 2 months ago | |
feat(platform): Add Platform config Co-authored-by: 2501_92924845<niulinkai@huawei.com> # message auto-generated for no-merge-commit merge: !6063 merge platformconfig into master feat(platform): Add Platform config Created-by: 2501_92924845 Commit-by: 2501_92924845 Merged-by: cann-robot Description: 背景: 原始的platform信息并沿用了机器层面命名。 本 PR 对平台配置域做概念规范化,统一到三个标准概念: 1. soc_series:原 short_soc_version(ini 键 Short_SoC_version),如 Ascend950; 2. soc_version:芯片分 bin(ini 键 SoC_version,每个 soc_version 一个 ini 文件),如 Ascend950PR_9589; 3. NPU_ARCH:核架构名称(ini 键 NpuArch),如 3510/2201。 A2/A3/A5 属于整机(chip + host CPU/网卡/机箱)层面的机器概念,不再用于平台配置选择。 Changes: - platform_config 精简为实际交付的 13 个 soc_version ini(69 -> 13),规格与 CANN 9.2.0 包内文件一致;Ascend910_9363、Ascend950DT_9581X 按交付需求保留 - DPlatform 枚举适配真实 soc_version,不再自定义枚举值:删除与实际芯片不符的 ASCEND_950DT_9579/ASCEND_950PR_9582(对应真实 bin 为 Ascend950DT_9572/Ascend950PR_9589), 补充 ASCEND_910_9363/ASCEND_950DT_9581X - platform.h 新增 DPlatformToNPUArch(),统一 soc_version -> NPU_ARCH 映射 (910B 系列 -> 2201,950 系列 -> 3510,Kirin -> 3113/3003) - GetCyclesForPass 仿真器选择改为按 NPU_ARCH 判断(3510 -> "A5",其余 -> "A2A3"), 不再按 A2A3/A5 机器名前缀匹配;A2A3/A5 仅作为 cost model 内部实现类型名保留 - 默认 device_platform 统一为标准格式 Ascend910B2(config_manager.h / tile_fwk_config.json) - CMakeLists 安装清单与交付 ini 清单保持一致 - UT 同步更新:枚举映射、legacy 格式兼容、NPU_ARCH 映射、ini 规格加载用例, 新增 Ascend910_9363 / Ascend950DT_9581X 用例 兼容性: - 旧格式 device_platform(如 "ASCEND_910B2")仍可识别,自动归一化为标准 soc_version 并打印告警; 其中 ASCEND_950DT_9579 -> Ascend950DT_9572、ASCEND_950PR_9582 -> Ascend950PR_9589, 与其原先实际加载的 ini 规格保持一致 - ASCEND_910C4 为无效值,回落默认 Ascend910B2(与原行为一致) Tests: - TestDevicePlatformConfig(16 例)、TestConfigManager、CostModelTest 相关用例全部通过; See merge request: cann/pypto!6063 | 2 months ago | |
fix(pypto-pro): lower loop target and classify tuple Co-authored-by: poorwill<wangbing110@huawei.com> # message auto-generated for no-merge-commit merge: !6261 merge master into master fix(pypto-pro): lower loop target and classify tuple Created-by: wangbing110 Commit-by: poorwill Merged-by: cann-robot Description: 1. add lower for loop target 2. classify tuple to tuple, named tuple, struct in parser 3. add doc for astype interface See merge request: cann/pypto!6261 | 2 months ago | |
fix(codegen): Uniquify the LiteNPU kernel entry name by function hash Co-authored-by: Nikita Larichev<nikita.larichev@h-partners.com> # message auto-generated for no-merge-commit merge: !5598 merge v3_01_litenpu into master fix(codegen): Uniquify the LiteNPU kernel entry name by function hash Created-by: Nikita17 Commit-by: Nikita Larichev Merged-by: cann-robot Description: fix(codegen): Uniquify the LiteNPU kernel entry name by function hash Split out of https://gitcode.com/cann/pypto/merge_requests/5158 for reviewability. This is the only part of that PR that changes framework code, and it is independent of the rest of the series. Two kernels built in separate processes can receive the same generated entry symbol, because the function-id counter that feeds the magic name restarts per process. When their artifacts are combined into one offline model the second kernel silently overwrites the first. Appending the function hash to the entry name makes the symbol depend on the kernel body rather than on process-local state. Changes: - Append the function hash to the LiteNPU kernel entry name so distinct kernel bodies cannot share an entry symbol - Add a Kirin9030 test that builds the same-named kernel in two fresh subprocesses and asserts identical bodies keep one name while different bodies get different names ### Revision notes - **Since the previous revision:** the duplicated LiteNPU entry-name formula is now a single member, Function::GetMagicNameWithHash(), called from both codegen sites and the launcher. The interim framework/src/interface/utils/kernel_entry_name.{h,cpp} pair introduced by an earlier revision is deleted — Function already lives under interface/, so a member has the same layering and link properties as a free function there and needs no new file. The test's build driver is now a real module, kernel_entry_uniqueness_driver.py, copied per build with the operation passed as an argument, rather than a templated source string. - **Review feedback:** answers all three comments on this PR — reuse rather than a second formula, a copied driver rather than a generated one, and the helper as a member of Function. - **Against custom_pypto_20260717_rebased, the monolithic branch this series was split from:** adds test_kirin9030_kernel_entry_uniqueness.py (4 tests), absent there. ### Why this is needed at all Before this change the emitted LiteNPU entry symbol was TENSOR_default_loop_1_Unroll1_PATH0_hiddenfunc0_5_main — **byte-identical across unrelated kernels**. On device that mis-dispatched: a two-kernel pipeline failed precision at cosine 0.924405, because one kernel's binary shadowed the other inside the combined offline model. An upstream change complicates the picture and is worth naming, because it invites the wrong conclusion. 51ff0e528 *"feat(ir): Switch new_ir config to true"* (2026-08-12) flipped new_ir from False to True, moving kernels from the AST parser onto the PIL pipeline. The two pipelines name functions differently, so magic names **acquired** a per-kernel component they did not have before. That was a feature switch, not a naming fix. It does not make this change unnecessary. On the current pipeline, across the shipped demo set, 16 distinct magic names include **3 that are each shared by two or three different kernels**: | magic name | kernels sharing it | |---|---| | add_kernel_PATH0_hiddenfunc_5 | add, add_softmax_pipeline, mixed_ascendc_pypto | | softmax_kernel_PATH0_hiddenfunc_5 | softmax, add_softmax_pipeline | | pypto_add_kernel_PATH0_hiddenfunc_5 | mixed_ascendc_pypto, mixed_torch_pypto | The function id is _5 in every one — Program::Reset() rewinds the counter per process, so the id never disambiguates. Each operator of a multi-operator offline model is exported and built by its own process and the artifacts are combined afterwards, which is exactly the regime where those names meet. test_distinct_entry_names_differ_only_in_the_content_hash asserts the collision directly: two same-named kernels with different bodies share a magic name and are separated by the content hash alone. new_ir=False also remains a supported argument, and restores the fully generic name where the hash does all of the work. Related Issues: [#2869](https://gitcode.com/cann/pypto/issues/2869), [#5158](https://gitcode.com/cann/pypto/merge_requests/5158) See merge request: cann/pypto!5598 | 2 months ago | |
fix(operation): Add missing arch and format constraint checks for matmul/scaled_mm Co-authored-by: shi-dingkun<shidingkun1@huawei.com> # message auto-generated for no-merge-commit merge: !5865 merge fix/matmul-arch-and-format-constraint-check into master fix(operation): Add missing arch and format constraint checks for matmul/scaled_mm Created-by: shi-dingkun Commit-by: shi-dingkun Merged-by: cann-robot Description: 为 matmul/scaled_mm 补齐接口文档中缺失的业务约束检查以及文档针对多核切K功能的描述修正,并修正 FP4 UT。 ## 约束检查 | 约束 | 检查位置 | |---|---| | 输入→输出 dtype 组合表(基础/量化/反量化场景) | __validate_out_dtype | | A2/A3 不支持 DT_HF8 输入 | __validate_inputs | | DT_HF8 不支持 NZ 格式 | __validate_inputs | | A2/A3 不支持 trans_mode | __validate_trans_mode | | scale_a/scale_b 仅支持 ND 格式 | __validate_scaled_inputs | | matmul 拒绝 FP4 输入(仅 scaled_mm 支持) | __validate_matmul_fp4_input | ## FP4 UT 修正 test_fp4_packed_shape.py 重写为正规写法:独立 X/Y 矩阵,scaled_mm + scale tensors + DT_FP16 输出。 ## 测试 test_matmul_op.py 20/20 通过,test_fp4_packed_shape.py 1/1 通过。 Related Issues: #3213 See merge request: cann/pypto!5865 | 2 months ago | |
style(all): Fix ruff-check lint errors across the codebase Co-authored-by: junjieHuang<huangjunjie38@h-partners.com> # message auto-generated for no-merge-commit merge: !4934 merge style-python-format into master style(all): Fix ruff-check lint errors across the codebase Created-by: junjieHuang Commit-by: junjieHuang Merged-by: cann-robot Description: Fix ruff-check lint errors across the codebase See merge request: cann/pypto!4934 | 4 months ago | |
feat(pro): direction-aware tensor shape profiling via pl.Input/pl.Output annotation markers Co-authored-by: gravel1997<shili19@huawei.com> Co-authored-by: gaoxiang<gaoxiang26@huawei.com> # message auto-generated for no-merge-commit merge: !6306 merge jit_profilling_attempt into master feat(pro): direction-aware tensor shape profiling via pl.Input/pl.Output annotation markers Created-by: gravel1997 Commit-by: gravel1997;gaoxiang Merged-by: cann-robot Description: feat(pro): direction-aware tensor shape profiling via pl.Input/pl.Output annotation markers Related Issue: [#3299](https://gitcode.com/cann/pypto/issues/3299) See merge request: cann/pypto!6306 | 2 months ago | |
fix(tests): Delete unused simulator add test case Co-authored-by: chai-hw<chaizhengtong@huawei.com> # message auto-generated for no-merge-commit merge: !5957 merge delete_ut into master fix(tests): Delete unused simulator add test case Created-by: chai-hw Commit-by: chai-hw Merged-by: cann-robot Description: 删除无用ut See merge request: cann/pypto!5957 | 2 months ago | |
feat(exported_custom_op): Add kernel-source introspection and the runtime compile contract Co-authored-by: Nikita Larichev<nikita.larichev@h-partners.com> # message auto-generated for no-merge-commit merge: !5599 merge v3_02_compile into master feat(exported_custom_op): Add kernel-source introspection and the runtime compile contract Created-by: Nikita17 Commit-by: Nikita Larichev Merged-by: cann-robot Description: Split out of https://gitcode.com/cann/pypto/merge_requests/5158 for reviewability. First functional piece of the exported custom-op subsystem: everything downstream needs a way to recover a kernel's source and to compile it under a stable contract. **API surface map for this whole series — every def with its signature, introducing PR and callers:** https://claude.ai/code/artifact/a42e70ca-5cf9-4a67-8eb3-b7d3c8e17f1a Changes: - Add kernel-source introspection for decorated kernel functions: source recovery, annotation-span editing, scope classification, and the authoring helpers that read a DIRECT kernel's declared shape/dtype constants and classify a factory's signature - Define the runtime compile contract: CompileEntry(jit_kernel=… | factory=…, num_inputs=, num_outputs=, factory_signature=), called as entry(shapes, dtypes, attrs, soc_version) -> compiled-kernel path, result cached per key. Construction accepts exactly one kernel form and rejects an unknown factory_signature or a non-positive input/output count; each call requires soc_version and checks the shape/dtype count against num_inputs - infer_shape / infer_dtype are read/write properties, rejecting a non-callable at assignment rather than deep in dispatch; without a hook every output takes the first input's shape and dtype - Enforce author-declared annotations at compile: a pinned dtype that disagrees with the runtime dtype raises, a pinned shape warns - Wire build_kernel through the frontend parser (single-object contract stated in its error), register the package in pyproject.toml - Add the kernel compile samples and the unit tests over the contract, the declared annotations and the warning paths Related Issues: [#2869](https://gitcode.com/cann/pypto/issues/2869), [#5158](https://gitcode.com/cann/pypto/merge_requests/5158) See merge request: cann/pypto!5599 | 2 months ago | |
fix(build): Flush gcov data for pytest-forked subprocess coverage Co-authored-by: chengding888<chengding1@hisilicon.com> # message auto-generated for no-merge-commit merge: !6148 merge master into master fix(build): Flush gcov data for pytest-forked subprocess coverage Created-by: chengding888 Commit-by: chengding888 Merged-by: cann-robot Description: ## 背景 Python UT 通过 --forked(pytest-forked)并行执行用例,子进程以 os._exit() 退出,会跳过 atexit 钩子,导致 gcov 的 __gcov_exit 不被调用、.gcda 覆盖率数据不落盘。因此 --gcov 无法统计到由 Python UT 触发的 C++ 覆盖率(issue #2705)。 ## 解决方案 1. **python/tests/ut/conftest.py**:新增 pytest_runtest_teardown 钩子,当环境变量 PYPTO_GCOV_FLUSH=1 时手动调用 __gcov_dump(),把内存中的计数器写入 .gcda;并补充 duration_estimate 装饰器。 2. **build_ci.py**:--gcov 时注入 PYPTO_GCOV_FLUSH=1。 3. **cmake/intf.cmake**:gcov 模式追加链接选项 -Wl,--export-dynamic,-u,__gcov_dump,--whole-archive,-lgcov,--no-whole-archive。仅加 -u,__gcov_dump 时 _gcov_dump.o 不会被 lgcov.a 拉入,__gcov_dump 保持未定义,ctypes.CDLL(None) 找不到该符号,必须用 --whole-archive 强制拉入。 4. **cmake/scripts/gen_coverage.py**:lcov >= 2.0 时追加 --ignore-errors inconsistent,将 lcov 2.3.1 对 pybind11.cpp 的 mismatched end line 由 ERROR 降级为 WARNING,避免覆盖率生成失败。 5. **tools/scripts/pre_commit_check.sh**: - 修正覆盖率开关(--py_cov → --gcov)、clang 失败退出码、GTEST_FILTER 保存/恢复、覆盖率标签等; - 移除本地增量覆盖率门禁:本地 gen_coverage.py --increment 与 CI 的 get_ai_inc_cov.py(addlcov) 是两套独立实现,增量覆盖率无法保证与 CI 一致,门禁统一由 CI 兜底。 ## 验证 - bash tools/scripts/pre_commit_check.sh --full 全部通过(gnu / clang+ASan / Python / costmodel 仿真,耗时约 4779s)。 - 确认 Python UT 触发场景下 C++ 覆盖率数据(.gcda)可正常落盘并被 --gcov 统计。 Related Issue: #2705 See merge request: cann/pypto!6148 | 2 months ago | |
fix(machine): fix log quality issues in machine module. Co-authored-by: chai-hw<chaizhengtong@huawei.com> # message auto-generated for no-merge-commit merge: !5679 merge pyptolog_fix into master fix(machine): fix log quality issues in machine module. Created-by: chai-hw Commit-by: chai-hw Merged-by: cann-robot Description: PyPTO machine 模块日志整改 See merge request: cann/pypto!5679 | 3 months ago |
| Files | Last commit | Last update |
|---|---|---|
| 4 months ago | ||
| 2 months ago | ||
| 2 months ago | ||
| 2 months ago | ||
| 2 months ago | ||
| 2 months ago | ||
| 4 months ago | ||
| 2 months ago | ||
| 2 months ago | ||
| 2 months ago | ||
| 2 months ago | ||
| 3 months ago |