| 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 | |
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 | |
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 | |
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 | |
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 | |
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 | |
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(operation): Fix lrelu fp16 precision and negative_slope validation Co-authored-by: raoliang_sac<raoliang4@huawei.com> # message auto-generated for no-merge-commit merge: !5230 merge fix-lrelu-precision-and-validation into master fix(operation): Fix lrelu fp16 precision and negative_slope validation Created-by: raoliang_sac Commit-by: raoliang_sac Merged-by: cann-robot Description: ## 问题描述 pypto.lrelu 算子存在两个问题: ### 问题1:FP16/BF16 精度与 torch_npu 不一致 当输入 tensor 为 fp16/bf16 时,negative_slope(创建为 Element(DT_FP32))被 C++ 层 BinaryOperationScalar 截断为输入 dtype,导致硬件指令 TLRELU 做 fp16×fp16→fp16 乘法。而 torch_npu F.leaky_relu 和 AscendC leaky_relu 算子均在 fp32 下计算后 Cast 回原类型,两者精度存在系统性差异。 ### 问题2:negative_slope 缺少负数/NaN/inf 校验 negative_slope 接受负数、NaN、inf 时无报错,违反文档约束"必须为非负实数(≥ 0),不支持 nan、inf"。 ## 根因分析 **问题1根因链**: - 硬件指令 TLRELU(pto-isa/include/pto/npu/a2a3/TLRelu.hpp:59)要求 scalar 类型与 tile 类型一致 - Python 层 math.py:442 创建 Element(DT_FP32, negative_slope),但 C++ binary.cpp:1142 的 BinaryOperationScalar 将其截断为输入 dtype - AscendC leaky_relu 算子(leaky_relu_apt.cpp:34-38)通过 LeakyReluCastDag(leaky_relu_dag.h:68-78)正确处理:CopyIn<half> -> Cast<float> -> Muls(fp32 slope) -> Cast<half> -> CopyOut **问题2根因**:lrelu 函数缺少参数校验逻辑 ## 修复方案 ### 问题1:fp16/bf16 输入内部提升到 fp32 计算 参照 AscendC leaky_relu 算子和 Atan2 算子的处理模式,在 Python 层对 fp16/bf16 输入做: 1. Cast(input, DT_FP32) — 提升到 fp32 2. LReLU(fp32_input, fp32_slope) — 在 fp32 下计算 3. Cast(result, orig_dtype) — Cast 回原类型 同时统一 negative_slope 始终转为 Element(DT_FP32, ...),无论传入 float 还是 Element。 ### 问题2:添加 negative_slope 校验 对 negative_slope 值检查: - 负数 -> PyptoError(ValueError("negative_slope must be non-negative")) - NaN -> PyptoError(ValueError("negative_slope must not be NaN")) - inf -> PyptoError(ValueError("negative_slope must not be inf")) ## 验证结果 ### 精度验证(759x392 fp16, alpha=0.182676732) | 指标 | 修复前 | 修复后 | torch_npu | |------|--------|--------|-----------| | RMSE vs golden | 0.0016153 | **0.0007846** | 0.0007846 | | RMSE ratio | 2.0589 | **1.000000** | 1.0 | | 20 seed 通过率 | 12/20 PASS | **20/20 PASS** | - | | 逐元素一致性 | 有差异 | **完全一致** | - | ### 拦截验证 | 输入 | 修复前 | 修复后 | |------|--------|--------| | negative_slope=-0.1 | 无报错 | **PyptoError(ValueError)** | | negative_slope=NaN | 无报错 | **PyptoError(ValueError)** | | negative_slope=inf | 无报错 | **PyptoError(ValueError)** | | fp32 基础功能 | PASS | **PASS(无回归)** | ## 变更文件 | 文件 | 变更说明 | |------|---------| | python/pypto/op/math.py | fp16/bf16 输入 Cast->fp32 计算->Cast 回;统一 slope 为 DT_FP32;添加负数/NaN/inf 校验 | | docs/zh/api/operation/pypto-lrelu.md | 更新参数说明和约束说明,删除"fp16不保证正确性",改为"fp32内部计算后Cast回原类型" | Related Issue: #2853 See merge request: cann/pypto!5230 | 3 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 | |
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 | |
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(operation): Mxquant support -2 axis Co-authored-by: bynshard<zhangbingshuai@huawei.com> # message auto-generated for no-merge-commit merge: !4382 merge mxquant-penultimate-axix into master feat(operation): Mxquant support -2 axis Created-by: bynshard Commit-by: bynshard Merged-by: cann-robot Description: 为 MxQuant 新增 axis=-2 支持,实现 FP8 和 FP4 输出的 DN 轴量化,并完善 shape 推导、scale 布局、切分逻辑、解释器、Golden 生成、对齐校验和接口文档。 新增 100 个测试用例,覆盖不同输入类型、输出类型、舍入模式、Shape 和对齐场景;同时对已有 axis=-1 场景进行了回归测试,确保功能向后兼容。 更多描述信息见:[Commit Message 规范](../docs/zh/contribute/pull-request.md#commit-message) See merge request: cann/pypto!4382 | 3 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 | |
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 | |
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 |
| Files | Last commit | Last update |
|---|---|---|
| 4 months ago | ||
| 4 months ago | ||
| 4 months ago | ||
| 4 months ago | ||
| 4 months ago | ||
| 4 months ago | ||
| 4 months ago | ||
| 3 months ago | ||
| 4 months ago | ||
| 4 months ago | ||
| 4 months ago | ||
| 3 months ago | ||
| 4 months ago | ||
| 4 months ago | ||
| 4 months ago |