Closed
PyPTO basic operations CLI documentation mismatch #3452
KaranocaVeAdd on  Sep 24Closed at  Oct 10
KaranocaVe
KaranocaVe
Sep 24 Create

PyPTO basic operations CLI documentation mismatch

Scope

  • Repository: cann/pypto
  • Source commit: 289942aa3e0c0c0bc9e054c72bafb199200e392f

Public evidence

The two top-level examples guides describe these commands:

python3 examples/01_beginner/basic/basic_ops.py matmul::test_matmul
python3 examples/01_beginner/basic/basic_ops.py --list

At the fixed source commit, basic_ops.py registers matmul as a test name (lines 171-177), and its parser defines only -m/--run_mode and -t/--tests (lines 179-195). There is no positional test selector and no --list option. The specific test command must therefore be --tests matmul; --help is the available way to display the choices.

Expected and actual behavior

  • Expected: every command in the public quick-start guide is accepted by the referenced script and selects or describes the documented operation.
  • Actual: matmul::test_matmul is rejected as an unrecognized positional argument, and --list is rejected as an unrecognized option. The guide cannot be followed as written for either documented workflow.

Controls and boundary

The argparse behavior was checked with a minimal import stub so the parser could be exercised without changing the source or requiring PyTorch/PyPTO. --help exits 0 and lists -m/--run_mode, -t/--tests, and choices including matmul; both documented invalid forms exit 2. A valid parser control, --tests matmul --run_mode sim, is accepted and proceeds to the selected test.

The host used for validation does not provide torch, pypto, or torch_npu, so full kernel execution was not claimed. This limitation does not affect the argparse contract or the documentation defect.

Minimal repair

Update the two commands in both language versions of examples/README:

  • replace the unsupported positional selector with --tests matmul;
  • replace the unsupported --list command with --help, whose output includes all available test choices.

No source-code behavior change is required.

Validation

Validation

Fixed source

repository: cann/pypto
source_commit: 289942aa3e0c0c0bc9e054c72bafb199200e392f

The source checkout resolved the requested commit exactly. Public commit-pinned URLs for both README files and basic_ops.py returned HTTP 200.

Static contract

At examples/01_beginner/basic/basic_ops.py:

  • lines 171-177 register add, erfc, matmul, sum, and dynamic_add;
  • lines 179-195 define only -m/--run_mode and -t/--tests;
  • lines 197-205 select and run the requested tests.

At examples/README.md and examples/README_en.md, lines 53 and 56 respectively use the unsupported positional selector and --list option.

Commands and results

The direct command was attempted first:

python3 examples/01_beginner/basic/basic_ops.py --help

Exit code: 1

Key output:

ModuleNotFoundError: No module named 'torch'

The environment has no torch, pypto, or torch_npu. To isolate the documented CLI contract from those runtime prerequisites, the same script was loaded with minimal torch and pypto import stubs. The stubs did not replace argparse or alter the parser.

ARGS: ['--help']
EXIT: 0
usage: basic_ops.py [-h] [-m {npu,sim}] [-t [TEST ...]]
...
  -t, --tests [TEST ...]
                        Test cases to run (default: all). Choices: add, erfc,
                        matmul, sum, dynamic_add

ARGS: ['matmul::test_matmul']
EXIT: 2
basic_ops.py: error: unrecognized arguments: matmul::test_matmul

ARGS: ['--list']
EXIT: 2
basic_ops.py: error: unrecognized arguments: --list

ARGS: ['--tests', 'matmul', '--run_mode', 'sim']
EXIT: 1
Running test_matmul ...
AttributeError: module 'torch' has no attribute 'randn'

The last command reaches test_matmul, proving that the corrected selector and run-mode options are accepted by argparse; the subsequent failure is only the intentionally minimal runtime stub.

Patch validation

The proposed fix.patch changes only the four stale command lines in the Chinese and English top-level examples guides. The patch was regenerated without blank context lines, so the patch file itself has no trailing-whitespace diagnostics at the four previously reported lines.

Validation was performed against source commit 289942aa3e0c0c0bc9e054c72bafb199200e392f:

git apply --check --unidiff-zero fix.patch
# exit 0

# In a temporary Git copy initialized from the two fixed-commit README files:
git apply --unidiff-zero fix.patch
# exit 0
git diff --check -- examples/README.md examples/README_en.md
# exit 0

The patch is generated with git diff -U0, so applying it requires Git's explicit --unidiff-zero option. The applied diff contains six insertions and six deletions, limited to the two documented command pairs and their comments. No source file or runtime behavior is changed.

Conclusion

The defect is reproducible at the pinned commit as a documentation-to-CLI mismatch. The smallest repair is a documentation-only update in both language files. Full NPU/kernel execution remains outside this validation because the required runtime packages and device environment are absent.

关联 PR: https://gitcode.com/cann/pypto/merge_requests/6719

likedislike
KaranocaVeKaranocaVe
Sep 24 Modify description of issue
KaranocaVeKaranocaVe
Sep 24 Modify description of issue
lidongsheng
lidongshengCollaborators
Sep 28 Comments:

请及时处理相关PR

likedislike
KaranocaVe
KaranocaVe
Sep 28 Comments:

已重新检查 PR !6719 当前 head deffa51。改动仍只有两份 README;两次流水线分析都指向未修改的 python/tests/ut/pypto_pro/test_error_format.py:934,目前没有证据表明失败由这次文档变更引起,因此没有改代码或重复触发流水线。PR Approval Progress 仍显示 examples 模块为 0/2 LGTM、0/1 approve;检查也显示我当前没有 PUSH 权限。请模块维护者确认该 UT 失败的处理方式并补齐审批,由有权限的成员完成合入。

likedislike
lidongshenglidongshengCollaborators
Oct 8 Assign songle1 as responsible person
lidongshenglidongshengCollaborators
Oct 8 Added label: Frontend
lidongsheng
lidongshengCollaborators
Oct 8 Comments:

感谢对PyPTO项目贡献,PR reviewed

likedislike
KaranocaVe
KaranocaVe
Oct 10 Comments:

已由关联 PR !6719 修复并合入,关闭此 Issue。

likedislike
KaranocaVeKaranocaVe
Oct 10 Close issue
CANN-robotCANN-robotCollaborators
Oct 11 Added label: resolved
KaranocaVe
KaranocaVe
Oct 22 Comments:

@tsungl4 您好,这个 Issue 对应的修复已经合入:https://gitcode.com/cann/pypto/merge_requests/6719

开发者计划反馈,Issue 需要有 Accepted 标签才能计入积分,仅关闭或标记 resolved 还不够。目前这条 Issue 尚未标记 Accepted,麻烦您结合问题和已合入的修复复核一下;确认符合受理条件后,帮忙补上 Accepted 标签。

感谢您的支持!

likedislike