Skip to content

[WIP] feat: add InfiniOps as optional kernel provider#167

Open
chen2021673 wants to merge 2 commits into
masterfrom
feat/infiniops-provider
Open

[WIP] feat: add InfiniOps as optional kernel provider#167
chen2021673 wants to merge 2 commits into
masterfrom
feat/infiniops-provider

Conversation

@chen2021673
Copy link
Copy Markdown
Contributor

@chen2021673 chen2021673 commented Jun 4, 2026

Summary

引入 InfiniOps 作为可选 kernel provider,通过 USE_INFINIOPS=ON 启用。

当前接入不修改 Dispatcher 语义,也不新增 InfiniOps 专用 dispatch 分支。框架侧按 device + op 调用 kernel;启用 InfiniOps 时,由 CMake 选择 InfiniOps provider 注册对应 CUDA kernel,未启用时继续注册原生 CUDA kernel。

linearmatmulouter 已在前置 GEMM PR #166 中改为通过 Dispatcher::Instance().Call<void>({device.type(), "Gemm"}, ...) 调用 GEMM,因此 InfiniOps 只需要提供 Gemm 即可透明覆盖这些上层路径。

Changes

  • 构建:新增 USE_INFINIOPS CMake 选项;启用时接入 third_party/InfiniOps,并链接 InfiniOps::infiniops
  • Provider 接入:新增 infini_train/src/core/kernel_provider/infiniops/,提供 InfiniOps kernel wrapper。
  • Adapter:新增 adapter.{h,cc},提供 ToOpsDataType / ToOpsDevice / ToOpsTensor 等类型与张量桥接。
  • Handle:CUDA backend 通过 handle factory 注入当前 stream,避免通用 adapter 直接依赖 CUDA runtime 细节。
  • InfiniOps 算子封装:新增 gemm.ccelementwise.cc,当前接入 GemmAddForward
  • 注册方式:InfiniOps wrapper 复用现有 REGISTER_KERNEL(device, kernel_name, kernel_func),直接注册为 CUDA kernel。
  • Native registry 拆分(临时!!待全面接入后整体控制):将可被替换的原生 CUDA 注册拆到独立 TU:
    • gemm_registry.cu
    • elementwise_add_registry.cu
  • CMake 选择实现USE_INFINIOPS=ON 时不编译上述 native registry TU,由 InfiniOps provider 注册 Gemm / AddForwardUSE_INFINIOPS=OFF 时维持原生 CUDA 注册。
  • 测试配置scripts/test_config.json 默认构建命令增加 -DUSE_INFINIOPS=ON

测试

待补充截图

closed #161
issue InfiniTensor/InfiniOps#627

Add USE_INFINIOPS CMake option wiring the third_party/InfiniOps
subproject as an optional kernel backend (requires USE_CUDA). Provide
the InfiniOps adapter, CUDA handle factory, and Add/Gemm kernel
implementations registered via REGISTER_KERNEL.

Split the CUDA Add/Gemm registrations into dedicated registry sources
so they can be excluded when InfiniOps supplies those kernels instead.
Enable USE_INFINIOPS in the test build config.
@chen2021673 chen2021673 force-pushed the feat/infiniops-provider branch from 347095a to 8a74bd6 Compare June 4, 2026 03:29
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