Repository navigation
[fix] Clear rocprofiler env vars before spawning mp_tuner workers - #6860
Conversation
When the parent process initializes the GPU runtime, rocprofiler-sdk sets ROCPROFILER_REGISTER_LIBRARY and HSA_TOOLS_ROCPROFILER_V1_TOOLS with setenv. The spawned tuning workers inherit them, and the torch profiler in those workers then records no GPU kernels, so run_perftest returns 0 for every candidate and the tuner writes an arbitrary kernel with 0 us. Seen with the ROCm 10 torch wheels in the vLLM ROCm nightly images. Unset both (os.unsetenv, since os.environ does not see them) right before each worker pool is created. Co-authored-by: Cursor <[email protected]> Signed-off-by: Mikko Tukiainen <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
|
I wasn’t able to reproduce the 0 µs behavior with the ROCm images available to me. However, the root-cause analysis is technically sound, and clearing the rocprofiler variables before both the initial pool creation and subsequent pool rebuilds is appropriately scoped. I’ll add separate follow-up handling to treat us == 0 as a failed measurement and prevent it from being written to the tuning config. |
…uner spawns shape workers (#8121) 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 #6860 added to mp_tuner._new_pool before the spawn. Signed-off-by: Mikko Tukiainen <[email protected]> Co-authored-by: Cursor <[email protected]>
Motivation
On the vLLM ROCm nightly images (torch 2.13.0+rocm10.0.0), every tuner that uses
mp_tunermeasures 0 µs for every kernel candidate. Each task printsWarning: try run 3 times, but still get 0!, the run still exits 0, and the tuned CSV gets an arbitrary kernel (the first candidate) withus = 0andtflops = inf. Nothing marks the result as invalid, so a bad config can be committed by mistake.Tuning
gemm_a4w4_blockscale_tune.pyfor one shape list on MI355X: all 1404 candidates timed 0 µs.Technical Details
When the parent process initializes the GPU runtime, rocprofiler-sdk sets
ROCPROFILER_REGISTER_LIBRARYandHSA_TOOLS_ROCPROFILER_V1_TOOLSwithsetenv.mp_tuner's workers are spawned, so they inherit both. In a worker started with them set, the torch profiler records no GPU events,get_trace_perffinds no device rows ("no valida data after post process!") andrun_perftestreturns 0.Minimal reproduction, independent of AITER's kernels:
The fix unsets both variables right before each worker pool is created, both the initial pool and the one rebuilt after a crash, through a small
_new_poolhelper. It usesos.unsetenv, because the runtime sets them from C after Python took its snapshot, soos.environdoesn't contain them andos.environ.popalone does nothing. The parent's own runtime is already initialized at that point and is not affected.Test Plan
vllm/vllm-openai-rocmnightly df3bd094 (AITER 0.1.25, torch 2.13.0+rocm10.0.0).gemm_a4w4_blockscale_tune.pyon M = 1, N = 4608, K = 8192 with--mp 1, before and after the change. The change was applied to the image'smp_tuner.py; the hunks are the same as on main except for surrounding context.sitecustomize.pyonPYTHONPATH), as a reference.Test Result
a4w4_blockscale_256x64x128x128_..._intrawave_v3(first candidate)f4gemm_bf16_per1x32Fp4_BpreShuffle_32x128f4gemm_bf16_per1x32Fp4_BpreShuffle_32x128The reproduction prints
[0]before and[2]with the variables unset. black and ruff pass.Submission Checklist