Repository navigation
[CK] [CI] [JIT] [Tuning] Per-candidate faults, selection proof and auto-select in --compare - #5846
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
PR title tags & labels: |
The race, resume journal, finalist rounds, standard-error gate, evidence manifest and re-tune incumbent move to a follow-up on top of #5846, so this PR carries only what a first tuned table needs: - every candidate (or a seeded --candidate-sample) is measured once through the stock mp_tuner, alongside the auto-select incumbent and the shipped tile defaults; - a winner is published only if it beats the incumbent by more than MHA_FWD_INDIFFERENCE_DELTA (2%), and every written row is proven by a fresh-process dispatch probe; - shapes that already have a row for this GPU are skipped unless --all is given; --all --compare --update_improved re-tunes them and replaces a row only if the public operator got faster; - a re-tune that finds auto-select best warns that the existing row still overrides it, since writing no row cannot remove one. Candidates that fail the accuracy check are labelled mismatch rather than crash, against the --errRatio the run was given. Co-authored-by: Cursor <[email protected]>
mp_tuner, base_tuner's measurement_kwargs and _read_csv fix, the FileBaton zombie check and their tests return to #5592's version. They now live in #5846, where the other tuners can use them, and the MHA tuner no longer needs them. base_tuner keeps only the gpu_model filter in run_config that tuned MHA rows rely on. Co-authored-by: Cursor <[email protected]>
The gate against the incumbent used 2%, while --all --compare --update_improved keeps a row only if the public operator got at least --min_improvement_pct (3%) faster. A 2-3% winner could be published by the search and then be refused by the protected re-tune. The gate now uses the same 3% and the same "at least" comparison, as MHA_FWD_MIN_IMPROVEMENT, which is also the value the shared PromotionPolicy in #5846 uses. Co-authored-by: Cursor <[email protected]>
#5846 now has one improvement bar (min_improvement_pct, 3%) for --compare and the gate, and leaves the finalist settings to the search that uses them. This branch adds them back as FinalistPolicy (finalists, rounds, significance_sigma) next to RacePolicy, and changes what the bar means: - gate_against_incumbent takes a noise_pct floor and promotes only at max(min_improvement_pct, noise_pct). Before, the standard-error bar replaced the delta, so enough finalist rounds would publish a real but tiny win that --compare would then refuse. - The floor is two combined standard errors under the exhaustive strategy, and the race's delta under --strategy race. - The MHA tuner reads the bar from --min_improvement_pct, so one flag sets it for both the search and --compare. --delta defaults to it and is only needed to make the race's indifference zone differ. - standard_error_bar and every margin are in percent, as --compare reports them; the evidence manifest records margin_pct, bar_pct and noise_floor_pct per promotion, and the promotion bar per run. Co-authored-by: Cursor <[email protected]>
The race, resume journal, finalist rounds, standard-error gate, evidence manifest and re-tune incumbent move to a follow-up on top of #5846, so this PR carries only what a first tuned table needs: - every candidate (or a seeded --candidate-sample) is measured once through the stock mp_tuner, alongside the auto-select incumbent and the shipped tile defaults; - a winner is published only if it beats the incumbent by more than MHA_FWD_INDIFFERENCE_DELTA (2%), and every written row is proven by a fresh-process dispatch probe; - shapes that already have a row for this GPU are skipped unless --all is given; --all --compare --update_improved re-tunes them and replaces a row only if the public operator got faster; - a re-tune that finds auto-select best warns that the existing row still overrides it, since writing no row cannot remove one. Candidates that fail the accuracy check are labelled mismatch rather than crash, against the --errRatio the run was given.
mp_tuner, base_tuner's measurement_kwargs and _read_csv fix, the FileBaton zombie check and their tests return to #5592's version. They now live in #5846, where the other tuners can use them, and the MHA tuner no longer needs them. base_tuner keeps only the gpu_model filter in run_config that tuned MHA rows rely on.
The gate against the incumbent used 2%, while --all --compare --update_improved keeps a row only if the public operator got at least --min_improvement_pct (3%) faster. A 2-3% winner could be published by the search and then be refused by the protected re-tune. The gate now uses the same 3% and the same "at least" comparison, as MHA_FWD_MIN_IMPROVEMENT, which is also the value the shared PromotionPolicy in #5846 uses.
04a2090 to
f36f909
Compare
#5846 now has one improvement bar (min_improvement_pct, 3%) for --compare and the gate, and leaves the finalist settings to the search that uses them. This branch adds them back as FinalistPolicy (finalists, rounds, significance_sigma) next to RacePolicy, and changes what the bar means: - gate_against_incumbent takes a noise_pct floor and promotes only at max(min_improvement_pct, noise_pct). Before, the standard-error bar replaced the delta, so enough finalist rounds would publish a real but tiny win that --compare would then refuse. - The floor is two combined standard errors under the exhaustive strategy, and the race's delta under --strategy race. - The MHA tuner reads the bar from --min_improvement_pct, so one flag sets it for both the search and --compare. --delta defaults to it and is only needed to make the race's indifference zone differ. - standard_error_bar and every margin are in percent, as --compare reports them; the evidence manifest records margin_pct, bar_pct and noise_floor_pct per promotion, and the promotion bar per run.
f36f909 to
839de6b
Compare
The race, resume journal, finalist rounds, standard-error gate, evidence manifest and re-tune incumbent move to a follow-up on top of #5846, so this PR carries only what a first tuned table needs: - every candidate (or a seeded --candidate-sample) is measured once through the stock mp_tuner, alongside the auto-select incumbent and the shipped tile defaults; - a winner is published only if it beats the incumbent by more than MHA_FWD_INDIFFERENCE_DELTA (2%), and every written row is proven by a fresh-process dispatch probe; - shapes that already have a row for this GPU are skipped unless --all is given; --all --compare --update_improved re-tunes them and replaces a row only if the public operator got faster; - a re-tune that finds auto-select best warns that the existing row still overrides it, since writing no row cannot remove one. Candidates that fail the accuracy check are labelled mismatch rather than crash, against the --errRatio the run was given.
mp_tuner, base_tuner's measurement_kwargs and _read_csv fix, the FileBaton zombie check and their tests return to #5592's version. They now live in #5846, where the other tuners can use them, and the MHA tuner no longer needs them. base_tuner keeps only the gpu_model filter in run_config that tuned MHA rows rely on.
The gate against the incumbent used 2%, while --all --compare --update_improved keeps a row only if the public operator got at least --min_improvement_pct (3%) faster. A 2-3% winner could be published by the search and then be refused by the protected re-tune. The gate now uses the same 3% and the same "at least" comparison, as MHA_FWD_MIN_IMPROVEMENT, which is also the value the shared PromotionPolicy in #5846 uses.
5e3eef0 to
e3a353a
Compare
9f020c6 to
c055f86
Compare
5bfc443 to
e5fbd05
Compare
57f1c9e to
cef3d2b
Compare
|
Thanks @yzhou103!
Status results: Good idea, done in cef3d2b. Results are the plain 3-value |
|
Hi @amd-bartgips please resolve the conflicts |
…t candidate With return_status=True, mp_tuner returns (info, us, err_ratio, status, detail), where status is ok, mismatch, unsupported, crash, timeout, zero_time (still 0 us after the retries), oom_runtime, oom_preflight or not_run. When a worker dies, times out or its group raises, the candidate it was running fails, what its group measured before it is kept, and the rest of the group is resubmitted to the restarted pool, for typed and untyped callers alike. A group that faults 5 times in a row without measuring anything returns its remaining candidates as not_run. A fault is an AcceleratorError or an error after which torch.cuda.synchronize() fails; the worker raises GpuContextLost so the parent restarts the pool.
…ime auto-select Tuned rows may carry gpu_model (chip_info.get_gpu_model, overridable with AITER_GPU_MODEL): gfx and cu_num cannot tell MI300X from MI325X, or MI350X from MI355X. The model comes from the HIP device name or, for the gfx950 parts an older libdrm does not name, from the PCI device ID as upstream libdrm's amdgpu.ids lists it. Rows without it match as before. comm_fused_moe_host reuses chip_info's model lookup, so the PCI table exists once. dispatch_verification runs a row through the public op in a fresh process, with the family's config variable pointing at the candidate CSV, and checks the selection dispatch recorded against the one the row names. A family opts in with SELECTION_PROBE_MODULE; run_config then verifies each shape's row from the active config file and reports a stale or failed row as an error. Verification and the auto-select run see the model_configs/ merge serving sees. With COMPARE_AUTOSELECT, --compare also times auto-select (a header-only table), and --update_improved drops a row auto-select beats and writes no row for a candidate that does not beat it. stale_reason lets a family mark a row its dispatch would skip, so a plain run retunes it.
#6709 added an a_preshuffle column to tuned_grouped_fmoe.csv without a blank-cell value, so retuning a row of the production table raises, and two test_tuner_infra tests fail on main. grouped_moe_gfx1250 reads a blank a_preshuffle as 0.
…batch A tuner adds an in_datas entry for every shape, with a count of 0 when no candidate supports the shape (gemm_a16w16 under --libtype flydsl for a preshuffled shape, opus_gemm for a non-bf16 one). Such a shape has no task group, so the shape-grouped path's group-count assert failed and the whole batch was lost, under --shape_grouped and in every --mp 1 run. Zero-count entries are now dropped before groups are matched to in_datas, so the shape is left untuned and reported as such, as the per-candidate path already does.
…status callers return_status=True result was a plain 5-tuple, so under --select power its watts read as NaN and the tune wrote no rows for that caller. TuneStatusResult still unpacks as (info, us, err_ratio, status, detail).
…rs, as on main A group that hits a worker missing from the PID-to-GPU map stays queued and is resubmitted in the restart the dead worker's own fault triggers. Restarting on the KeyError itself could restart before that fault was polled, so the candidate that killed the worker ran again instead of failing.
Only a table the tuner wrote and times itself (--compare) stands in for the default table and is verified with the model_configs CSVs serving merges. A --run_config file is timed as given, so its dispatch check now reads it the same way.
No table the shared tuner handles carries gpu_model, and neither serving lookup nor the duplicate-shape keys read it, so a row filtered or checked by model here could not be told apart at runtime. A family that keys its table on the model end to end adds the check itself, and brings the model detection with it.
A return_status result was a 5-tuple, so a family whose own overrides unpack (info, us, err_ratio) would fail the moment it opted in. Results are the 3-value TuneResult again for every caller; with return_status=True, mp_tuner returns (results, statuses), one (status, detail) per result in the same order. Workers carry one private record with all fields, so the status cannot be lost between the worker and the parent.
cef3d2b to
453cc64
Compare
|
Done, rebased on main. The only real overlap was #6895's pool restart for stale PID mappings, which is kept as it is on main. |
|
@valar-cop re-review |
valar-cop
left a comment
There was a problem hiding this comment.
LGTM
ci Triton Tests (MI35X) / Shard 6 failed — not sure yet (low): The log is empty (0 bytes), so the cause cannot be determined; the PR changes no Triton kernel or Triton test code, so a PR-caused failure cannot be established.
.valar/ci/job_133122443959.log is 0 bytes
PR diff touches no Triton kernels/tests
next: Re-run the Triton job on this head to obtain a log before attributing it. https://github.com/ROCm/aiter/actions/runs/43196136788/job/133122443959
ci Triton Test Results failed — not sure yet (low): Aggregator job fails because shard 6 failed; its own log is also 0 bytes. Main passed this job 8/8 recent runs, but with no log the failure still cannot be attributed.
.valar/ci/job_133131208863.log is 0 bytes
same job on main: 8 consecutive successes 2026-11-16..2026-11-17
next: Re-run together with shard 6; it should pass once the shard does. https://github.com/ROCm/aiter/actions/runs/43196136788/job/133131208863
# Conflicts: # .github/scripts/split_tests.sh
# Conflicts: # aiter/ops/mha.py
|
Conflicts with main are resolved in one merge commit ( |
Shared tuning code for the MHA tuner (#6580), as extensions of the existing
mp_tuner,run_configand--compare --update_improvedflow. Today a fault in one candidate can fail its whole group, and nothing checks that a tuned row is what dispatch then selects.Stack. main → #5846 (this) → #5762 MHA lookup → #6580 MHA tuner. No kernel changes.
mp_tunernot_run. This holds for every caller. AKeyErrorfrom the worker PID map (a worker was replaced) leaves the group queued, as on main since [Feat] Add tuner event pid recovery and fix deadlock #6895, until the restart its root-cause fault triggers or only such groups are left. A fault is told apart by exception type, not message text:torch.AcceleratorError, or any error after whichtorch.cuda.synchronize()fails, which the worker re-raises asGpuContextLost.return_status=True,mp_tunerreturns(results, statuses): one status (ok,mismatch,unsupported,crash,timeout,zero_time,oom_*,not_run) and detail per result, in the same order. Results stay main's 3-valueTuneResultwith.wattsfor every caller, so a family's own code that unpacks(info, us, err_ratio)keeps working when it opts in. A family that writes the statuses in itsresult_to_dfgets them in--profile_file.in_datasentry with count 0 but no task group, so the shape-grouped path's count assert failed and the whole batch was lost (on main; found by @mpashkovskii). Zero-count entries are now dropped before groups are matched, and the shape is reported as untuned.run_configand--compare(opt-in per family; nothing changes for a family that doesn't set these)SELECTION_PROBE_MODULE,run_configruns each row through the public op in a fresh process, with the config variable pointed at the table, and checks the selection dispatch recorded. A stale row, or one whose dispatch or output doesn't check out, is reported as an error. A row the family cannot check (expected_selectionreturns None) isuncheckedand logs a warning. When the tuner swaps in its own table, the fresh process also merges themodel_configs/files, as serving does for the default table; a table the user set is verified as given.COMPARE_AUTOSELECT,--comparealso times auto-select (a header-only table).--update_improvedthen drops a row that auto-select beats, and writes no row for a candidate that doesn't beat it.stale_reason(row)marks a row the family's dispatch would skip, so a plain run retunes it.Promotion bar. Unchanged: main's
--min_improvement_pct(3%), overridden per family inARG_DEFAULTSor on the CLI. It must now be in [0, 100). A noise-aware bar would be a follow-up: promote only when the gain clears both the minimum and the measured noise, as #5849's race does with paired statistics.gpu_model. Not in this PR. The shared tuner's tables are not keyed on the GPU model; the MHA table is, so the model detection and the rows keyed on it are in #5762 and #6580.Cost. Shape-grouped runs (
--shape_grouped, or--mp 1) start onemultiprocessing.Managerpermp_tunercall; other runs start none, to keep per-candidate results across a worker death. Underspawnit re-imports the tuner script: about 2.7 s and 0.9 GB. The per-group cleanup (gc.collect(),empty_cache(), about 120 ms) also runs only for shape-grouped groups, so per-candidate runs such as fmoe don't pay it per candidate.Overlaps
zero_time, and its worker test also checks that status.--select powerand theSelectionPolicythatmp_tunerreads. The policy,final_timingand the power-path check are kept as main has them, and every caller still gets main'sTuneResultwithwatts, including areturn_status=Truecaller, whose statuses come as a separate list.--select poweralready rejects--compare --update_improved, so the auto-select baseline only adds or removes rows under latency selection. Dispatch verification sets the family's config variable, so the fresh process skips theAITER_SELECT=poweroverlay and checks the table it was given.return info, us, round(max_err_ratio, 4)to themp_tunerworker. On top of this PR that path would drop the status andwatts, so it should return through_format_worker_result. #7106 (@RElbers) and #7148 (@Woody-Hu) conflict with this PR only in the test files.a_preshufflecolumn totuned_grouped_fmoe.csvwithout a blank value inGroupedFmoeTuner, so twotest_tuner_infratests fail on main. The third commit adds it (dispatch reads a blank as 0), since this PR's CI runs that file.cu_num).GPU faults during power measurement (#7493). When tuning for power, #6970 runs each candidate a second time to read its power draw. If the GPU crashes during that second run, the error is currently swallowed and the candidate just gets no power reading. The crash then surfaces on the next candidate in the same worker, which gets the blame instead. #7493 lets the crash through, so this PR's fault handling blames the right candidate.
Size. 13 files, +2,032 / −189 (about 1,070 lines of tests). Owner: @yzhou103.
PR Self-Review
Reviewed revision
b9b4d72c4Behavior and intent
A fault in one tuning candidate (a GPU fault, or a worker that dies or hangs) used to fail its whole shape group. Now only that candidate fails and the rest of the group is resubmitted. A shape with no candidates also no longer aborts a shape-grouped batch. Nothing checked that a tuned row is what dispatch then selects.
run_configcan now verify that in a fresh process.--comparecan time auto-select as a baseline, so--update_improvedno longer keeps a row that auto-select beats. Verification and the auto-select baseline are opt-in per family; a family that doesn't set them is unchanged.Validation and unverified scope
Head
b9b4d72c4(main99211b6f4merged in), one MI355X (gfx950):python3 -m unittest op_tests.tuning_tests.{test_mp_tuner_logic,test_dispatch_verification,test_tuner_infra,test_csv_validation,test_compare_logic,test_mp_tuner_fault}: all 138 passed.test_mp_tuner_faultcovers the paths the status change touches, end to end.On
c54ea45ff(main0f61f2b95), which also held the model detection now in #5762:test_fast_tuning.py: 52 passed, 1 skipped, 1 failed, the same as on main without a GPU (the failure is Triton finding no GPU driver; the skip needs a GPU).op_tests/tuning_tests/except the GPU suites: the same results as main (fourtest_fhmoe_tuner.pytests need a GPU on both). The twotest_tuner_infratests that fail on main pass here (third commit).On MI355X, earlier heads:
925c133e4(mainbbef5a6f2):gemm_a16w16_tune.py --libtype flydsl --mp 1with8×128×128bf16 and the same shape withbpreshuffle=True. Without the fix it fails withgroup count (1) != in_datas count (2)andtune 0 shapes. With it, the first shape is tuned and written, and the second is listed as untuned.Unverified:
--select powertogether with this PR's fault handling was not run on a GPU; only the CPU tests above cover it.SELECTION_PROBE_MODULEorCOMPARE_AUTOSELECT, so dispatch verification and the auto-select baseline run here only against a stub family. MHA (#5762, #6580) is the first real user.PR-specific question
The
.github/changes only add tests to existing lists: fiveop_tests/tuning_tests/files tosplit_tests.sh, two modules to theunittestcommand intuning-tests.yaml, and one timing row tosplit-test-times/aiter.tsv. No trigger, permission, secret or runner changes.split_tests.shruns inaiter-test.yaml'ssplit_aiter_testsjob underpull_request, notpull_request_target, so fork code there gets a read-only token and no secrets, as before.tuning-tests.yamlruns only onscheduleandworkflow_dispatch, so PR code cannot trigger it. The added tests run on the same runners, with the same privileges, as the existing op tests.Changed op tests
test_mp_tuner_logic.py(extended): CPU tests of the new fault handling inmp_tuner. They cover statuses returned alongside the results, resuming a faulted group after what it measured, the fault probe by type andsynchronize(), the 5-fault budget, a shape without candidates, a stale PID map waiting for the restart its fault triggers, and a worker's record (status, detail andwatts) surviving the trip back from the worker. [tuner] Reject zero timing measurements #6941's zero-timing test also checks thezero_timestatus. The existing tests cover only the polling loop's timeout and pool restart.test_mp_tuner_fault.py(new): the same paths end to end on one GPU with the real spawn pool: a GPU fault inside a candidate, a worker that exits, and a failure while building inputs. Only this test exercises real process death and pool restart; the logic tests use an in-process fake pool.test_dispatch_verification.py(new): the newdispatch_verificationmodule andrun_config's use of it, against a stub family. It covers a verified row, a wrong selection, a wrong output, an unchecked row, a row for another GPU, and themodel_configs/merge (for a table the tuner wrote, not a--run_configfile). The module is new, so nothing else covers it.test_compare_logic.py(extended): the auto-select baseline in--compare --update_improved, the[0, 100)bar check and stale rows. The existing tests cover the compare plan and merge without auto-select.README.md: lists the two new test files and the new coverage of the extended ones. Documentation only.