Skip to content

feat: support build on gfx1250 (Part1)#374

Open
RuibinCheung wants to merge 5 commits into
mainfrom
dev/zhangrb/gfx1250_build_support
Open

feat: support build on gfx1250 (Part1)#374
RuibinCheung wants to merge 5 commits into
mainfrom
dev/zhangrb/gfx1250_build_support

Conversation

@RuibinCheung

@RuibinCheung RuibinCheung commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR is the first part of enabling Primus-Turbo on the AMD gfx1250 (CDNA5) architecture.

It teaches the whole stack — build system, host bindings, and device kernels — to recognize gfx1250 and to cope with the two hardware differences that break the existing gfx942/gfx950 assumptions: a 32-lane wavefront (instead of 64) and the new split s_wait_* counters that replace the unified s_waitcnt.

Because the CK (ck_tile) and turbo (MFMA) GEMM backends, Triton/flydsl, and several quantization kernels are not yet available on gfx1250, this part also makes those backends optional and selectable at build time so that a gfx1250 build can be produced today while the remaining kernel support lands in follow-up PRs.

Fixes # (issue)

Type of change

  • Documentation change (change only to the documentation, either a fix or a new content)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Infra/Build change
  • Code refactoring

Changes

Please list the changes introduced in this PR:

  • Add gfx1250 architecture detection on both host and device.

    • New GPUArch::GFX1250, is_gfx1250(), and a warp_size() helper in csrc/include/primus_turbo/arch.h.
    • New is_gfx1250() in primus_turbo/pytorch/core/utils.py.
    • Add gfx1250 to SUPPORTED_GPU_ARCHS and the --offload-arch filtering pipeline in setup.py.
  • Handle the 32-lane wavefront on gfx1250.

    • Make THREADS_PER_WARP arch-aware in platform.h (64 for gfx942/gfx950, 32 otherwise) so fat-binary builds get the correct value per arch.
    • Replace fixed THREADS_PER_WARP usages with the runtime warp_size() in the reduce and normalization host launchers.
    • Skip the extra cross-32-lane-group shuffle step in warp_reduce_max_64_dpp when the wavefront is already 32 lanes.
  • Support the gfx12 split wait counters.

    • Use s_wait_dscnt / s_wait_loadcnt instead of s_waitcnt lgkmcnt/vmcnt on gfx1250 in device/memory.cuh and device/reduce.cuh.
  • Clarify FP8 encoding selection by architecture.

    • Rework float8.h so gfx942 uses FNUZ and all other archs (gfx950, gfx1250) use OCP, instead of special-casing only gfx950.
  • Make the CK and turbo GEMM backends optional and build-time selectable.

    • New PRIMUS_TURBO_BUILD_BACKEND env var (comma/semicolon separated, e.g. ck,turbo) parsed by enabled_backends() / build_ck_backend() / build_turbo_backend() in tools/build_utils.py; unset builds all backends, empty string builds none.
    • Define -DBUILD_CK_BACKEND / -DBUILD_TURBO_BACKEND only for enabled backends, guard the CK/turbo declarations and host bindings behind them, and fall back to loud runtime-error stubs when a backend is disabled.
    • Exclude CK/turbo kernel sources from the build when the corresponding backend is disabled.
    • Record enabled backends in the generated primus_turbo/_build_info.py, and expose build_ck() / build_turbo() in core/utils.py so kernel dispatchers only select a backend that was actually compiled in.
  • Add a standalone, CK-free compute_group_offs kernel (csrc/kernels/grouped_gemm/compute_group_offs.cu) that is always built so the symbol is available to both CK and non-CK host bindings.

  • Guard unsupported paths on gfx1250.

    • Raise a build error if the JAX, CK, or turbo backends are requested for gfx1250.
    • Skip installing triton==3.7.0 and flydsl>=0.2.0 when building for gfx1250.
    • Raise runtime errors from the MXFP8 quantization kernels on gfx1250 (kernel support pending).
    • Skip the whole test suite and the mega_moe_fused test module on gfx1250.
  • Improve the build tooling.

    • Rewrite find_rocm_home() to honor ROCM_HOME / ROCM_PATH and support TheRock rocm-sdk-core, and derive HIP_HOME from it.
    • Verify ninja availability before building extensions and remove dead debug code in tools/build_ext.py.
    • Preserve a previously recorded git commit in _build_info.py when git is unavailable.

