Repository navigation
Conversation
🏷️ 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 |
|
Advisory review with the repo's Verdict:
|
Keep the schema fix only; remove op_tests/test_gemm_a4w4_compile.py and revert the aiter_test.sh pytest routing it required. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Re-adds test_gemm_a4w4_compile.py (dropped in 85fe4de) per review feedback: op_tests/test_gemm_a4w4.py and test_f4gemm.py never exercise torch.compile or inspect the aiter schema, so the mutates_args fix in this PR had no CI guard against the regression it addresses. Co-Authored-By: Claude Sonnet 5 <[email protected]>
85fe4de to
1251748
Compare
|
@aiter-bot review |
|
aiter-bot — queued behind 7 review(s); expect to start in about 2.0 h. The box reviews one PR at a time. |
aiter-bot
left a comment
There was a problem hiding this comment.
ROCm/aiter PR #8474 — [CI] [Bugfix] Fix A4W4 mutation schemas under torch.compile
Review (advisory):
Validation (deterministic): NOT RUN — target op_tests/test_gemm_a4w4_compile.py existed, but auto-validation was disabled (REVIEW_AUTO_VALIDATE=0) and this box has no ROCm GPU (torch 2.15.0+cpu); the schema half was hand-run on CPU as advisory evidence (fails on base, passes on head)
Perf (advisory): NOT RUN — target op_tests/test_gemm_a4w4_compile.py exposes no benchmark entry point (no --scenario bench, no perftest/@benchmark harness); the diff changes no kernel or dispatch code, so no latency delta is expected
Size: 61 lines / 3 files
Design (advisory): declare the two allocating A4W4 entry points read-only (mutates_args=[] on gemm_a4w4/gemm_a4w4o8) rather than changing the torch_compile_guard default for every guarded op
Human: recommend yifehuan-amd review whether declaring gemm_a4w4/gemm_a4w4o8 read-only under torch.compile matches how ATOM and other downstream consumers call them on gfx950/gfx1250, and whether the remaining allocating ops still on the default mutates_args="unknown" (per_token_quant_hip, per_group_quant_hip) should be swept in a follow-up to PR #8474
📝 [verified] The inductor compile case is gated _GFX != "gfx950" (op_tests/test_gemm_a4w4_compile.py:73) while gemm_a4w4o8 is gfx1250-only (aiter/ops/gemm_op_a4w4.py:846) and the gfx1250 CI jobs run only the opt-in Triton suite — so the second fixed op is never compiled end-to-end on any runner and only its schema is asserted. Reviewer should ask whether a gfx1250-gated compile case for gemm_a4w4o8 is planned.
📝 [inferred] The e2e case may not reproduce the base crash it targets: issue #2780's reproducer compiles a residual-add Block under mode="max-autotune-no-cudagraphs", while the test compiles a bare function under backend="inductor", fullgraph=True, and Inductor may remove auto_functionalized_v2 cleanly for so simple a graph — leaving the schema assertion (which does fail on base) as the only guard that catches the regression. Author must confirm the inductor case fails on the base revision, or state on the PR that the schema test is the intended regression guard.
1 finding(s) posted inline, on the lines they are about:
aiter/ops/gemm_op_a4w4.py:438— The bare @torch_compile_guard() default this PR removes from gemm_a4w4/gemm_a4w4o8…
aiter-bot review on this PR flagged that gemm_a4w4o8 (the gfx1250-only mxfp8-output entry point also fixed by this PR) was never compiled end-to-end on any runner, since gfx1250 CI only runs the opt-in Triton suite. Add a compile test for it mirroring the existing gemm_a4w4 case, gated to gfx1250 so it only runs where the op is actually supported.
|
Addressing aiter-bot's review:
Also replied inline on the |
|
@demonsan — this is ready for review when you have a moment: CI is green, the two aiter-bot review threads are addressed (stale description fixed, added a |
Summary
Declare the allocating A4W4 GEMM entry points as read-only custom ops so
torch.compiledoes not functionalize inputs they never mutate.Motivation
torch_compile_guarddefaults tomutates_args="unknown". Forgemm_a4w4, that marks every tensor input as writable, insertsauto_functionalized_v2, and can fail Inductor post-grad lowering withAssertionError: auto_functionalized_v2 was not removed.Fixes #2780.
Changes
mutates_args=[]forgemm_a4w4andgemm_a4w4o8; both allocate their outputs and leave inputs unchanged.op_tests/test_gemm_a4w4_compile.py: a schema test (runs anywhere, no GPU needed) asserting both ops declare no written arguments, plustorch.compile+Inductor end-to-end tests for each op, gated to the GPU each one actually runs on (gfx950forgemm_a4w4,gfx1250forgemm_a4w4o8)..github/scripts/aiter_test.sh's pytest-collection list.Testing
op_tests/test_gemm_a4w4_compile.py(see above)git diff --check— passedDocumentation
Dependencies
Breaking Changes
None. The new schema matches the existing implementation: neither allocating op mutates its inputs.
PR Self-Review
Reviewed revision
fc069db11d(re-adds theop_tests/test_gemm_a4w4_compile.pyregression test and its.github/scripts/aiter_test.shpytest routing, and adds an equivalentgemm_a4w4o8compile test).Behavior and intent
The only runtime contract change is removal of false input mutation aliases from the two allocating A4W4 operators. Eager dispatch, argument values, output allocation, and kernel selection are unchanged. The existing schema is insufficient because
mutates_args="unknown"tells PyTorch that every tensor input is written in place, even though these functions only allocate and return new outputs; Inductor then inserts an unnecessaryauto_functionalized_v2node and can fail to remove it.Validation and unverified scope
The local machine has neither PyTorch nor a ROCm GPU with the right arch, so none of the new tests were exercised locally against real kernels:
test_allocating_a4w4_ops_have_read_only_schemasis schema-only (no GPU needed); per aiter-bot's automated review on an earlier revision, hand-run on CPU: 2 failures on the pre-fix revision, 2 passes on this revision (I don't have a working aiter build locally to re-run it myself).test_gemm_a4w4_compiles_with_inductor(gemm_a4w4, gfx950) andtest_gemm_a4w4o8_compiles_with_inductor(gemm_a4w4o8, gfx1250) are both skipped outside their target arch, so neither has run anywhere yet; they're gated to run on the PR's MI35X CI runner (gfx950) and, if a gfx1250 runner is in scope for this file, there respectively.gemm_a4w4inductor case compiles a bare function (backend="inductor", fullgraph=True), while issue [Issue]: torch_compile_guard defaults to mutates_args="unknown", causing torch.compile crash for gemm_a4w4 #2780's original reproducer compiled a residual-add block undermode="max-autotune-no-cudagraphs"; I can't confirm from here whether this simpler graph reproduces the originalauto_functionalized_v2assertion on the pre-fix revision, or whether Inductor elides it for a graph this small. The schema test is the regression guard I can vouch for; treat the inductor cases as best-effort end-to-end confirmation, not as confirmed repros of the original crash.Follow-up (not in this PR)
aiter/ops/quant.py'sper_token_quant_hipandper_group_quant_hipare allocating, non-mutating ops still ontorch_compile_guard's defaultmutates_args="unknown", so they can hit the sameauto_functionalized_v2class of failure undertorch.compile. Not fixed here; will open a follow-up to sweep remaining default-guard sites.CI and permissions
This revision touches no workflow, CI script routing logic, runner label, token permission, or secret (only adds one filename to an existing pytest-routing list).