Repository navigation
cleanup(rocm): build only the launched W4A8 sdot4 config - #89
Merged
Merged
Conversation
w4a8_gemm_rdna2 launches config 8 (a8_lds_k32_ag) only. Stop instantiating the other eight explore configs, and drop the uninstantiated probe kernel and the unused instantiate macro. Co-authored-by: Cursor Grok 4.7 <cursoragent@cursor.com> Signed-off-by: BlivionIaG <kev29lt@gmail.com>
4 tasks done
Refresh the branch onto the current rdna_extras tip (1136bb9) before re-evaluating the W4A8 sdot4 config trim on gfx1030. Signed-off-by: BlivionIaG <kev29lt@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
The production dense W4A8 sdot4 GEMM only builds the config it launches.
w4a8_gemm_rdna2callsfind_config(kDefaultConfigId)withkDefaultConfigId = 8(a8_lds_k32_ag: 256 threads, NPT 4, K_STEP 32, M_TILE 8, LDS A, per-group activation scales) at group sizes 32, 64, and 128. The translation unit still instantiated the other eight explore configs at those three group sizes (24 kernel copies with no launch path), plus an uninstantiated probe kernel and an instantiate macro with no users. The header banner also claimed the file was not in the build.This drops configs 0–7 from
W4A8_EXPLORE_CONFIGS, deletesw4a8_probe_kernel(gfx1030 body and non-gfx stub) andW4A8_EXPLORE_INSTANTIATE_GEMM, and replaces the banner.find_config/kConfigsstay a one-entry lookup, so id 8 still resolves the same way. There is no env that selects a config id: the onlygetenvon this path isVLLM_RDNA2_W4A8_DEBUG.docs/rdna2/tuning.mddocumentsVLLM_RDNA2_W4A8_SDOT4(path on/off) and the two shape loggers, not a config picker, so the lookup for id 8 is unchanged.Kept: config 8 at group sizes 32/64/128, the
w4a8_gemm_kernelandw4a8_act_quant_kernelbodies, andVLLM_RDNA2_W4A8_DEBUG/VLLM_RDNA2_W4A8_MOE_DEBUG.Not touched:
csrc/rocm/moe_w4a8_rdna2.cu,CMakeLists.txt,ops.h,torch_bindings.cpp,_custom_ops.py(open PRs #51 and #57 edit those), andtests/kernels/quantization/test_rdna2_w4a8.py/test_rdna2_moe_w4a8.py.This supersedes #41. That draft did the same trim on the stale base
rdna_extra/v0.28.0and cannot land. This PR is againstrdna_extras(tip64d59b89) and does not modify #41. No other open PR onrdna_extrasremoves these unlaunched copies.AI assistance was used (Cursor Grok 4.7). A human should review every changed line.
Test Plan
No gfx1030 GPU on this VM, and
hipccis not installable here (hipccis not onPATH;apt-cache searchforhipccandrocm-devreturns no packages). A gfx1030 build plustests/kernels/quantization/test_rdna2_w4a8.pyis required before merge.Local checks, against
rdna_extrasat64d59b8942:w4a8_gemm_kernel(device body and non-gfx stub) andw4a8_act_quant_kernel(both copies) extracted fromHEADand this branch. Both real bodies match (w4a8_gemm_kernel6484 bytes,w4a8_act_quant_kernel3436 bytes).git diffhunks are only the banner, the probe kernel, the probe stub, and the config/instantiate macros.rgforw4a8_probe_kernel,W4A8_EXPLORE_INSTANTIATE_GEMM,enum class Probe, and the dropped config names (a16_lds_k32,a16_lds_k16,a16_smem_k16,a8_smem_k32,a32n2_lds_k32,c16_lds_k32,a16_lds_k32_ag): no matches.clang-format21.1.2--style=file --dry-run --Werroron the two edited files.No model eval. The launched instantiation is unchanged (
Cfg<256, 4, 32, MT=8, GROUP, kLds, A_GROUP=true>forGROUPin {32, 64, 128}), so numerics should not move. That still needs a gfx1030 run oftest_rdna2_w4a8.pybefore merge.Test Result
Kernel-body compare: identical, as above. Removed symbols: no remaining references in the tree.
clang-format21.1.2: clean.hipcc --offload-arch=gfx1030 -fsyntax-onlyofw4a8_sdot4_rdna2.cu: not run; ROCm/hipcc is not in this image and not in the default apt repos.Left for later
docs/rdna2/w4a8-wiring.mdstill describes the header as a verbatim copy of/tmp/pr9_branch/csrc/rocm/explore/w4a8_sdot4.cuhand saysW4A8_EXPLORE_CONFIGSis the full explore sweep.Cfgcomment still citesisa_check.py. Left as-is so that struct source stays byte-for-byte.kSmem,NPT=2, andM_TILE16/32 branches. Config 8 does not take them. Stripping them would edit the kernel source, so they stay.kBadConfigin the.cuerror enum is unused. That was already true before this change.Re-evaluation 2026-11-11
Verdict: ready to merge. The branch is pure subtraction. The gfx1030 build and
test_rdna2_w4a8.pythat the test plan above asked for were run on a V620 and everything the PR keeps is bit-identical tordna_extras. Not merged; waiting for the merge decision.Branch state
rdna_extras1136bb952b(the body above was written against64d59b8942)e7ee449c78=bab3c17ecb+ merge ofrdna_extras(clean).moe_w4a8_rdna2.cugained large v2-kernel changes onrdna_extrassince the PR base; none of it touches the removed items.csrc/rocm/w4a8_sdot4_rdna2.cu,csrc/rocm/w4a8_sdot4_rdna2.cuh)bab3c17ecbis authored by BlivionIaG with the Cursor Grok co-author trailer: no agent-authored commit, nothing to re-author. Supersedes the closed #41.Nothing uses what is removed
Searched the whole tree (excluding
bench_results) ate7ee449c78:w4a8_probe_kernel,enum class Probe/Probe::k*,W4A8_EXPLORE_INSTANTIATE_GEMM, the names of configs 0-7 (a16_lds_k32,a16_lds_k16,a16_smem_k16,a8_smem_k32,a8_lds_k32,a32n2_lds_k32,c16_lds_k32,a16_lds_k32_ag),w4a8_sdot4_capi,w4a8_sdot4_isa_shim: no remaining references.W4A8_EXPLORE_CONFIGSis used only byw4a8_sdot4_rdna2.cu(kConfigs,find_config(kDefaultConfigId = 8)).moe_w4a8_rdna2.cuincludes the header but uses only primitives that stay (sdot4,load_w,load_group,f16_t,u32x2_t,kLoMask,thread_x,block_x/y/z).docs/rdna2/w4a8-wiring.mdmentions the macro name, which stays.getenvcalls on these paths areVLLM_RDNA2_W4A8_DEBUGandVLLM_RDNA2_W4A8_MOE_DEBUG). The probe was never registered intorch_bindings.cpp, so no op is removed.moe_w4a8_rdna2.cu,CMakeLists.txt,ops.h,torch_bindings.cpp,_custom_ops.py.Evidence on a V620 (gfx1030), HIP 0, ROCm 7.14, torch 2.12.0+rocm7.14.0
_rocm_Cbuilt for gfx1030 from the exact trees (rdna_extras1136bb952band this branch's mergee7ee449c78), same tree path and build dir so code objects are comparable.rdna_extrastest_rdna2_w4a8.py,test_rdna2_moe_w4a8.py,test_rdna2_moe_deterministic.py,test_rdna2_moe_fp32_scratch.py,test_rdna2_dense_deterministic_dispatch.pyon GPUtest_rdna3_compile_guards.py,tests/tools/rdna/test_mono_w4a8_plan.py,tests/models/qwen4_exp/test_amd_mono_rdna2_w4a8.pyw4a8_gemm_rdna2over M in {1, 8, 32, 33, 64, 200, 513} x K in {512, 2048, 4096} x N in {256, 1024, 4096} x G in {32, 64, 128}, plusw4a8_act_quant_rdna2over the same M x G)rdna_extrasand on this PR, run twice each); that path is not touched by the PR_rocm_CopsDevice code, gfx1030, per function (disassembled and compared instruction for instruction):
rdna_extrasw4a8_sdot4_rdna2.hip.ow4a8_gemm_kernel(9 configs x G 32/64/128) +w4a8_act_quant_kernelw4a8_gemm_kernelconfig 8 at G 32/64/128 +w4a8_act_quant_kernel, identical tordna_extras(5,411 instructions); 24w4a8_gemm_kernelremovedmoe_w4a8_rdna2.hip.o(recompiled against the new header)skinny_gemms.hip.o_rocm_Cobjects (fingerprint of.text,.rodata,.note)w4a8_sdot4_rdna2.hip.ochangedSize and build time (gfx1030-only
_rocm_C):rdna_extras_rocm_C.abi3.so.hip_fatbin.textw4a8_sdot4_rdna2.hip.ow4a8_gemm_kernel: 307,076 B)w4a8_sdot4_rdna2.hip.oMAX_JOBS=8, nice 19)Fat build:
w4a8_sdot4_rdna2.cuandmoe_w4a8_rdna2.cualso compile (rc=0) forgfx1030;gfx942;gfx1100;gfx1200from this branch; the non-gfx1030 device passes of the dense TU are the existing stub (772 B of.text), so the production fat build is unaffected. The two C++ files pass clang-format.Risk
Notes, not blocking
docs/rdna2/w4a8-wiring.mditem no longer applies (the file now says the tree has nocsrc/rocm/explore/directory, andW4A8_EXPLORE_CONFIGSis still the name of the macro). Theisa_check.pycomment in theCfgstruct and thetest_rdna2_w4a8.pydocstring pointing atbenchmarks/kernels/w4a8_sdot4_explore/test_reference.pyrefer to files that are not in the tree; they were not touched.