Skip to content

chore: add convention checker - #591

Draft
voltjia wants to merge 6 commits into
masterfrom
chore/add-convention-checker
Draft

voltjia wants to merge 6 commits into
masterfrom
chore/add-convention-checker

Conversation

@voltjia

@voltjia voltjia commented May 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add scripts/check_conventions.py to enforce project-specific conventions that are not covered by clang-format or ruff.
  • Add .github/workflows/conventions.yml so the checker runs in CI for push and pull_request events.
  • Document local convention-checker usage in CONTRIBUTING.md.

Motivation

The project has contribution rules that generic formatters do not enforce, such as blank-line spacing between class members and repository-specific PR/commit checks. This PR adds an automated checker so those rules can run in CI and be reproduced locally.

N/A: no linked issue.

Type of Change

  • feat — new feature / new operator / new platform
  • fix — bug fix
  • perf — performance improvement (no behavioral change)
  • refactor — code restructuring without behavior change
  • test — adding or fixing tests only
  • docs — documentation only
  • build / ci — build system or CI configuration
  • chore — tooling, formatting, or other non-code changes
  • Breaking change (requires a ! in the Conventional Commits prefix or a BREAKING CHANGE: footer)

Platforms Affected

  • CPU (WITH_CPU)
  • NVIDIA (WITH_NVIDIA)
  • Iluvatar (WITH_ILUVATAR)
  • MetaX (WITH_METAX)
  • Cambricon (WITH_CAMBRICON)
  • Moore (WITH_MOORE)
  • Ascend (WITH_ASCEND)
  • PyTorch C++ bindings (WITH_TORCH)
  • Build system / CMake / CI
  • Python bindings / user-facing API

Test Results on Supported Platforms

Result file generated locally: ci-results/remote/convention-checker-20260507-120000/RESULTS.md.

Command:

REMOTE_DIR=/tmp/infiniops-ci-convention-checker \
RUN_ID=convention-checker-20260507-120000 \
bash /mnt/c/Users/huang/.codex/worktrees/7644/InfiniOps/.ci/run-all-platforms.sh \
  --skip-build --profile direct
Platform Built pytest Result Notes / Hardware
NVIDIA Yes Failed: 5 failed, 3108 passed, 1000 skipped in 195.73s Failures in tests/test_cast.py and tests/test_linear.py; test.log includes Fatal Python error: Aborted.
Iluvatar Yes Failed: 5 failed, 2909 passed in 231.89s Failures in tests/test_cast.py and tests/test_linear.py; test.log includes Fatal Python error: Aborted.
MetaX Yes Failed: 5 failed, 5452 passed, 1072 skipped in 376.41s Failures in tests/test_cast.py, tests/test_linear.py, and tests/test_matmul.py; test.log includes Fatal Python error: Aborted.
Cambricon Yes Failed: 17 failed, 3061 passed, 3770 skipped in 919.28s Failures in tests/test_add.py and CPU tests/test_matmul.py; first detailed error includes RuntimeError: "random_" not implemented for 'Short'.
Moore Yes Failed: 305 failed, 5450 passed, 1387 skipped in 727.70s Failures concentrated in tests/test_gemm.py and CPU tests/test_matmul.py; first detailed error includes RuntimeError: MmCall MUDNN failed in: RunWithBiasAdd.
Ascend Yes Failed: 5 failed, 3815 passed, 90 skipped in 502.19s; script exit test=137 test.log contains a pytest summary despite Docker/script exit 137; failures are in CPU tests/test_matmul.py.
Additional local validation
python3 scripts/check_conventions.py --base origin/master --head HEAD --check-git --pr-title "chore: add convention checker" --summary-by-code
Summary: 0 error(s), 0 warning(s).

python3 -m py_compile scripts/check_conventions.py
passed

uvx ruff check .
All checks passed!

uvx ruff format --check .
30 files already formatted
Result file content
Run ID: convention-checker-20260507-120000
Final branch head: f2b63d8

nvidia build=0 test=1
metax build=0 test=1
iluvatar build=0 test=1
moore build=0 test=1
cambricon build=0 test=1
ascend build=0 test=137

Full logs are under:
ci-results/remote/convention-checker-20260507-120000/<platform>/test.log

Benchmark / Performance Impact

N/A. This PR adds developer tooling and CI checks only.

Notes for Reviewers