Checklist:

  • The functionality is complete
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Copilot AI review requested due to automatic review settings June 9, 2026 11:13

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

安全审查完成:未发现本 PR 引入或暴露的 medium/high/critical 漏洞。

检查范围包括新增/修改的 gfx1250 build 支持、可选 GEMM backend 选择、ROCM 路径探测、pybind stub、grouped_gemm_compute_offs 独立实现,以及相关 GPU kernel/inline asm 变更。未发现攻击者可控输入到注入、权限绕过、SSRF/XSS/路径穿越、不安全反序列化、秘密泄露或新增供应链 sink 的可利用路径。

既有自动化安全审查线程:未发现需要复核的未解决线程。

Open in Web View Automation 

Sent by Cursor Automation: Find vulnerabilities

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds build support for the gfx1250 (CDNA5) architecture by making optional GEMM backends selectable at build time and porting device-side waitcnt usage to gfx12’s split wait counters, while consolidating grouped-GEMM helper code so it remains available even when CK/turbo backends are disabled.

Changes:

  • Adds gfx1250 to supported arch list and introduces PRIMUS_TURBO_BUILD_BACKEND to selectively build CK and/or turbo GEMM backends (with guarded headers and stubbed host bindings when disabled).
  • Ports device inline-asm wait logic for gfx12 using split counters and shared macros.
  • Consolidates compute_group_offs into an always-built, backend-agnostic kernel and moves the PyTorch host binding to an always-built utility TU.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
tools/build_utils.py Improves ROCm discovery and adds backend-selection helpers; introduces _join_rocm_home.
tools/build_ext.py Reuses _join_rocm_home from build utils.
setup.py Adds gfx1250 arch, filters sources based on selected backends, and defines backend guard macros in compile flags.
csrc/pytorch/type_traits.h Guards CK-only type mapping behind PRIMUS_TURBO_BUILD_CK_BACKEND.
csrc/pytorch/grouped_gemm/utils/grouped_gemm_utils.cpp New always-built PyTorch grouped-GEMM utility binding for offset computation.
csrc/pytorch/grouped_gemm/ck_grouped_gemm.cpp CK implementation now guarded; adds CK-disabled stubs.
csrc/pytorch/gemm/turbo_gemm.cpp Adds turbo-disabled stub guarded by PRIMUS_TURBO_BUILD_TURBO_BACKEND.
csrc/pytorch/gemm/ck_gemm.cpp Adds CK-disabled stub guarded by PRIMUS_TURBO_BUILD_CK_BACKEND.
csrc/kernels/grouped_gemm/compute_group_offs.cu New standalone always-built device implementation of compute_group_offs.
csrc/kernels/grouped_gemm/ck_grouped_gemm.cu Removes duplicated compute_group_offs implementation/instantiation.
csrc/kernels/deep_ep/utils.cuh Introduces gfx12 split-counter wait macro and uses it in fences.
csrc/include/primus_turbo/grouped_gemm.h Guards CK-only includes/types/APIs behind PRIMUS_TURBO_BUILD_CK_BACKEND.
csrc/include/primus_turbo/gemm.h Guards CK/turbo-only declarations behind backend macros.
csrc/include/primus_turbo/device/reduce.cuh Uses a gfx12 LDS-wait macro for ds swizzles/reductions.
csrc/include/primus_turbo/device/memory.cuh Switches wait helpers to gfx12 split counters for gfx1250.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tools/build_utils.py Outdated
Comment on lines +110 to +111
if rocm_home and torch.version.hip is None:
logger.warning("No ROCm runtime is found, using ROCM_HOME='%s'", rocm_home)
Comment thread tools/build_utils.py
Comment on lines +115 to 120
def _join_rocm_home(*paths) -> str:
return os.path.join(find_rocm_home(), *paths)


