Repository navigation
Conversation
…r the flat-row decode A caller that captures CUDA graphs has to choose between OpusMlaFlatDecode and mla_decode_fwd before recording, so it needs the kernel's limits and the "When to use it" rule as code, not prose. ATOM had a copy of both (ROCm/ATOM#2961); this puts them next to the kernel. - unsupported_reason(num_heads, q_len, *, kv_dtype, q_dtype, kv_dim, page_size, kv_bytes): why the kernel cannot run a decode (gfx950, fp8 Q and KV, 576-wide rows, page size 1, a KV cache below 4 GiB, at most 128 * max_chunks rows a request), or None. - min_batch(num_heads, q_len, cp_world_size): the smallest batch at which the docstring's guidance picks this kernel, or None where mla_decode_fwd stays the choice. Shape only, so it can be asked once per captured graph. - supports(num_heads, q_len, cp_world_size, batch, *, kv_dtype, ...): both. - OpusMlaFlatDecode(max_q_len=, num_heads=) sizes item_cap from the widest request (item_cap_for: one item per (request, chunk) unit, one per XCD boundary across a request's chunks, one per workgroup), so no plan of up to max_batch such requests raises. Without them item_cap stays 1024. No kernel or planner change. op_tests/test_mla.py checks the selection table, each limit, and that a sized decoder plans batches up to 256 at uniform, skewed and ragged contexts under 8-way round-robin CP and without CP.
🏷️ CI GuideRuns automatically on every PR:
🚦 Update: Heavy CI review gate:
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 |
|
@aiter-bot review |
|
aiter-bot — queued behind 6 review(s); expect to start in about 73 min. The box reviews up to 4 PRs at a time. |
aiter-bot
left a comment
There was a problem hiding this comment.
ROCm/aiter PR #9178 — [OPUS] [MLA] mla_flat: supports(), min_batch() and capacity sizing fo…
Review (advisory):
Validation (deterministic): NOT RUN — auto-validation disabled (REVIEW_AUTO_VALIDATE=0) and no idle GPU on this box (all 8 at ~98% use, torch.cuda unavailable in this environment), though the single test target op_tests/test_mla.py existed — environment gap, not a PR defect.
Perf (advisory): NOT RUN — perf triage required the target's harness (python3 op_tests/test_mla.py) but the same environment gap applies (no idle GPU, torch.cuda unavailable); the PR itself makes no perf claim.
Size: 225 lines / 2 files
Design (advisory): the kernel-selection rule moves out of ATOM's private copy into aiter as query functions beside the kernel, and item_cap turns from a hand-picked 1024 into a closed-form worst-case count — the caller still decides, only the rule's content changes address.
Human: recommend Andreas Karatzas review whether min_batch's hard-coded selection table — in particular its deliberate exclusion of the one-token-per-request cells where the module's own measurements say opus wins from batch 8, and its MI355X-only measurements answering for every gfx950 — is the right contract for a caller that routes on supports() alone.
📝 [inferred] min_batch's thresholds are MI355X measurements (the module docstring scopes them "on MI355X at 8k and 131k tokens of context"), but supports() answers on any gfx950 and the mechanical consumer cannot see the qualifier that lives only in the docstring — on another gfx950 part the batch and head-count boundaries are unmeasured. Reviewer should ask whether the boundaries hold on the other gfx950 SKUs, or whether supports() should scope its answer to MI355X.
📝 [verified] nothing in aiter calls supports()/min_batch()/unsupported_reason()/item_cap_for() or passes the new max_q_len/num_heads kwargs, so until ATOM#2961 replaces its own wanted()/dcp1_shape_ok()/uses_opus_for_batch() copies with calls to these, the exported rule activates nothing and no CI exercises it end to end — the table can drift from the kernel unobserved in the meantime. Reviewer should ask for the ATOM#2961 consumer to land before the guidance table and the kernel drift apart.
2 finding(s) posted inline, on the lines they are about:
aiter/ops/opus/mla_flat.py:106— min_batch (aiter/ops/opus/mla_flat.py:106) returns None for every q_len < 2, but the module's own measured…aiter/ops/opus/mla_flat.py:117— supports() (aiter/ops/opus/mla_flat.py:117) does not forward the max_chunks parameter that unsupported_reason…
| ``mla_decode_fwd`` stays the choice at every batch ("When to use it" above). The answer | ||
| depends on the shape only, so a caller that captures CUDA graphs per batch can ask it once | ||
| per graph.""" | ||
| if q_len < 2: |
There was a problem hiding this comment.
| return None | ||
|
|
||
|
|
||
| def supports( |
There was a problem hiding this comment.
📝 [verified] supports() (aiter/ops/opus/mla_flat.py:117) does not forward the max_chunks parameter that unsupported_reason itself takes (mla_flat.py:75), so a decoder built with a non-default max_chunks — e.g. OpusMlaFlatDecode(max_batch, max_chunks=4) — gets supports() answers computed for the default 8: supports(96, 9, 8, 32, kv_dtype=fp8) says True while 9*96=864 rows exceeds that decoder's 512 and plan() raises at plan time. Reviewer should ask whether supports() needs a max_chunks passthrough or a docstring note that it describes the default decoder.
…ks in supports Review of ROCm#9178: - min_batch now takes one token per request from batch 8 at 96 or more heads with CP and at 48 or more without, as the "When to use it" table says; it returned None for every q_len below 2, which contradicted the table. check_opus_flat_decode gains one-token shapes (96 and 128 heads with CP, 48 and 96 without) against the reference. - min_batch keeps 16 heads at 3-4 tokens without CP on mla_decode_fwd below batch 8 (0.92-1.00x of the default path at batch 4, 1.05-1.11x at batch 8), as committed in the review of ROCm#7415; the docstring's table now lists it. - supports() passes max_chunks to unsupported_reason, so it answers for a decoder built with a non-default max_chunks. - min_batch's docstring says the boundaries were measured on MI355X and are unmeasured on other gfx950 parts.
aiter's min_batch (ROCm/aiter#9178) now also takes one query token a request from batch 8 at wide head counts. OpusMla.takes keeps ATOM to the MTP decode this PR validates: buckets of one query token stay on mla_decode_fwd. The DCP1 kernel check runs at aiter's smallest batch for each shape (batch 8 for 16 heads at 3-4 tokens, which aiter now keeps on mla_decode_fwd below it).
…runcated watchdog read, size the agent timeouts for the 4-lane pool (#9201) * [CI] review-bot: read WORK out of a binary fetch log, retry a stalled watchdog read, size the agent timeouts for the 4-lane pool Three failure modes from the 2026-12-04 outage (6 failed runs, 01:24-03:02): - run_one.sh extracted WORK= from the tee'd fetch log with a bare grep, so a PR with binary artifacts (OPUS .co blobs put NULs in that log) made grep answer "binary file matches" instead of the match -- a fetch that SUCCEEDED was reported as "fetch produced no WORK dir" on every retry (#8283/#7979/#7983). grep -a reads the log as text. - watchdog.py caught only HTTPError, so a 30s socket timeout crashed the watchdog with a bare TimeoutError and failed a run whose review had already published a green card (#9178). A stalled GET is now retried (3 attempts, 5s backoff); a POST is never retried, because a retried comment can land twice, and a failed POST degrades to 0, which the caller already warns about. - AITER_AGENT_TIMEOUT=2400s was sized for one review at a time; the 4-lane pool serves four through the same GLM endpoint and workers measured 25-40+ min under that load, so 2400s timed out live while the backend answered normally (#8983/#8541). Defaults now 3300s/agent and 6900s/run (115 min, still under the job's timeout-minutes of 120; check_prompts.py asserts it). watchdog_test.py gains real-socket transport checks (the retry lives below the _get/_post seam its fakes replace) with a mutation guard; _fetchfail_test.sh gains the binary-log case. selftest: 156 green / 0 red. Co-Authored-By: Claude Code <[email protected]> * watchdog: retry a truncated response body, not just a stalled read A response that dies mid-body raises http.client.IncompleteRead -- an HTTPException, not an OSError -- so the OSError-only retry net added for the 2026-12-04 stall let it escape unretried and unnamed: the same bare-traceback crash one layer up, and _post's RuntimeError guard could not degrade it either. Name the family in the catch so a truncated GET is retried like a stalled one and a truncated POST degrades to 0. Co-Authored-By: Claude Code <[email protected]> --------- Co-authored-by: zufayu <[email protected]> Co-authored-by: Claude Code <[email protected]>
Summary
Follow-up to #7415. A caller that captures CUDA graphs has to choose between
OpusMlaFlatDecodeandmla_decode_fwdbefore it records the call, so it needs the kernel's limits and the docstring's "When to use it" rule as code. ROCm/ATOM#2961 carried its own copy of both; review asked for them to live in aiter. This adds them toaiter/ops/opus/mla_flat.py, with no kernel or planner change:unsupported_reason(num_heads, q_len, *, kv_dtype, q_dtype=None, kv_dim=576, page_size=1, kv_bytes=0, max_chunks=8): why the kernel cannot run a decode (gfx950, fp8 Q and KV, 576-wide rows, page size 1, a KV cache below 4 GiB, at most128 * max_chunksrows a request), orNone.min_batch(num_heads, q_len, cp_world_size=1): the smallest batch at which "When to use it" picks this kernel, orNonewheremla_decode_fwdstays the choice at every batch. 2 or more query tokens: under round-robin CP from 96 rows a request at batch 1; without CP 48 or 96 heads at batch 1, 12 or 16 heads at batch 4 (16 heads at 3-4 tokens at batch 8). One token: batch 8 at 96 or more heads under CP, 48 or more without. The boundaries were measured on MI355X. It depends on the shape only, so a caller can ask it once per captured graph.supports(num_heads, q_len, cp_world_size, batch, *, kv_dtype, ..., max_chunks=8): both together.OpusMlaFlatDecode(max_batch, ..., max_q_len=, num_heads=): with the widest request given,item_capdefaults toitem_cap_for(...), enough work items for any plan of up tomax_batchsuch requests at any contexts, instead of 1024. Existing callers are unchanged.Relation to #7415. #7415 left the choice to the caller ("
OpusMlaFlatDecodedoes not choose between the paths; the caller does"), and its review thread pointed to ATOM#2961'swanted()/dcp1_shape_ok()/uses_opus_for_batch()as where the rule lived. That still holds: nothing in aiter calls these functions,mla_decode_fwd,get_mla_metadata_v1andmla_reduce_v1are untouched and never dispatch to the kernel, and the caller still decides whether to build a decoder and run it. What moves is the content of the rule, from a copy in ATOM to one place next to the kernel, so the limits and the measured boundaries cannot drift apart from the kernel they describe. ATOM#2961's review asked for exactly this (its item 1); its head (d8c63164) replaces those ATOM functions with calls to these and depends on this PR.PR Self-Review
Reviewed revision
5c5cd180Behavior and intent
Adds query functions beside the flat-row decode: the kernel's input limits (
unsupported_reason), the measured "When to use it" boundaries (min_batch), both together (supports), and work-item sizing from the widest request (item_cap_for, used byOpusMlaFlatDecodewhen givenmax_q_lenandnum_heads). No kernel, planner or existing call path changes; nothing in aiter calls the new functions, and existingOpusMlaFlatDecodecallers keepitem_cap=1024.The existing behavior was insufficient for a graph-capturing caller: the limits and boundaries existed only as docstring prose, so ATOM kept a hand copy of both, and
item_cap=1024is not enough for every plan at large batches (128 heads x 8 tokens x batch 128 under CP needs about 1200 at mixed contexts), so a caller had to size it by hand.Validation and unverified scope
MI355X (gfx950), aiter at this revision, two toolchains: ROCm 10.1 / PyTorch 2.13 and ROCm 7.2.4 / PyTorch 2.10.
python3 -c "from op_tests import test_mla as t; t.check_opus_flat_supports(); t.check_opus_flat_decode()": passes on both toolchains. These are the two checkspython3 op_tests/test_mla.pyruns in its gfx950 block; I ran them directly rather than the whole script.item_cap_formakescheck_opus_flat_supportsfail (a plan at batch 256, 8 tokens, 96 heads under CP needs 1739 items against 1578).d8c63164against this revision: its opus tests (tests/test_opus_mla_dispatch.py,tests/model_ops/test_opus_mla_gpu.py, 85 tests) pass on both toolchains.Unverified: the boundaries on gfx950 parts other than MI355X (unmeasured; the docstring says so); new timings (none taken here: the one-token cells and the 16-head 3-4 token boundary come from #7415's measurements)