feat: migrate backend from per-device kernels to InfiniOps operator library#304
Draft
bitzyz wants to merge 11 commits into
Draft
feat: migrate backend from per-device kernels to InfiniOps operator library#304bitzyz wants to merge 11 commits into
bitzyz wants to merge 11 commits into
Conversation
70e886d to
15cbfab
Compare
15cbfab to
a2575d1
Compare
952e424 to
889b1ad
Compare
9ff0681 to
49a1769
Compare
49a1769 to
c11b79b
Compare
0b0c969 to
0d67dc3
Compare
0d67dc3 to
70882d2
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.
This commit replaces InfiniTensor's per-device kernel implementations with InfiniOps, a unified operator library shared across the InfiniTensor ecosystem. This is the first step in a multi-part migration.
Add InfiniOps as a git submodule at 3rd-party/infiniops, version-pinned via .gitmodules. The submodule provides kernel implementations for CPU, CUDA, and other accelerators through a single libinfiniops.so.
Introduce the InfiniOps bridge layer (include/core/infiniops_bridge/):
Implement 6 InfiniOps adapter kernels (src/kernels/infiniops/): Add, Mul, MatMul (with bias fusion via Gemm beta=1), Cast, Concat, and RMSNorm. Each adapter converts InfiniTensor tensors to InfiniOps tensors and calls the corresponding infini::ops::*::Call().
Remove legacy per-device kernel implementations for CUDA, BANG, Kunlun, Ascend, and IntelCPU backends (~24,700 lines deleted). This includes all kernel source files, runtime classes, operator timers, and device-specific headers. The remaining CPU kernels (src/kernels/cpu/) serve as fallback for operators not yet covered by InfiniOps adapters.
Simplify the build system: remove USE_CUDA, USE_BANG, USE_KUNLUN, USE_ASCEND, USE_INTELCPU CMake options. InfiniOps device backends are now controlled through InfiniOps's own WITH_CPU/WITH_NVIDIA etc. flags. GPU support is re-enabled via -DWITH_NVIDIA=ON passed through to InfiniOps's add_subdirectory.
Update the Python FFI (src/ffi/ffi_infinitensor.cc): replace all device-specific runtime factory functions (cuda_runtime(), bang_runtime(), etc.) with a unified cpu_runtime() / cuda_runtime() that returns InfiniOpsRuntimeObj. Fix copyout_numpy to use numpy.empty() instead of py::array(dtype, shape, nullptr) to avoid NumPy 2.x stride issues.