Repository navigation
[Feat] Add tuner event pid recovery and fix deadlock - #6895
Conversation
Signed-off-by: jamesETsmith <[email protected]> Co-authored-by: Cursor <[email protected]>
Signed-off-by: jamesETsmith <[email protected]> Co-authored-by: Cursor <[email protected]>
Signed-off-by: jamesETsmith <[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: |
Signed-off-by: jamesETsmith <[email protected]> Co-authored-by: Cursor <[email protected]>
|
Thanks for pointing this problem. The mapping error is a symptom of a stale PID map, not the root failure. Restarting immediately can prevent the actual hung/crashed tasks from being processed. I reproduced this with a real BF16 tune using --mp 2, with one stale PID mapping and one hung task: Mapping Error Task 0 -> restart, remaining=4 Mapping-error tasks should remain pending while polling continues, allowing timeout, worker-exit, or accelerator-error handling to identify the root failure: mapping_error_tasks = set() if remaining_tasks and all( With this behavior, the same reproduction reaches the hung task, marks it timed out, and restarts with fewer remaining tasks instead of repeatedly restarting with the same task set. Please also add tests covering: A mapping error does not interrupt another running task. |
Keep mapping-error tasks pending while polling other workers so the underlying timeout or accelerator failure can be observed. Restart once only stale mappings remain, and remove the CUDA-event environment override per review feedback. Co-authored-by: Cursor <[email protected]> Signed-off-by: jamesETsmith <[email protected]>
cbd785c to
502ad57
Compare
|
@yzhou103 thanks for the comments! I've implemented your suggestions to 1) remove the cuda-event timing features I added earlier and 2) switching the behavior to continue runs after a mapping error to prevent the hang. I've also added new tests to cover the cases you mentioned in your comments. Let me know what you think! |
|
@yzhou103 anything else I should do here? |
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 |
Summary
Fix a livelock in
mp_tunerwhen a worker PID is missing from the PID-to-GPU map. Tasks that hit a mapping error now stay pending while the rest of the round is polled. The pool is rebuilt only when every remaining task has a stale mapping, and those candidates are rerun after the rebuild.Motivation
When a pool worker restarts, its new PID is not in
mp_tuner's PID-to-GPU map, and the task fails with a mapping error. Onmain, that task is appended todummy_failed_tasks, a list that is never read. The task is also not marked complete and does not trigger a restart. If the only remaining tasks have stale mappings, the polling loop retries them forever. This is the livelock reported in ROCm/aiter#5091.An earlier revision of this PR restarted the pool as soon as a mapping error appeared. Review on this PR showed that this hides the real failure. A mapping error is a symptom of a worker restart, and breaking out of polling early means a hung or crashed task later in the list is never reached by the timeout path. With
--mp 2, one stale mapping, and one hung task, that version restarted repeatedly with the same remaining task set.Changes
aiter/utility/mp_tuner.pymapping_error_tasksand keep polling the rest of the round. A mapping error does not break the loop, restart the pool, or drop the candidate.mapping_error_tasks. If every remaining task has a mapping error, setpool_restart_needed.mapping_error_tasksafter the pool is rebuilt so that resubmitted tasks start clean.dummy_failed_taskslist.op_tests/tuning_tests/test_mp_tuner_logic.pysimulate_poll_roundsimulation to match the new logic.TestKeyErrorHandlingwithTestMappingErrorRecovery(4 tests, described under Changed op tests below).AITER_PERFTEST_USE_CUDA_EVENToverride from the first revision was removed in response to review: CUDA-event timing measures differently from the profiler path. That work is no longer part of this PR.Testing
Documentation
This change only affects internal recovery behavior in
mp_tuner. No user-facing options or outputs change.Dependencies
Breaking Changes
None. Tuning results do not change unless a mapping error happens. If one does, the affected candidates are now rerun after a pool rebuild, where before the tuner looped forever.
PR Self-Review
Reviewed revision
ef00a29
Behavior and intent
Before this PR, a task whose worker PID is missing from the PID-to-GPU map is never completed and never causes a restart. If only such tasks remain,
mp_tunerloops forever (ROCm/aiter#5091). After this PR, mapping-error tasks stay pending while the other tasks keep being polled. That way, timeout, worker-exit, or accelerator-error handling can find the actual failure and restart the pool. If every remaining task has a stale mapping, the pool is rebuilt and those candidates are resubmitted. They are not replaced with failed dummy results. Restarting immediately on a mapping error was rejected because it stops polling before a hung task can time out.Validation and unverified scope
Ran
python3 -m unittest op_tests.tuning_tests.test_mp_tuner_logic -von a clean clone atef00a29. Python 3.12, CPU-only host, no ROCm build:TestMappingErrorRecoverytests and the existing consecutive-timeout andAcceleratorErrortests.import aitertriggers a JIT build ofmodule_aiter_core, which needsninjaand ROCm. These tests areTestTaskExecutionTiming,TestTaskStartTimeReset,TestTaskWorkerExit, andTestWorkerErrorRatio. They come frommain, are not changed by this PR, and are expected to run in the gfx942/gfx950 op-test CI.Unverified:
simulate_poll_roundcopy in the test file, not by runningmp_tuneritself.--mp 2, one stale PID mapping, and one hung task. I have also not rerun a full GPU tuning pass on this revision. The MI355X BF16(M=64, N=5120, K=5120)tuning run in the first PR description used the earlier immediate-restart design.PR-specific question
All 4 new
TestMappingErrorRecoverytests fail on themainlogic. Onmain, a mapping error is appended todummy_failed_tasksand never setspool_restart_needed, so:test_mapping_error_does_not_interrupt_successful_taskfailsassertEqual(dummy, [])andassertTrue(restart).test_pool_restarts_when_only_mapping_error_tasks_remainfailsassertTrue(restart). This is the livelock.test_mapping_error_candidates_are_rerun_after_restartfails because the candidate is put in the dummy list and no restart is requested.test_timeout_is_processed_before_mapping_restartguards against the earlier immediate-restart design. That design would setrestartin the first round, before the hung task times out.No existing canonical test covered this. The old
TestKeyErrorHandlingtests asserted the livelock behavior, for example "only KeyError tasks remain → no restart". These tests replace them instead of duplicating them.Changed op tests
op_tests/tuning_tests/test_mp_tuner_logic.py:simulate_poll_roundnow tracksmapping_error_tasksand setspool_restart_neededonly when every remaining task has a mapping error, matchingmp_tuner.TestKeyErrorHandling(3 tests) is replaced byTestMappingErrorRecovery(4 tests). The new tests cover these behaviors:This is the only test file for
mp_tunerpolling and recovery logic, and the old tests asserted the behavior that this PR removes, so the change is not redundant. All other test classes in the file are unchanged.