Repository navigation
Conversation
The AOT build of the gfx950 A16W16 GEMM (aiter.aot.flydsl.gemm) passes an int32 split-K semaphore, but the runtime allocates it as int64 since #6494. FlyDSL puts the tensor dtype into the cache key, so no AOT entry matches a runtime call, and every tuned FlyDSL hgemm configuration compiles again on first use. Allocate both split-K buffers in one function that the runtime and the AOT build share. The new test builds one tuned split-K row with the AOT driver and runs it in FlyDSL run-only mode, which raises instead of compiling on a miss. op_tests/test_graph_alloc.py now passes the split_k argument that #6494 added to get_split_k_buffers. Signed-off-by: Rony Leppänen <[email protected]> Co-authored-by: Claude <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
Motivation
The AOT build of the gfx950 A16W16 GEMM (
python -m aiter.aot.flydsl.gemm, whichsetup.pyalso runs during a prebuild) compiles every tunedflydsl_hgemm_*row into the FlyDSL cache, but the runtime never finds these entries. Since #6494 the runtime allocates the split-K semaphore as int64 (get_split_k_buffers), while_compile_hgemm_to_cachestill passes an int32 tensor. FlyDSL's cache key holds each tensor argument's dtype and alignment, so the two keys differ in thesemaphoreentry only (keys computed in the image listed under Tests, for one configuration, once with each semaphore dtype):As a result, each tuned FlyDSL hgemm configuration compiles again the first time a process uses it, even with a complete AOT cache. In a serving process this happens inside the first requests that reach the configuration.
Changes
aiter/ops/flydsl/kernels/gemm_a16w16_gfx950.py:make_split_k_buffers(device)allocates the split-K semaphore (int64) and signal (int32).get_split_k_bufferscalls it underpersistent_alloc, as before.aiter/aot/flydsl/gemm.py:_compile_hgemm_to_cachepassesmake_split_k_bufferson the CPU instead of its own int32 tensors.op_tests/test_flydsl_hgemm_aot.py:test_hgemm_aot_cache_is_retrievable_in_run_only_modefollowstest_fhmoe_aot_cache_is_retrievable_in_run_only_modeinop_tests/test_fhmoe.py. It copies one split-K row fromdsv3_bf16_tuned_gemm.csvinto a temporary table, builds it withpython -m aiter.aot.flydsl.gemm --csv, and runs it throughaiter.tuned_gemm.flydsl_gemmwithFLYDSL_RUNTIME_RUN_ONLY=1. In run-only mode FlyDSL raises instead of compiling when no entry matches. It is skipped on other architectures.op_tests/test_graph_alloc.py: passes thesplit_kargument that #6494 added toget_split_k_buffers; the two-argument call raisedTypeError.AOT caches built before this change keep their int32-keyed entries, so they are not used until they are rebuilt.
Scope
All gfx950 FlyDSL hgemm rows of the tuned bf16 GEMM tables: at the base commit, 2,543 rows (1,022 distinct kernels) in
bf16_tuned_gemm.csvand 19 model tables. Measured with the 81 distinct kernels ofglm53_flash_bf16_tuned_gemm.csv. The gfx1250 A16W16 AOT path already passes the same counter dtype as its runtime (int32) and is not changed.Tests
Setup:
lmsysorg/sglang-rocm:v0.5.22-rocm724-mi35x-20261021(AITER 285579b). For "with this PR", this PR's change applied to that commit'saiter/aot/flydsl/gemm.py,aiter/ops/flydsl/kernels/gemm_a16w16_gfx950.pyandop_tests/test_graph_alloc.py; the touched functions are the same as on main. The new test file is added to the container in both arms.Results:
test_hgemm_aot_cache_is_retrievable_in_run_only_mode: fails in both containers without this PR (RuntimeError: FLYDSL_RUNTIME_RUN_ONLY=1 but no usable AOT cache for gemm_a16w16_gfx950) and passes in both with it.pytest op_tests/test_graph_alloc.py: without this PR 1 failed, 2 passed in both containers (test_every_cached_scratch_comes_from_the_private_pool:TypeError: get_split_k_buffers() missing 1 required positional argument: 'split_k'); with it 3 passed in both.Performance
First use of each of the 81 tuned FlyDSL hgemm kernels of
glm53_flash_bf16_tuned_gemm.csv, after building them with the AOT driver into an empty cache: one call per kernel at the shape of its first row, in a fresh process, wall time with device synchronization.The AOT driver wrote 81 entries in every container. Without this PR, the table shows the first container; the second ran while another process compiled on the same host, so its times are left out (its tests gave the same results).
This change was developed with AI assistance (Claude); I reviewed every line and ran the tests listed.