Skip to content

feat(hygon): expose driver modules and device attributes - #52

Merged
gongchensu merged 2 commits into
InfiniTensor:masterfrom
Ringssss:feat/hygon-driver-modules
Nov 26, 2026
Merged

gongchensu merged 2 commits into
InfiniTensor:masterfrom
Ringssss:feat/hygon-driver-modules

Conversation

@Ringssss

Copy link
Copy Markdown
Contributor

Summary

  • Expose Hygon driver module loading, function lookup, launch, unload, and function attributes through the installed InfiniRT API.
  • Add the device attributes used by native JIT launchers and generate infini/rt/hygon/driver_.h.

Motivation

InfiniOps can launch compiled Triton kernels from C++, but its Hygon implementation lacked the public driver interface. This supplies the interface needed by the Clover DCU integration without changing existing runtime operations.

Type of Change

  • feat - new backend capability / public API

Platforms Affected

  • Hygon (WITH_HYGON)
  • Build system / CMake / generated headers
  • Public headers / installed consumer API

Smoke Build and Test Result

Validated on Hygon BW / gfx936 with DTK 26.04, GCC 11.4, and CMake/Ninja:

cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_INSTALL_PREFIX="$INFINI_ROOT" -DWITH_CPU=ON -DWITH_HYGON=ON \
  -DAUTO_DETECT_DEVICES=OFF -DINFINI_RT_BUILD_TESTING=ON
cmake --build build -j 12
cmake --install build
export LD_LIBRARY_PATH="/opt/dtk/cuda/cuda/lib64:$LD_LIBRARY_PATH"
ctest --test-dir build --output-on-failure
100% tests passed, 0 tests failed out of 13
Total Test time (real) = 2.18 sec

An installed-header consumer and real InfiniOps Hygon Triton Add, convolution, GDN and MoE launches also passed. The initial consumer run lacked the DTK CUDA compatibility library path; adding that runtime path resolved it.

Test Results on Supported Platforms

Platform Affected Build / Smoke Result Full Result / Notes
CPU Shared header generation Passed Included in the 13-test run
Hygon Yes Passed Runtime, graph, installed consumer, and actual JIT launches
NVIDIA / Iluvatar / MetaX / Moore / Cambricon / Ascend No backend implementation changes N/A Hardware unavailable; their header mappings are unchanged

Benchmark / Performance Impact

N/A: this exposes driver functionality; no standalone speedup is claimed.

Notes for Reviewers

The implementation uses DTK's CUDA driver compatibility API, consistent with the existing Hygon runtime. Tested compiler targets use 64-thread waves. InfiniOps must query the actual HIP compiler target rather than interpreting CUDA compute capability as a gfx architecture.

@gongchensu

Copy link
Copy Markdown
Contributor

现有 test_install_consumer 会调用 runtime,但没有引用 Driver::ModuleLoadData 等新符号。Hygon 的 CMake target 目前只显式导出 CUDA::cudart。建议让一个只链接 InfiniRT::infinirt 的独立可执行文件实际引用新增函数。这样即使没有加速卡,也能在链接阶段发现依赖缺失。

Ringssss and others added 2 commits November 25, 2026 15:50
The public Hygon driver header exposes cuModuleLoadData, cuLaunchKernel
and the other driver entry points, which live in the CUDA driver library
rather than in cudart. The library itself never calls them, so nothing
linked it and the exported target carried only CUDA::cudart: a consumer
referencing the header had to find the driver library on its own.

FindCUDAToolkit does not provide CUDA::cuda for this DTK layout, so the
driver library is located next to the toolkit and carried through
InfiniRT::BackendRuntime, which the package config re-finds on the
consumer's machine - the same route the vendor SDK drivers take. The
install consumer now references every entry point of the driver
interface, so a missing dependency fails its link on any machine, with
or without a device.

Addresses the review comment on InfiniTensor#52.
@humannumber196
humannumber196 force-pushed the feat/hygon-driver-modules branch from 7815bd2 to 62f2195 Compare November 25, 2026 08:41
@humannumber196

humannumber196 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

现有 test_install_consumer 会调用 runtime,但没有引用 Driver::ModuleLoadData 等新符号。Hygon 的 CMake target 目前只显式导出 CUDA::cudart。建议让一个只链接 InfiniRT::infinirt 的独立可执行文件实际引用新增函数。这样即使没有加速卡,也能在链接阶段发现依赖缺失。

感谢!已按建议修复(62f2195):

install consumer 现在引用 Driver 接口的全部 7 个入口点(ModuleLoad/GetFunction/Unload、FuncGetAttribute/SetCacheConfig/SetAttribute、LaunchKernel)。volatile 指针存储防止编译器把地址折叠掉。双向验证过:不加导出修复时这个测试链接立即失败,加上后通过——纯链接期检查,无卡机器同样生效。
驱动库经 InfiniRT::BackendRuntime 可移植导出:构建侧在 toolkit 旁 find_library(没用 CUDA::cuda_driver 是因为这类条件目标在国产兼容栈上不可靠——上游 InfiniOps 的 CoreX 注释就是现成反例),配置文件在消费者机器上重新定位,与 Moore 导出 musart 驱动库的既有路径一致。

@gongchensu
gongchensu merged commit 05865f0 into InfiniTensor:master Nov 26, 2026
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.

3 participants