HIP_HOME: Path = find_hip_home()
HIP_HOME: Path = _join_rocm_home("hip")
HIP_LIBRARY_PATH = os.path.join(HIP_HOME, "lib")
Comment thread setup.py
Comment on lines +40 to +46
# csrc/kernels path fragments that depend on CK, skipped when the CK backend is disabled.
CK_DISABLED_SOURCE_MARKERS = (
"/gemm/ck/",
"/gemm/ck_gemm.cu",
"/grouped_gemm/ck/",
"/grouped_gemm/ck_grouped_gemm.cu",
)
Comment on lines +13 to +20
// gfx12 (gfx1250 / gfx1251, CDNA5) removed the unified `s_waitcnt`; the combined
// LDS + VMEM wait is expressed via the split counters.
#if defined(__gfx1250__)
#define PRIMUS_TURBO_WAIT_ALL_STR \
"s_wait_dscnt 0\n\ts_wait_kmcnt 0\n\ts_wait_loadcnt 0\n\ts_wait_storecnt 0"
#else
#define PRIMUS_TURBO_WAIT_ALL_STR "s_waitcnt lgkmcnt(0) vmcnt(0)"
#endif
Comment on lines +10 to +16
// gfx12 (gfx1250 / gfx1251, CDNA5) removed the unified `s_waitcnt`; LDS waits use
// the split `s_wait_dscnt` counter instead.
#if defined(__gfx1250__)
#define PRIMUS_TURBO_WAIT_DS_STR "s_wait_dscnt 0"
#else
#define PRIMUS_TURBO_WAIT_DS_STR "s_waitcnt lgkmcnt(0)"
#endif
Comment thread csrc/pytorch/gemm/turbo_gemm.cpp Outdated
Comment on lines +88 to +93
at::Tensor turbo_gemm_fp8(at::Tensor A, at::Tensor scaleA_inv, at::Tensor B, at::Tensor scaleB_inv,
const at::ScalarType out_dtype, bool transA, bool transB, bool transC,
const std::string &granularity) {
PRIMUS_TURBO_ERROR("turbo_gemm_fp8 is unavailable: turbo backend not built. "
"Rebuild with PRIMUS_TURBO_BUILD_BACKEND including 'turbo'.");
}
Comment on lines +310 to +315
at::Tensor ck_grouped_gemm(at::Tensor &a, at::Tensor &b, at::Tensor &group_lens,
at::Tensor &group_offs, const bool transA, const bool transB,
c10::optional<int64_t> num_cu) {
PRIMUS_TURBO_ERROR("ck_grouped_gemm is unavailable: CK backend not built. "
"Rebuild with PRIMUS_TURBO_BUILD_BACKEND including 'ck'.");
}
Comment on lines +317 to +322
at::Tensor ck_grouped_gemm_variable_k(at::Tensor &a, at::Tensor &b, at::Tensor &group_lens,
at::Tensor &group_offs, const bool transA, const bool transB,
c10::optional<int64_t> num_cu) {
PRIMUS_TURBO_ERROR("ck_grouped_gemm_variable_k is unavailable: CK backend not built. "
"Rebuild with PRIMUS_TURBO_BUILD_BACKEND including 'ck'.");
}
Comment on lines +324 to +330
at::Tensor ck_grouped_gemm_fp8(at::Tensor &a, at::Tensor &b, at::Tensor &a_scales,
at::Tensor &b_scales, at::Tensor &group_lens, at::Tensor &group_offs,
const bool transA, const bool transB, at::ScalarType out_dtype,
const std::string &granularity, c10::optional<int64_t> num_cu) {
PRIMUS_TURBO_ERROR("ck_grouped_gemm_fp8 is unavailable: CK backend not built. "
"Rebuild with PRIMUS_TURBO_BUILD_BACKEND including 'ck'.");
}
Comment on lines +332 to +340
at::Tensor ck_grouped_gemm_fp8_variable_k(at::Tensor &a, at::Tensor &b, at::Tensor &a_scales,
at::Tensor &b_scales, at::Tensor &group_lens,
at::Tensor &group_offs, const bool transA,
const bool transB, at::ScalarType out_dtype,
const std::string &granularity,
c10::optional<int64_t> num_cu) {
PRIMUS_TURBO_ERROR("ck_grouped_gemm_fp8_variable_k is unavailable: CK backend not built. "
"Rebuild with PRIMUS_TURBO_BUILD_BACKEND including 'ck'.");
}
Copilot AI review requested due to automatic review settings June 12, 2026 05:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 12 comments.