The multi-platform runtime test suite did not pass, but the failures are in existing runtime operator tests while this PR only changes tooling, CI, and documentation. This PR is opened as draft so the failed platform results are visible before review.


Checklist

Title, Branch, and Commits

  • PR title follows Conventional Commits (e.g. feat(nvidia): …, fix(cuda/gemm): …).
  • Branch name follows <type>/xxx-yyyy-zzzz where <type> matches the PR title's Conventional Commits type and words are joined with hyphens (see CONTRIBUTING.md §Branches).
  • Each commit message follows Conventional Commits.
  • Commits are meaningful and well-formed; this PR can be squash-merged.
  • No stray merge commits from master — the branch is rebased cleanly on top of the current master.
  • No fixup! / squash! / wip commits remain.

Scope and Design

  • Changes are minimal — nothing unrelated to the stated motivation was added (CONTRIBUTING.md §Code/General).
  • No dead code, commented-out blocks, debug prints, printf/std::cout/print(...) left behind, or TODO without an owner and issue link.
  • No unrelated formatting churn that would obscure the diff.
  • N/A: no public runtime API changes.

General Code Hygiene (applies to all languages)

  • The code is self-explanatory; comments were added only where the why is non-obvious (CONTRIBUTING.md §Code/General).
  • Every modified or added file ends with a single trailing newline (CONTRIBUTING.md §Code/General).
  • No trailing whitespace, tab/space mixing, or stray BOMs.
  • Identifiers in comments and error messages are wrapped in backticks (e.g. the `seqlens_k` tensor) (CONTRIBUTING.md §Code/General).
  • All comments and error messages are in English (CONTRIBUTING.md §Code/General).
  • Comments and error messages are complete sentences — capitalized first letter, terminal punctuation — unless the language/framework convention says otherwise (CONTRIBUTING.md §Code/General; §Python).

C++ Specific (if C++ files changed)

N/A: no C++ files changed.

Python Specific (if Python files changed)

  • Code is PEP 8 compliant; ruff check passes cleanly on CI (see .github/workflows/ruff.yml).
  • ruff format --check passes cleanly — if not, run ruff format and commit the result.
  • Comments are complete English sentences, starting with a capital letter and ending with punctuation; Markdown backticks are used for code references (CONTRIBUTING.md §Python).
  • Framework-specific conventions are honored where applicable (CONTRIBUTING.md §Python).
  • No blank line between the function signature and the body when there is no docstring or comment (CONTRIBUTING.md §Python).
  • A blank line is present before and after if, for, and similar control-flow statements (CONTRIBUTING.md §Python).
  • A blank line appears before each return, except when it directly follows a control-flow statement (CONTRIBUTING.md §Python).
  • Docstrings (if any) follow PEP 257 (CONTRIBUTING.md §Python).
  • Type hints are added / kept consistent with the surrounding code.

Testing

  • pytest was run locally on every supported platform that this PR can affect, and the results are recorded in the "Test Results" table above (CONTRIBUTING.md §Pull Requests).
  • N/A: no platform was skipped; all six remote platform jobs were attempted.
  • N/A: no runtime operator functionality was added.
  • N/A: no new pytest parameterization was added.
  • N/A: no Payload-returning test was added.
  • N/A: no new default dtype / device parameterization was added.
  • N/A: no flaky test was added.
  • N/A: this is not a runtime bug fix.

Build, CI, and Tooling

  • The project builds cleanly from a fresh directory with pip install .[dev] on affected platforms; all multi-platform runs reported build=0.
  • N/A: compile_commands.json behavior was not changed.
  • N/A: no new backend or device was added.
  • N/A: CUDA-like backend mutual exclusion was not changed.
  • Existing CI workflows (clang-format.yml, ruff.yml) are green locally or expected to be green on CI; this PR also adds conventions.yml.
  • No new runtime dependency was added without updating pyproject.toml.

Documentation

  • CONTRIBUTING.md was updated for the new developer workflow.
  • N/A: no new operator, dispatch helper, or public utility was added.
  • N/A: no user-visible breaking change.

Security and Safety

  • No secrets, access tokens, internal URLs, customer data, or personal hardware identifiers have been committed.
  • N/A: no third-party code was added.
  • N/A: no unsafe pointer arithmetic, uninitialized reads, or missing bounds checks were introduced.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant