[GH-ISSUE #2065] Hygon DCU (gfx936 / DTK 26.04) build works — two undocumented gaps (libhwloc-dev, pip build isolation) #1261

Closed
opened 2026-10-29 14:50:39 +00:00 by bsakaguchi · 2 comments
Owner

Originally created by @lutianshu824 on GitHub (Jun 27, 2026).
Original GitHub issue: https://github.com/kvcache-ai/ktransformers/issues/2065

Summary

kt-kernel from v0.6.3.post1 builds and imports cleanly on Hygon DCU
(arch gfx936, e.g. BW100/BW150) using Hygon's DTK 26.04 ROCm-compatible
toolkit. The existing ROCm path (KTRANSFORMERS_USE_ROCM, cpu_backend/vendors/hip.h,
the CPUInfer stream bridge) compiles against DTK with no source changes.

Sharing the validated recipe, plus two small, undocumented friction points
that bite any ROCm / vendor-torch user (not just Hygon). Happy to send a docs PR
if useful.

Environment

GPU Hygon DCU, gfx936
Toolkit DTK 26.04 (ROCm-compatible, ROCM_PATH=/opt/dtk, hipcc/dcc 25.10)
PyTorch 2.5.1 (vendor ROCm build), torch.version.hip = 6.3.x
Python 3.10
CPU AVX2 + FMA only (no AVX512 / AMX)
kt-kernel v0.6.3.post1

Result: pip builds kt_kernel-0.6.3.post1-cp310 and
python -c "import kt_kernel; print(kt_kernel.__cpu_variant__)" → avx2.

Recipe that worked

git clone --branch v0.6.3.post1 https://github.com/kvcache-ai/ktransformers.git
cd ktransformers && git submodule update --init third_party/llama.cpp third_party/pybind11

apt-get install -y libhwloc-dev            # see gap #1

export CPUINFER_CPU_INSTRUCT=AVX2
export CPUINFER_ENABLE_AMX=OFF
export CPUINFER_USE_ROCM=1                 # -> -DKTRANSFORMERS_USE_ROCM=ON
export PYTORCH_ROCM_ARCH=gfx936
export ROCM_PATH=/opt/dtk
cd kt-kernel && pip install . --no-build-isolation --no-deps   # see gap #2

Gap #1 — libhwloc-dev is a REQUIRED build dep but undocumented

cmake hard-fails for anyone without hwloc:

-- Checking for one of the modules 'hwloc'
CMake Error at .../FindPkgConfig.cmake:938 (message):
  None of the required 'hwloc' found
Call Stack (most recent call first):
  CMakeLists.txt:615 (pkg_search_module)

pkg_search_module(HWLOC REQUIRED IMPORTED_TARGET hwloc) makes hwloc mandatory,
but it's not listed in kt-kernel/install.sh deps nor in the install docs.
Suggestion: add libhwloc-dev (Debian/Ubuntu) / hwloc-devel (RHEL) to the
deps step + the AVX2/ROCm tutorials, or emit a friendlier error.

Gap #2 — default pip install . (build isolation) pulls a generic PyPI torch

On ROCm / vendor-torch setups, pip install . uses an isolated build env
and resolves a stock CPU/CUDA torch from PyPI, which shadows the vendor
(ROCm/DCU) torch already installed and yields a kernel linked against the wrong
torch. Using --no-build-isolation --no-deps so the build links the in-env
vendor torch fixes it. Worth a one-line note in the ROCm / AVX2 tutorials, since
the current ROCm doc targets AMD GPUs with the PyPI rocm6.2.4 wheel and won't
warn vendor-torch users.

Note

The current ROCm tutorial (doc/en/ROCm.md) is validated on AMD Radeon
7900xtx + ROCm 6.2.4. The above shows the same code path also works on Hygon DCU
(gfx936) via DTK with a vendor torch. A short doc/en/DCU.md (or a section in the
ROCm doc) would help other Hygon DCU users — I'm glad to open that PR.

Full recipe, a Dockerfile, and a prebuilt gfx936 wheel:
https://github.com/lutianshu824/ktransformers-dcu

Thanks for the great project!

Originally created by @lutianshu824 on GitHub (Jun 27, 2026). Original GitHub issue: https://github.com/kvcache-ai/ktransformers/issues/2065 ## Summary `kt-kernel` from **v0.6.3.post1** builds and imports cleanly on **Hygon DCU** (arch **gfx936**, e.g. BW100/BW150) using Hygon's **DTK 26.04** ROCm-compatible toolkit. The existing ROCm path (`KTRANSFORMERS_USE_ROCM`, `cpu_backend/vendors/hip.h`, the CPUInfer stream bridge) compiles against DTK with no source changes. Sharing the validated recipe, plus **two small, undocumented friction points** that bite any ROCm / vendor-torch user (not just Hygon). Happy to send a docs PR if useful. ## Environment | | | |---|---| | GPU | Hygon DCU, **gfx936** | | Toolkit | DTK 26.04 (ROCm-compatible, `ROCM_PATH=/opt/dtk`, `hipcc`/dcc 25.10) | | PyTorch | 2.5.1 (vendor ROCm build), `torch.version.hip` = 6.3.x | | Python | 3.10 | | CPU | AVX2 + FMA only (no AVX512 / AMX) | | kt-kernel | v0.6.3.post1 | Result: `pip` builds `kt_kernel-0.6.3.post1-cp310` and `python -c "import kt_kernel; print(kt_kernel.__cpu_variant__)"` → `avx2`. ## Recipe that worked ```bash git clone --branch v0.6.3.post1 https://github.com/kvcache-ai/ktransformers.git cd ktransformers && git submodule update --init third_party/llama.cpp third_party/pybind11 apt-get install -y libhwloc-dev # see gap #1 export CPUINFER_CPU_INSTRUCT=AVX2 export CPUINFER_ENABLE_AMX=OFF export CPUINFER_USE_ROCM=1 # -> -DKTRANSFORMERS_USE_ROCM=ON export PYTORCH_ROCM_ARCH=gfx936 export ROCM_PATH=/opt/dtk cd kt-kernel && pip install . --no-build-isolation --no-deps # see gap #2 ``` ## Gap #1 — `libhwloc-dev` is a REQUIRED build dep but undocumented cmake hard-fails for anyone without hwloc: ``` -- Checking for one of the modules 'hwloc' CMake Error at .../FindPkgConfig.cmake:938 (message): None of the required 'hwloc' found Call Stack (most recent call first): CMakeLists.txt:615 (pkg_search_module) ``` `pkg_search_module(HWLOC REQUIRED IMPORTED_TARGET hwloc)` makes hwloc mandatory, but it's not listed in `kt-kernel/install.sh deps` nor in the install docs. Suggestion: add `libhwloc-dev` (Debian/Ubuntu) / `hwloc-devel` (RHEL) to the `deps` step + the AVX2/ROCm tutorials, or emit a friendlier error. ## Gap #2 — default `pip install .` (build isolation) pulls a generic PyPI torch On ROCm / vendor-torch setups, `pip install .` uses an **isolated** build env and resolves a stock CPU/CUDA `torch` from PyPI, which shadows the vendor (ROCm/DCU) torch already installed and yields a kernel linked against the wrong torch. Using `--no-build-isolation --no-deps` so the build links the in-env vendor torch fixes it. Worth a one-line note in the ROCm / AVX2 tutorials, since the current ROCm doc targets AMD GPUs with the PyPI `rocm6.2.4` wheel and won't warn vendor-torch users. ## Note The current ROCm tutorial (`doc/en/ROCm.md`) is validated on AMD Radeon 7900xtx + ROCm 6.2.4. The above shows the same code path also works on Hygon DCU (gfx936) via DTK with a vendor torch. A short `doc/en/DCU.md` (or a section in the ROCm doc) would help other Hygon DCU users — I'm glad to open that PR. Full recipe, a `Dockerfile`, and a prebuilt gfx936 wheel: https://github.com/lutianshu824/ktransformers-dcu Thanks for the great project!
Author
Owner

@yyj6666667 commented on GitHub (Jun 28, 2026):

🫡
Thanks for the job, Hygon users will be glad to see that. It's my pleasure to review and merge your docs PR

<!-- gh-comment-id:4824507881 --> @yyj6666667 commented on GitHub (Jun 28, 2026): 🫡 Thanks for the job, Hygon users will be glad to see that. It's my pleasure to review and merge your docs PR
Author
Owner

@yyj6666667 commented on GitHub (Jul 6, 2026):

The tutorial (a section in the ROCm doc) has been added and merged into main along with this PR https://github.com/kvcache-ai/ktransformers/pull/2075

<!-- gh-comment-id:4891671317 --> @yyj6666667 commented on GitHub (Jul 6, 2026): The tutorial (a section in the ROCm doc) has been added and merged into main along with this PR https://github.com/kvcache-ai/ktransformers/pull/2075
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
kvcache-ai/ktransformers#1261
No description provided.