Comment thread tools/build_utils.py
Comment on lines +131 to +132
def _join_rocm_home(*paths) -> str:
return os.path.join(find_rocm_home(), *paths)
Comment thread tools/build_utils.py Outdated
Comment on lines +125 to +127
if rocm_home is None:
logger.warning("No ROCm runtime is found, using ROCM_HOME='%s'", rocm_home)

Comment on lines +104 to +109
at::Tensor ck_gemm_fp8(at::Tensor &a, at::Tensor &b, at::Tensor &a_scales, at::Tensor &b_scales,
const bool transA, const bool transB, at::ScalarType out_dtype,
const std::string &granularity) {
PRIMUS_TURBO_ERROR("ck_gemm_fp8 is unavailable: CK backend not built. "
"Rebuild with PRIMUS_TURBO_BUILD_BACKEND including 'ck'.");
}
Comment thread csrc/pytorch/gemm/turbo_gemm.cpp Outdated
Comment on lines +88 to +93
at::Tensor turbo_gemm_fp8(at::Tensor A, at::Tensor scaleA_inv, at::Tensor B, at::Tensor scaleB_inv,
const at::ScalarType out_dtype, bool transA, bool transB, bool transC,
const std::string &granularity) {
PRIMUS_TURBO_ERROR("turbo_gemm_fp8 is unavailable: turbo backend not built. "
"Rebuild with PRIMUS_TURBO_BUILD_BACKEND including 'turbo'.");
}
Comment on lines +316 to +321
at::Tensor ck_grouped_gemm(at::Tensor &a, at::Tensor &b, at::Tensor &group_lens,
at::Tensor &group_offs, const bool transA, const bool transB,
c10::optional<int64_t> num_cu) {
PRIMUS_TURBO_ERROR("ck_grouped_gemm is unavailable: CK backend not built. "
"Rebuild with PRIMUS_TURBO_BUILD_BACKEND including 'ck'.");
}
Comment on lines +338 to +346
at::Tensor ck_grouped_gemm_fp8_variable_k(at::Tensor &a, at::Tensor &b, at::Tensor &a_scales,
at::Tensor &b_scales, at::Tensor &group_lens,
at::Tensor &group_offs, const bool transA,
const bool transB, at::ScalarType out_dtype,
const std::string &granularity,
c10::optional<int64_t> num_cu) {
PRIMUS_TURBO_ERROR("ck_grouped_gemm_fp8_variable_k is unavailable: CK backend not built. "
"Rebuild with PRIMUS_TURBO_BUILD_BACKEND including 'ck'.");
}
Comment on lines +13 to +17
// gfx12 (gfx1250 / gfx1251, CDNA5) removed the unified `s_waitcnt`; the combined
// LDS + VMEM wait is expressed via the split counters.
#if defined(__gfx1250__)
#define PRIMUS_TURBO_WAIT_ALL_STR \
"s_wait_dscnt 0\n\ts_wait_kmcnt 0\n\ts_wait_loadcnt 0\n\ts_wait_storecnt 0"
Comment on lines +10 to +13
// gfx12 (gfx1250 / gfx1251, CDNA5) removed the unified `s_waitcnt`; LDS waits use
// the split `s_wait_dscnt` counter instead.
#if defined(__gfx1250__)
#define PRIMUS_TURBO_WAIT_DS_STR "s_wait_dscnt 0"
Comment on lines 18 to 24
template <int CNT> __device__ __forceinline__ void wait_lgkmcnt() {
#if defined(__gfx1250__)
asm volatile("s_wait_dscnt %0" : : "n"(CNT) : "memory");
#else
asm volatile("s_waitcnt lgkmcnt(%0)" : : "n"(CNT) : "memory");
#endif
}
Comment on lines 26 to 32
template <int CNT> __device__ __forceinline__ void wait_vmcnt() {
#if defined(__gfx1250__)
asm volatile("s_wait_loadcnt %0" : : "n"(CNT) : "memory");
#else
asm volatile("s_waitcnt vmcnt(%0)" : : "n"(CNT) : "memory");
#endif
}
@RuibinCheung RuibinCheung changed the title feat: support build on gfx1250 [WIP] feat: support build on gfx1250 Jun 15, 2026
@RuibinCheung
RuibinCheung marked this pull request as draft June 15, 2026 02:41
@RuibinCheung
RuibinCheung force-pushed the dev/zhangrb/gfx1250_build_support branch from a7a196c to 7d2cf3b Compare July 15, 2026 08:55
@RuibinCheung
RuibinCheung force-pushed the dev/zhangrb/gfx1250_build_support branch from 7d2cf3b to 7cb6cf5 Compare July 15, 2026 10:25
@RuibinCheung
RuibinCheung marked this pull request as ready for review July 15, 2026 10:39
Copilot AI review requested due to automatic review settings July 15, 2026 10:39
@RuibinCheung RuibinCheung reopened this Jul 15, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 33 out of 33 changed files in this pull request and generated 5 comments.

