Skip to content

Specify hsa path relative to aiter lib*so compiled - #1811

Closed
wangye805 wants to merge 1 commit into
mainfrom
yewang12/rel_path_lib_to_hsa
Closed

wangye805 wants to merge 1 commit into
mainfrom
yewang12/rel_path_lib_to_hsa

Conversation

@wangye805

Copy link
Copy Markdown
Contributor

Motivation

MHA api refactoring brings AITER_ASM_DIR back which was removed before in #1597. This can bring back the issues in https://ontrack-internal.amd.com/browse/SWDEV-565755 for future TE + aiter mha backend

Technical Details

Add compile-time envs AITER_USE_AITER_ASM_DIR and AITER_REL_PATH_LIB_TO_HSA to search hsaco from a pre-agreed relative path from the compiled lib*.so. Therefore downstream libraries like TE/jax-aiter do not need to set AITER_ASM_DIR anymore.

AITER_USE_AITER_ASM_DIR: default value 1, which is the original flow which user still need to set the AITER_ASM_DIR env. If set to 0, the compilation goes the proposed flow
AITER_REL_PATH_LIB_TO_HSA: default value "./", which means that aiter lib*.so's (libmha_fwd/bwd.so) need to be under the same location with hsa dir

Test Plan

Testing aiter optest without specifying AITER_ASM_DIR

Test Result

Passed

Old flow not changed:

root@ctr-cx64-mi300x-13:/workspace/aiter_main/op_tests/cpp/mha# bash build_mha.sh bwd_v3
######## building mha kernel bwd_v3
aiter is not installed.
######## linking mha bwd
root@ctr-cx64-mi300x-13:/workspace/aiter_main/op_tests/cpp/mha# AITER_ASM_DIR=/workspace/aiter_main/hsa/gfx942/ LD_LIBRARY_PATH=./ ./bwd.exe -bwd_v3=1 -v=0
[fp16|batch|bhsd] b:2, h:8/8, s:3328/3328, d:128/128, scale:0.0883883, bias:n, dbias:0, p_drop:0, s_randval:0, deterministic:0, mask:n
[aiter] hipModuleLoad: /workspace/aiter_main/hsa/gfx942/fmha_v3_bwd/bwd_hd128_odo_fp16.co GetFunction: _ZN5aiter23fmha_bwd_hd128_odo_fp16E Success
[aiter] hipModuleLoad: /workspace/aiter_main/hsa/gfx942/fmha_v3_bwd/bwd_hd128_fp16_a32_psskddv.co GetFunction: _ZN5aiter31fmha_bwd_hd128_fp16_a32_psskddvE Success
[aiter] hipModuleLoad: /workspace/aiter_main/hsa/gfx942/fmha_v3_bwd/bwd_hd128_dq_convert_fp16.co GetFunction: _ZN5aiter30fmha_bwd_hd128_dq_convert_fp16E Success
, 0.541 ms, 419.34 TFlops, 202.00 GB/s

New flow works fine:

root@ctr-cx64-mi300x-13:/workspace/aiter_main/op_tests/cpp/mha# AITER_USE_AITER_ASM_DIR=0 AITER_REL_PATH_LIB_TO_HSA="../../../" bash build_mha.sh bwd_v3
######## building mha kernel bwd_v3
aiter is not installed.
######## linking mha bwd
root@ctr-cx64-mi300x-13:/workspace/aiter_main/op_tests/cpp/mha# LD_LIBRARY_PATH=./ ./bwd.exe -bwd_v3=1 -v=0
[fp16|batch|bhsd] b:2, h:8/8, s:3328/3328, d:128/128, scale:0.0883883, bias:n, dbias:0, p_drop:0, s_randval:0, deterministic:0, mask:n
[aiter] hipModuleLoad: ./../../../hsa/gfx942/fmha_v3_bwd/bwd_hd128_odo_fp16.co GetFunction: _ZN5aiter23fmha_bwd_hd128_odo_fp16E Success
[aiter] hipModuleLoad: ./../../../hsa/gfx942/fmha_v3_bwd/bwd_hd128_fp16_a32_psskddv.co GetFunction: _ZN5aiter31fmha_bwd_hd128_fp16_a32_psskddvE Success
[aiter] hipModuleLoad: ./../../../hsa/gfx942/fmha_v3_bwd/bwd_hd128_dq_convert_fp16.co GetFunction: _ZN5aiter30fmha_bwd_hd128_dq_convert_fp16E Success
, 0.534 ms, 424.71 TFlops, 204.58 GB/s

Submission Checklist

@wangye805
wangye805 requested review from a team, minmengdie, slippedJim and valarLip January 12, 2026 04:55
@wangye805
wangye805 force-pushed the yewang12/rel_path_lib_to_hsa branch from d4c8701 to 4a40109 Compare January 12, 2026 05:01
@yuguo68

yuguo68 commented Jan 17, 2026

Copy link
Copy Markdown
Contributor

ah, ye ge? great to see you here.

@yuguo68

yuguo68 commented Jan 17, 2026

Copy link
Copy Markdown
Contributor

I am updating aiter in PyTorch, and also need a way to avoid specifying env var AITER_ASM_DIR. made a proposal in #1862

@zufayu

zufayu commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Hi, thank you for your contribution!

Over the past six months, ROCm/aiter has undergone significant updates and improvements. We're closing this PR for now to keep the backlog manageable — if you're still able to reproduce the issue or the feature is still relevant, we'd love to hear from you! Please give the latest version of the repo a try and feel free to reopen this PR or submit a new one if the problem persists. Looking forward to your continued contributions!

@zufayu zufayu closed this Jun 26, 2026
@zufayu
zufayu deleted the yewang12/rel_path_lib_to_hsa branch August 11, 2026 06:47
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