Repository navigation
[CK] [Tune][MoE] Clear inherited rocprofiler env before the MXFP4 FlyDSL tuner spawns shape workers - #8121
Conversation
…uner spawns shape workers Mxfp4FlydslTuner.tune initialises the GPU in the parent and then starts its own spawn pool, so the shape workers inherit the rocprofiler-sdk registration variables and torch.profiler records no GPU kernels. Reuse the clearing that ROCm#6860 added to mp_tuner._new_pool before the spawn. Signed-off-by: Mikko Tukiainen <[email protected]> Co-authored-by: Cursor <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
WAITING ON AUTHORPR Self-ReviewRevision Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision. Questions to answer in the PR description
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
|
@valar-cop review |
…uner import conflict. #7542 and #8121 import clear_inherited_rocprofiler_env from mp_tuner; this branch imports gfx942_mxfp8_block_exponent from fp4_utils. Both imports are kept. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
gemm_moe_tune.py --mxfp4-flydslruns each shape in a freshspawnprocess. Each child inherits the two rocprofiler-sdk variables that the parent's GPU initialisation sets, sotorch.profilerin the child records no GPU kernels, and every candidate either fails or times as 0. This PR clears those variables before the spawn, reusing the helper #6860 added formp_tuner's pool.Motivation
rocprofiler-sdk calls
setenvforROCPROFILER_REGISTER_LIBRARYandHSA_TOOLS_ROCPROFILER_V1_TOOLSin whichever process initialises the GPU. #6860 found thatmp_tunerworkers which inherit these variables see an empty profiler trace, and cleared them in_new_pool.Mxfp4FlydslTuner.tunedoes not use that pool. It calls_preflight_devices, which initialises the GPU in the parent, and then starts its ownmultiprocessing.get_context("spawn")pool, so #6860's fix never applies. Staged search is the default and always takes this path, even with--mp 1.The symptom in the 0.1.29 image, tuning one Qwen3.8-Flash-Next TP2 shape (
token=64, model_dim=2560, inter_dim=384, expert=513, topk=11, MXFP4 per_1x32):host_time_sum). The tuner ends with[Tuning not Finished] some shapes are not tuned or all failed, and the output row is empty.flydsl_mxmoe_g1_a4w4_16x128x256_f16in_nt_xcd2andflydsl_moe2_layout_afp4_wfp4_bf16_t16x128x128_atomic_nt_sbm16. CUDA-graph replay offused_moewith that row measures 103.8 µs, so the profiler time is real.Falling back to CUDA-event timing is not a workaround. At small M it measures host launch time: every candidate at M=64 landed near 155 µs, so the pick was noise.
Not a duplicate: I searched the open AITER PRs for rocprofiler and tuner environment fixes. #6860 (merged) fixed
mp_tuner._new_poolonly.Changes
aiter/utility/mp_tuner.py: move the loop out of_new_poolinto a publicclear_inherited_rocprofiler_env()._new_poolcalls it, so its behaviour is unchanged.csrc/ck_gemm_moe_2stages_codegen/gemm_moe_tune.py: call the new function inMxfp4FlydslTuner.tuneright before the spawn context is created.The variables are removed only from the tuner process, which runs no profiled work of its own after this point. No kernel or runtime path changes.
Performance (if applicable)
Not a kernel change, so there is no kernel speedup to report. The fix makes the existing tuner produce timings.
--mxfp4-flydsl, one shape (M=64, 2560/384/513/11)Testing
Documentation
There is no new flag or behaviour: the tuner now works as documented.
Dependencies
Breaking Changes
None.
PR Self-Review
Reviewed revision
9faae0e
Behavior and intent
The MXFP4 FlyDSL MoE tuner's shape workers no longer inherit the parent's rocprofiler-sdk registration. Before this PR,
torch.profilerin those workers recorded no GPU kernels and every candidate failed.Validation and unverified scope
Repro on one GPU, MI355X (gfx950), AITER 0.1.29 in
vllm/vllm-openai-rocm:nightly-rocm100-8ca766326652caf4b8e50d1b9118d8a22f6adc73:Before the fix, this prints "[Tuning not Finished] ... all failed" and the
s64_out.csvrow is empty. After it, the row is tuned at about 105 µs with the kernels named above.Remaining and unverified:
--mxfp4-flydslpath was exercised. I found no other spawn pools ingemm_moe_tune.py, but did not audit other tuner scripts.PR-specific question
No kernel path changes, so no runtime dispatch is affected. The change only runs inside the offline tuner,
gemm_moe_tune.py --mxfp4-flydsl(Mxfp4FlydslTuner.tune), for every architecture, dtype and shape that tuner accepts.The new call removes two rocprofiler-sdk environment variables from the tuner's own process right before it creates the
spawncontext. This is the same thingmp_tuner._new_poolalready does since #6860. Inference processes never import or call it, and the variables are only cleared in a process that runs no profiled work of its own after that point.Changed op tests
None.
Co-authored-by: Cursor [email protected]