Comment thread tools/build_utils.py Outdated
Comment on lines +159 to +160
if rocm_home and torch.version.hip is None:
logger.warning("No ROCm runtime is found, using ROCM_HOME='%s'", rocm_home)
Comment thread tools/build_utils.py
Comment on lines +164 to +168
def _join_rocm_home(*paths) -> str:
return os.path.join(find_rocm_home(), *paths)


HIP_HOME: Path = find_hip_home()
HIP_HOME: Path = _join_rocm_home("hip")
Comment on lines +36 to +41
const int threads_per_block = 256;
const int blocks = static_cast<int>((group_num + threads_per_block - 1) / threads_per_block);

compute_group_offs_device<IndexType><<<blocks, threads_per_block, 0, stream>>>(
group_lens_ptr, group_offs_ptr, static_cast<int>(group_num));
}
Comment on lines +25 to +29
IndexType cumsum = 0;
for (int i = 0; i < idx; i++) {
cumsum += group_lens_ptr[i];
}
group_offs_ptr[idx + 1] = cumsum + group_lens_ptr[idx];
Comment on lines 60 to +62
PRIMUS_TURBO_CHECK(
is_gfx950(),
"The HIPBLASLT_MATMUL_MATRIX_SCALE_VEC32_UE8M0 only support on gfx950.");
!is_gfx942(),
"The HIPBLASLT_MATMUL_MATRIX_SCALE_VEC32_UE8M0 not support on gfx942.");
@RuibinCheung RuibinCheung changed the title [WIP] feat: support build on gfx1250 feat: support build on gfx1250 Jul 16, 2026
Copilot AI review requested due to automatic review settings July 16, 2026 01:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 33 out of 33 changed files in this pull request and generated 6 comments.

Comment thread setup.py
Comment thread tools/build_utils.py
Comment on lines +159 to +160
if rocm_home:
logger.warning("No ROCm runtime is found, using ROCM_HOME='%s'", rocm_home)
Comment thread tools/build_utils.py
Comment on lines +164 to +168
def _join_rocm_home(*paths) -> str:
return os.path.join(find_rocm_home(), *paths)


