feat(torch): add generated operator bases#622
Open
voltjia wants to merge 1 commit into
Open
Conversation
9444f9c to
9864ff2
Compare
33e537c to
ffc3d68
Compare
9864ff2 to
c0db647
Compare
ffc3d68 to
d89ce8e
Compare
c0db647 to
3e3e319
Compare
fe50963 to
c5a3a38
Compare
56 tasks
c5a3a38 to
312cd42
Compare
3e3e319 to
2a5d6af
Compare
34db70e to
f5f6a15
Compare
d41f01d to
9f591db
Compare
f5f6a15 to
ee42c3c
Compare
9f591db to
70094a1
Compare
ee42c3c to
9299ffb
Compare
70094a1 to
87e86ab
Compare
9299ffb to
1c61728
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/base/, regenerated from the currentfeat/torch-codegen-optional-overloadsgenerator output.Motivation
The PyTorch codegen work needs a checked-in operator-base layer that matches the current generator behavior, including optional-parameter overload support from PR #619. The larger generated base set also exposes wrapper-generation cost and missing-wrapper test behavior that need to be handled before the bases can be validated across all supported platforms.
Closes # N/A — no dedicated issue.
Type of Change
feat— new feature / new operator / new platformfix— bug fixperf— performance improvement (no behavioral change)refactor— code restructuring without behavior changetest— adding or fixing tests onlydocs— documentation onlybuild/ci— build system or CI configurationchore— tooling, formatting, or other non-code changes!in the Conventional Commits prefix or aBREAKING CHANGE:footer)Platforms Affected
WITH_CPU)WITH_NVIDIA)WITH_ILUVATAR)WITH_METAX)WITH_CAMBRICON)WITH_MOORE)WITH_ASCEND)WITH_TORCH)Test Results on Supported Platforms
All rows used a full bare
python3 -m pytest -vrun, withouttests/,--devices, or-n. Each build regenerated PyTorch operator sources first, installed withWITH_TORCH=ON, and smoke-checked representative generated PyTorch operators after install. Build times are from thepip installphase recorded by the local validation runner; pytest times are from the timed pytest command; total time isgenerate + build + pytest.pytestResult6304 passed, 11538 skipped in 337.64s8.4804 passed, 11520 skipped in 557.07s8.5804 passed, 10520 skipped in 354.50s8.3082 passed, 12858 skipped in 921.19s8.5768 passed, 10574 skipped in 569.91s8.4481 passed, 11801 skipped in 533.13s8. The container exited with code 137 after pytest had already emitted a passing summary.Full `pytest` output (optional)
The test counts are higher than earlier PR-body snapshots because this branch now includes the generated PyTorch operator-base set and full bare pytest collects
tests/test_torch_ops.pywithWITH_TORCH=ON. The platform-to-platform count differences come from vendor PyTorch schema availability and explicit known vendor-kernel skips in the generated torch-op harness.Benchmark / Performance Impact
Wrapper generation now runs in parallel by default and skips base headers that have no platform implementation in the scanned implementation set. This keeps the generated-base branch practical to build with the larger checked-in
src/base/set; the all-platform validation above records the resulting generate, build, and pytest times.Notes for Reviewers
This PR is stacked on PR #619 because the regenerated base signatures depend on the optional-parameter hashing and overload handling introduced there. The PR should be retargeted to
masterafter #619 lands, or merged after #619.The generated base files are intentionally checked in as generator output. File paths are kept flat under
src/base/.The generated bases intentionally omit
src/base/all.h,src/base/any.h, andsrc/base/internal_scaled_mm.hin this PR because their ATen schemas vary across installed PyTorch builds; those forms are better regenerated by the local codegen environment instead of frozen as stable public bases.Checklist
Title, Branch, and Commits
feat(nvidia): …,fix(cuda/gemm): …).<type>/xxx-yyyy-zzzzwhere<type>matches the PR title's Conventional Commits type and words are joined with hyphens (seeCONTRIBUTING.md§Branches).CONTRIBUTING.md§Pull Requests).master— the branch is rebased cleanly on top of the currentmasterthrough PR feat(torch): expose optional codegen parameters #619.fixup!/squash!/wipcommits remain.Scope and Design
CONTRIBUTING.md§Code/General).printf/std::cout/print(...)left behind, orTODOwithout an owner and issue link.General Code Hygiene (applies to all languages)
CONTRIBUTING.md§Code/General).CONTRIBUTING.md§Code/General).the `seqlens_k` tensor) (CONTRIBUTING.md§Code/General).CONTRIBUTING.md§Code/General).CONTRIBUTING.md§Code/General; §Python).C++ Specific (if C++ files changed)
clang-format(version 21, per.github/workflows/clang-format.yml) has been run against all modified.h,.cc,.cuh, and.mlufiles; the diff is clean.clang-tidyconcerns (per.clang-tidy) have been reviewed — no new warnings beyond the existing baseline.CONTRIBUTING.md§C++).assertwith messages that include at least__FILE__,__LINE__, and__func__(CONTRIBUTING.md§C++).CONTRIBUTING.md§C++).CONTRIBUTING.md§C++).CONTRIBUTING.md§C++).CONTRIBUTING.md§C++).CONTRIBUTING.md§C++).src/base/<op>.h(inheritingOperator<Op>) with platform implementations undersrc/<category>/<platform>/inheriting the base (CONTRIBUTING.md§Adding an Operator).new/delete; RAII / smart pointers / existing allocators are used.Python Specific (if Python files changed)
ruff checkpasses cleanly on CI (see.github/workflows/ruff.yml).ruff format --checkpasses cleanly — if not, runruff formatand commit the result.CONTRIBUTING.md§Python).pytest.skipmessages without terminal period) are honored where applicable (CONTRIBUTING.md§Python).CONTRIBUTING.md§Python).if,for, and similar control-flow statements (CONTRIBUTING.md§Python).return, except when it directly follows a control-flow statement (CONTRIBUTING.md§Python).Testing
pytestwas 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).tests/followingtests/test_add.py/tests/test_gemm.pypatterns (CONTRIBUTING.md§Adding an Operator).pytest.mark.parametrizecorrectly: dependent parameters share one decorator (e.g.@pytest.mark.parametrize("dtype, rtol, atol", …)), independent parameters use separate decorators ordered by parameter declaration.pytest.mark.auto_act_and_assertis used and the test returns aPayloadwhosefuncandrefshare the same calling convention.dtype/deviceparameterization is relied on, or overridden with an explicitpytest.mark.parametrizewhen necessary.Build, CI, and Tooling
pip install .[dev]on at least one affected platform.compile_commands.jsonstill regenerates (CMake optionCMAKE_EXPORT_COMPILE_COMMANDS=ONinpyproject.toml— required by thecode-lintskill andclang-tidy -p).CMakeLists.txtis not broken.clang-format.yml,ruff.yml) are green locally (or expected to be green on CI).pyproject.toml's[project.optional-dependencies](or justified in the PR description).Documentation
CONTRIBUTING.md§Some Code Explanations).Security and Safety