Skip to content

fix(hygon): resolve CUDA runtime overloads in device compilation - #53

Open
baominghelly wants to merge 1 commit into
masterfrom
fix/hygon-cuda-overloads
Open

baominghelly wants to merge 1 commit into
masterfrom
fix/hygon-cuda-overloads

Conversation

@baominghelly

Copy link
Copy Markdown
Contributor

Summary

  • Replace the four ambiguous Hygon CUDA function aliases (GetDevice, GetDeviceCount, DeviceSynchronize, and MemcpyAsync) with forwarding lambdas, matching the existing wrappers in src/native/cuda/hygon/runtime_.h.
  • Compile and run the existing Hygon native runtime suite through an additional .cu translation unit, retaining the ordinary C++ test.

Motivation

In the DTK 25.04.1 CI image, InfiniRT builds successfully as C++, but downstream InfiniOps device compilation fails when it includes the installed Hygon runtime header:

variable 'GetDevice' with type 'const auto' has incompatible initializer of type '<overloaded function type>'

The same diagnostic occurs for all four aliases. Calling the CUDA APIs inside forwarding wrappers allows overload resolution at the call site instead of trying to deduce a function pointer from an overload set.

The baseline failure was reproduced with a minimal CUDA translation unit before validating the fix. Original downstream failure.

Type of Change

  • feat - new feature / new backend capability / new public API
  • fix - bug fix
  • perf - performance improvement without behavior change
  • refactor - code restructuring without behavior change
  • test - adding or fixing tests only
  • docs - documentation only
  • build / ci - build system or CI configuration
  • chore - tooling, formatting, or other non-code changes
  • Breaking change

Platforms Affected

  • CPU (WITH_CPU)
  • NVIDIA (WITH_NVIDIA)
  • Iluvatar (WITH_ILUVATAR)
  • Hygon (WITH_HYGON)
  • MetaX (WITH_METAX)
  • Moore (WITH_MOORE)
  • Cambricon (WITH_CAMBRICON)
  • Ascend (WITH_ASCEND)
  • Build system / CMake / generated headers
  • Public headers / installed consumer API
  • Documentation only

The CMake addition is restricted to WITH_HYGON. Generated and installed Hygon detail headers inherit the source change; the header generator itself is unchanged.

Smoke Build and Test Result

Validated commit: 46d411ef37f7c8a5d599ceca78547eac0bcbbfd4.

Environment: BW200 / gfx936, image image.sourcefind.cn:5000/dcu/admin/base/pytorch:2.4.1-ubuntu22.04-dtk25.04.1-py3.10, DTK CUDA facade 12.6.77. The temporary container selected its existing CUDA 12 toolkit and exported CUDA_PATH, CUDA_HOME, PATH, and its runtime library directory in LD_LIBRARY_PATH. One idle GPU was selected automatically and held with the existing host GPU lease; the container verified that exactly one device was visible.

cmake -S /task/infinirt-fixed -B /task/fixed-build \
  -DWITH_CPU=ON -DWITH_HYGON=ON -DINFINI_RT_BUILD_TESTING=ON \
  -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/task/infinirt-prefix
cmake --build /task/fixed-build -j 8
ctest --test-dir /task/fixed-build --output-on-failure
cmake --install /task/fixed-build
nvcc -std=c++17 -arch=gfx936 -I/task/infinirt-prefix/include \
  -c /task/header-consumer.cu -o /task/fixed-header.o
100% tests passed, 0 tests failed out of 14
Includes test_hygon_runtime, test_hygon_cuda_runtime, test_hygon_graph,
test_runtime_dispatch, and test_install_consumer.
Patched installed header compiled under DTK nvcc.

Downstream InfiniOps build and smoke:

python -m pip install '.[dev]' --no-build-isolation \
  --config-settings=cmake.define.INFINI_OPS_SMOKE_BUILD=ON \
  --config-settings=cmake.define.INFINI_RT_ROOT=/task/infinirt-prefix
pytest tests/ -m smoke -n 4 -v --tb=short --junitxml=/task/test-results.xml
InfiniOps wheel built and installed successfully.
161 passed, 73 skipped, 2 warnings in 16.36s

A fresh GitHub runner acceptance run pinned this exact InfiniRT commit and independently passed build/install and the same smoke suite: 161 passed, 73 skipped, 0 failed. JUnit and GPU lease artifact.

The existing smoke suite determines the skips for unavailable implementations and platform-specific requirements. No test selection, tolerance, or idle-GPU threshold was relaxed. The two Torch warnings concern unavailable memory-efficient attention; the corresponding tests passed.

Test Results on Supported Platforms

Platform Affected Build / Smoke Result Full Result / Notes
CPU No N/A - not affected CPU tests also passed in the combined CPU+Hygon configuration.
NVIDIA No N/A - not affected Backend code and test configuration unchanged.
Iluvatar No N/A - not affected Backend code and test configuration unchanged.
Hygon Yes smoke passed Complete configured InfiniRT CTest suite: 14/14; downstream InfiniOps smoke: 161 passed, 73 skipped. Full downstream operator suite not run.
MetaX No N/A - not affected Backend code and test configuration unchanged.
Moore No N/A - not affected Backend code and test configuration unchanged.
Cambricon No N/A - not affected Backend code and test configuration unchanged.
Ascend No N/A - not affected Backend code and test configuration unchanged.

Benchmark / Performance Impact

N/A. This fixes device-compilation compatibility; no performance claim.

Notes for Reviewers

  • The additional CUDA test reuses test_native_runtime.cc and the existing Hygon test definitions so host and device compiler coverage exercise the same runtime behavior.
  • On a separate BW1100 host with DTK 26.04 / Clang 17, the unpatched baseline header compiled with that host's DTK compiler after supplying its C++ standard-library include paths. The overload failure was not reproduced there. This comparison does not isolate whether compiler or compatibility-header changes are responsible, and is not a full validation of the patched suite on DTK 26.04.
  • Clang Format and Ruff passed for the fix commit.

@baominghelly
baominghelly marked this pull request as ready for review November 5, 2026 09:27

This branch has not been deployed

No deployments
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