HIP_HOME: Path = find_hip_home()
HIP_HOME: Path = _join_rocm_home("hip")
Comment thread tests/conftest.py
Comment on lines +52 to +59
# TODO(ruibin): gfx1250 is not yet fully supported by the Primus-Turbo.
from primus_turbo.pytorch.core.utils import is_gfx1250

if is_gfx1250():
skip_gfx1250 = pytest.mark.skip(reason="Not yet supported on gfx1250")
for item in items:
item.add_marker(skip_gfx1250)
return
Comment on lines +31 to +34
# mega_moe_fused (the flydsl mega path) is not supported on gfx1250. Skip the whole
# module before importing the flydsl-backed modules below
if is_gfx1250():
pytest.skip("mega_moe_fused is not supported on gfx1250", allow_module_level=True)
Comment on lines +14 to +31
template <typename IndexType>
__global__ void compute_group_offs_device(const IndexType *group_lens_ptr,
IndexType *group_offs_ptr, const int group_num) {
const int64_t idx = blockIdx.x * blockDim.x + threadIdx.x;

if (idx == 0) {
group_offs_ptr[0] = 0;
}

if (idx < group_num) {
// Exclusive-prefix-sum to produce group offsets.
IndexType cumsum = 0;
for (int i = 0; i < idx; i++) {
cumsum += group_lens_ptr[i];
}
group_offs_ptr[idx + 1] = cumsum + group_lens_ptr[idx];
}
}
Copilot AI review requested due to automatic review settings July 16, 2026 06:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 33 out of 33 changed files in this pull request and generated 5 comments.

Comment thread tools/build_utils.py
Comment on lines +159 to 161
if rocm_home:
logger.warning("No ROCm runtime is found, using ROCM_HOME='%s'", rocm_home)
return rocm_home
Comment thread tools/build_utils.py
Comment on lines +164 to +165
def _join_rocm_home(*paths) -> str:
return os.path.join(find_rocm_home(), *paths)
Comment thread tests/conftest.py
Comment on lines +52 to +59
# TODO(ruibin): gfx1250 is not yet fully supported by the Primus-Turbo.
from primus_turbo.pytorch.core.utils import is_gfx1250

if is_gfx1250():
skip_gfx1250 = pytest.mark.skip(reason="Not yet supported on gfx1250")
for item in items:
item.add_marker(skip_gfx1250)
return
Comment on lines +33 to +41
template <typename IndexType>
void compute_group_offs(const IndexType *group_lens_ptr, IndexType *group_offs_ptr,
const int64_t group_num, hipStream_t stream) {
const int threads_per_block = 256;
const int blocks = static_cast<int>((group_num + threads_per_block - 1) / threads_per_block);

compute_group_offs_device<IndexType><<<blocks, threads_per_block, 0, stream>>>(
group_lens_ptr, group_offs_ptr, static_cast<int>(group_num));
}
Comment on lines +24 to +28
// Exclusive-prefix-sum to produce group offsets.
IndexType cumsum = 0;
for (int i = 0; i < idx; i++) {
cumsum += group_lens_ptr[i];
}
@RuibinCheung RuibinCheung changed the title feat: support build on gfx1250 feat: support build on gfx1250 (Part1) Jul 16, 2026
Copilot AI review requested due to automatic review settings July 16, 2026 09:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 34 out of 34 changed files in this pull request and generated 6 comments.

