feat(hygon-gemm): add Hygon backend support for Add/Gemm#31
Open
gongchensu wants to merge 4 commits intoInfiniTensor:masterfrom
Open
feat(hygon-gemm): add Hygon backend support for Add/Gemm#31gongchensu wants to merge 4 commits intoInfiniTensor:masterfrom
gongchensu wants to merge 4 commits intoInfiniTensor:masterfrom
Conversation
a56e674 to
2290578
Compare
Contributor
Author
9b9dda2 to
e397d93
Compare
e397d93 to
c8d8b56
Compare
c8d8b56 to
ceb9a4c
Compare
aa6ed00 to
8fd111a
Compare
8fd111a to
b1117d4
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/hygon/device_.hsrc/hygon/runtime_.hsrc/hygon/runtime_utils.hsrc/hygon/blas.hsrc/hygon/blas_utils.hWITH_HYGON:CMakeLists.txt.src/CMakeLists.txt.Addinsrc/hygon/add/kernel.h.Gemminsrc/hygon/gemm/cublas.h.src/pybind11_utils.hso CUDA-compatible PyTorch device names can map to the active InfiniOps backend, including Hygon.examples/CMakeLists.txtexamples/runtime_api.hREADME.md.gitignorefor generated local build artifacts.Motivation
This PR introduces initial Hygon backend support to InfiniOps.
Hygon DCU platforms expose a CUDA/HIP-compatible programming model, so InfiniOps can reuse the existing CUDA-style operator organization while adding Hygon-specific runtime, device, BLAS, and build-system integration. This enables InfiniOps to compile and dispatch selected operators on Hygon hardware without changing the public operator API.
The first supported operators are
AddandGemm, which provide a minimal but useful backend foundation:Addvalidates the basic Hygon kernel dispatch path.Gemmvalidates the Hygon BLAS integration path.This PR is intentionally scoped to backend infrastructure plus
AddandGemm. Follow-up PRs can add more Hygon operator implementations on top of the same backend layer.No linked 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_HYGON)WITH_TORCH)Test Results on Supported Platforms
pytestResultSuccessfully installed InfiniOps-0.1.0tests/test_add.pyandtests/test_gemm.pygit ls-files | rg '\.(h|cc|cuh|mlu)$' | xargs clang-format --dry-run --Werrorclang-formatversion21.1.2Full `pytest` output (optional)
Benchmark / Performance Impact
No benchmark numbers are included in this PR.
This PR adds initial Hygon backend support and validates functionality through
AddandGemm. It does not change existing CPU, NVIDIA, Iluvatar, MetaX, Cambricon, Moore, or Ascend implementations. Performance tuning for Hygon kernels and BLAS usage can be handled in follow-up PRs once the backend integration is established.Notes for Reviewers
src/hygon/gemm/cublas.hintentionally follows the existing BLAS-backed GEMM structure used by CUDA-like platforms.src/pybind11_utils.hnow accepts backend-specific internal device names in addition to PyTorch device names, so a CUDA-compatible PyTorch device type can resolve to the enabled InfiniOps backend.feat(hygon): add Hygon backend infrastructurefeat(hygon-add): add Hygon backend support for Addfeat(hygon-gemm): add Hygon backend support for GemmChecklist
Title, Branch, and Commits
feat(hygon): add Add and Gemm backend support).<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 feat: support GEMM on CPU & MetaX and add generic dispatcher #1).master— the branch is rebased cleanly on top of the currentmaster.fixup!/squash!/wipcommits remain.Scope and Design
AddandGemmsupport (CONTRIBUTING.md§Code/General feat: support GEMM on CPU & MetaX and add generic dispatcher #1).printf/std::cout/print(...)left behind, orTODOwithout an owner and issue link.General Code Hygiene (applies to all languages)
CONTRIBUTING.md§Code/General build: add CMake build system and README #2).CONTRIBUTING.md§Code/General feat(gemm-iluvatar): add Iluvatar GEMM backend support #3).the `seqlens_k` tensor) (CONTRIBUTING.md§Code/General feat: add the implementation ofAddoperator on CPU, NVIDIA, and MetaX #4).CONTRIBUTING.md§Code/General refactor: adapt dispatcher for full C++17 compatibility and supportpip installon MetaX #5).CONTRIBUTING.md§Code/General feat(ops): addRmsNormwith Iluvatar, NVIDIA, CPU backends and fp16/bf16 support #6; Python build: add CMake build system and README #2).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++ build: add CMake build system and README #2).CONTRIBUTING.md§C++ feat(gemm-iluvatar): add Iluvatar GEMM backend support #3).CONTRIBUTING.md§C++ feat: add the implementation ofAddoperator on CPU, NVIDIA, and MetaX #4).kernel/kernel_v2/ …; well-known algorithms use the algorithm name; library-based implementations use the library name (CONTRIBUTING.md§C++ refactor: adapt dispatcher for full C++17 compatibility and supportpip installon MetaX #5).CONTRIBUTING.md§C++ feat(ops): addRmsNormwith Iluvatar, NVIDIA, CPU backends and fp16/bf16 support #6).CONTRIBUTING.md§C++ feat: add the implementation ofGemmoperator on Cambricon #7).CONTRIBUTING.md§C++ feat(ops): add Iluvatar GPU backend forAdd#8).CONTRIBUTING.md§C++ feat/devcausalsoftmaxcudaDraft#9).CONTRIBUTING.md§C++ feat: addswigluop with NVIDIA and CPU backends #10).src/hygon/and use the existing base operator structure (CONTRIBUTING.md§Adding an Operator feat: support GEMM on CPU & MetaX and add generic dispatcher #1–2).new/delete; RAII / smart pointers / existing allocators are used.Python Specific (if Python files changed)
ruff checkis not applicable to this PR because no Python source files were changed.ruff format --checkis not applicable to this PR because no Python source files were changed.Testing
pytestwas run locally on Hygon hardware, and the results are recorded in the "Test Results" table above (CONTRIBUTING.md§Pull Requests feat(gemm-iluvatar): add Iluvatar GEMM backend support #3).tests/, especiallytests/test_add.pyandtests/test_gemm.py(CONTRIBUTING.md§Adding an Operator feat(gemm-iluvatar): add Iluvatar GEMM backend support #3).pytest.mark.parametrizecorrectly through the existing project test patterns.pytest.mark.auto_act_and_assertcoverage is reused and the test returns aPayloadwhosefuncandrefshare the same calling convention.dtype/deviceparameterization is relied on, or overridden with an explicitpytest.mark.parametrizewhen necessary.master.Build, CI, and Tooling
pip install .[dev]on Hygon.compile_commands.jsonstill regenerates (CMake optionCMAKE_EXPORT_COMPILE_COMMANDS=ONinpyproject.toml— required by thecode-lintskill andclang-tidy -p).CMakeLists.txtunderif(AUTO_DETECT_DEVICES)and toif(AUTO_DETECT_BACKENDS)where applicable.CMakeLists.txtis not broken.clang-format.ymlis green locally.ruff.ymlis not applicable to this PR because no Python source files were changed.pyproject.toml's[project.optional-dependencies].Documentation
README.md, examples, or inline docs were updated where Hygon behavior, build flags, or developer workflow changed.Security and Safety