Comment thread tools/build_utils.py
Comment on lines +164 to +165
def _join_rocm_home(*paths) -> str:
return os.path.join(find_rocm_home(), *paths)
Comment thread tools/build_utils.py
Comment on lines +159 to +160
if rocm_home:
logger.warning("No ROCm runtime is found, using ROCM_HOME='%s'", rocm_home)
Comment thread setup.py Outdated
Comment on lines +233 to +238
# TODO(ruibin): add CK and turbo support for gfx1250
if "gfx1250" in arch_list:
if build_ck_backend() or build_turbo_backend():
raise ValueError(
"The CK or turbo backend is not supported on gfx1250. Please set PRIMUS_TURBO_BUILD_BACKEND='' to disable build the CK and turbo backends."
)
Comment on lines +14 to +31
template <typename IndexType>
__global__ void compute_group_offs_device(const IndexType *group_lens_ptr,
IndexType *group_offs_ptr, const int group_num) {
const int64_t idx = blockIdx.x * blockDim.x + threadIdx.x;

if (idx == 0) {
group_offs_ptr[0] = 0;
}

if (idx < group_num) {
// Exclusive-prefix-sum to produce group offsets.
IndexType cumsum = 0;
for (int i = 0; i < idx; i++) {
cumsum += group_lens_ptr[i];
}
group_offs_ptr[idx + 1] = cumsum + group_lens_ptr[idx];
}
}
Comment on lines +33 to +41
template <typename IndexType>
void compute_group_offs(const IndexType *group_lens_ptr, IndexType *group_offs_ptr,
const int64_t group_num, hipStream_t stream) {
const int threads_per_block = 256;
const int blocks = static_cast<int>((group_num + threads_per_block - 1) / threads_per_block);

compute_group_offs_device<IndexType><<<blocks, threads_per_block, 0, stream>>>(
group_lens_ptr, group_offs_ptr, static_cast<int>(group_num));
}
Comment on lines 59 to 63
if (scale_mode == HIPBLASLT_MATMUL_MATRIX_SCALE_VEC32_UE8M0) {
PRIMUS_TURBO_CHECK(
is_gfx950(),
"The HIPBLASLT_MATMUL_MATRIX_SCALE_VEC32_UE8M0 only support on gfx950.");
!is_gfx942(),
"The HIPBLASLT_MATMUL_MATRIX_SCALE_VEC32_UE8M0 not support on gfx942.");
}
kyle-256
kyle-256 previously approved these changes Jul 17, 2026

@kyle-256 kyle-256 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zhenhuang12
zhenhuang12 self-requested a review July 17, 2026 05:28
zhenhuang12
zhenhuang12 previously approved these changes Jul 17, 2026

@zhenhuang12 zhenhuang12 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copilot AI review requested due to automatic review settings July 17, 2026 08:51
@RuibinCheung
RuibinCheung dismissed stale reviews from zhenhuang12 and kyle-256 via a06a940 July 17, 2026 08:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 35 out of 35 changed files in this pull request and generated 5 comments.

Comment thread tools/build_utils.py
Comment on lines +159 to 161
if rocm_home:
logger.warning("No ROCm runtime is found, using ROCM_HOME='%s'", rocm_home)
return rocm_home
Comment thread tools/build_utils.py
Comment on lines +164 to +165
def _join_rocm_home(*paths) -> str:
return os.path.join(find_rocm_home(), *paths)
Comment on lines +40 to +46
// Device pass: rely on the per-arch predefined macros so fat-binary builds
// (multiple --offload-arch) still get the correct value for each arch.
#if defined(__gfx942__) || defined(__gfx950__)
constexpr int THREADS_PER_WARP = 64;
#else
constexpr int THREADS_PER_WARP = 32;
#endif
Comment on lines +23 to +27
if (idx < group_num) {
// Exclusive-prefix-sum to produce group offsets.
IndexType cumsum = 0;
for (int i = 0; i < idx; i++) {
cumsum += group_lens_ptr[i];
Comment on lines 60 to +62
PRIMUS_TURBO_CHECK(
is_gfx950(),
"The HIPBLASLT_MATMUL_MATRIX_SCALE_VEC32_UE8M0 only support on gfx950.");
!is_gfx942(),
"The HIPBLASLT_MATMUL_MATRIX_SCALE_VEC32_UE8M0 not support on gfx942.");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants