Repository navigation
Conversation
Reapply the final Task1 Torch-owned split-K workspace and Task2 caller-resolved exact-kid interface state on top of upstream/main@a43694f1.\n\nThis is a squashed final-state review commit; obsolete intermediate Task1/Task2 implementations are intentionally not replayed. The resulting task files match the validated merge candidate.
Reapply upstream commit 1b741c0 on top of the unified public API, canonical exact-kid registry, and caller-owned Torch workspace design. Adopt the policy-tag N-D TDM API, clusterlaunch grid round-up, compile-time gfx1250 reducer dispatch, mixed-arch device guards, tuned configs, and the final decision to leave the fused family unregistered.
Reuse thread-local tensor descriptors and avoid redundant error calls so MI308 workspace performance stays within repeat noise. Record the full correctness and ABBA validation results. Co-authored-by: Cursor <[email protected]>
Move the architecture heuristics and tuned-candidate validation into a dedicated policy module while keeping exact execution in the family launcher. Preserve the upstream skinny-to-Torch fallback when no valid tuned row exists.
…ce_management_and_interface_refactor
…ce_management_and_interface_refactor
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
PR title tags: |
Merge upstream/main at 226ee79 and reconcile transactional JIT cache publication with the exact-kid OPUS interfaces and subset code generation. Allow batched gfx1250 CO launches while retaining the batch-one restriction for workspace kernels. Remove the duplicate gfx1250 split-K test file and keep the reducer row-limit check in the existing A16 suite using registry kids. Include always-emitted MXFP8 BMM ids in compiled-kid metadata and validate extra-kid requests against the complete generated set. Validation: 1477 CPU/Meta tests and 25 subtests passed; Black, Ruff, syntax, and diff checks against upstream/main passed. No GPU tests were run.
|
gfx942 BF16-workspace exact-N guard redirects on one entry point and hard-raises on another — Problem: aiter/ops/opus/policy.py:419-425 (_resolve_a16w16_candidate) redirects kid 10210→10200 and 10213→10203 when N not in GFX942_BF16WS_EXACT_N, but aiter/ops/opus/gemm_op_a16w16.py:419-431 passes the tuned row's solidx and an explicit kernelId verbatim into _execute_a16w16, and aiter/ops/opus/launch_plan.py:285-294 then raises ValueError("gfx942 exact kid 10210 requires N in [64, 128, 256, 384, 512, 1024, 2048]; got N=1000") with no redirect anywhere in between. Impact at runtime: on a gfx942 device, gemm_a16w16_opus(A, B, kernelId=10210, splitK=2) with A: [M,K] bf16 and B: [K,1000] bf16 (N=1000, outside the exact-N set; the guard fires for any splitK) now hard-raises through the compatibility entry the author claims is behavior-preserved, where base's generated launcher (csrc/opus_gemm/codegen/gen_instances_gfx942.py:351-357 at base) silently called the fp32-workspace sibling 10200 and returned a correct Y; the tuned-row path has the same asymmetry via a user AITER_CONFIG_GEMM_BF16_FILE override (the shipped CSV carries no such rows and the base tuner already refused to emit them, so the explicit-kernelId path is the concrete trigger). Action: Author must route gemm_a16w16_opus's tuned-row and explicit-kernelId kids through resolve_a16w16_tuned_candidate (or apply the same 10210/10213 redirect inside _build_a16w16_launch_plan) so all entry points agree. [verified] |
- converge A16 split-K before workspace sizing across architectures\n- validate MXFP8 saved rows and prefetch constraints before launch\n- restore gfx942 compatibility redirects while keeping exact APIs strict\n- distinguish direct/workspace compiled-table availability\n- align gfx1250 cluster candidate and default-build coverage
Keep exhaustive heuristic, shipped-config, artifact identity, and hardware launch coverage while collapsing duplicate planner, route, compatibility, and tuner cases into their maintained owners. Validated with Black, Ruff, Python syntax checks, git diff --check, and 98 focused CPU/meta tests plus 22 subtests. GPU tests were not run locally.
Resolve the A16W16 test conflict while retaining strict exact-kid/caller-workspace coverage and main's production benchmark entry.
Keep exact-kid launch validation isolated from main's production benchmark path and remove duplicate shape-driven wrappers.
Resolve OPUS codegen and registry conflicts with ROCm#5397 while preserving exact-kid typed-workspace handling.
Upstream reworked the OPUS BMM path underneath this branch, so this is a port rather than a merge. Three changes drove every conflict: * ROCm#4961 "Unify OPUS GEMM/BMM interfaces and use Torch workspaces" deleted aiter/ops/opus/bmm_op.py, replaced opus_bmm_a8w8_mxscale with opus_gemm_a8w8_mxscale_bmm_launch, and moved the split-K workspace from a kernel-held ws_handle to a caller-owned pointer (kargs.ptr_ws). * BMM kid ids moved into the 8000 band (BMM_MXSCALE_KID_OFFSET). PR ROCm#4320's private namespace collided with the canonical registry. * A per-instance workspace_preload_sf was added to work around a ROCm 7.2.4 clang-22 illegal-register-class miscompile in the D_OUT=void specialization. What this commit does with them: bmm_op.py is gone, as upstream has it. Its three kid gates -- M alignment, B layout, scale layout -- moved to policy.py beside the other kid policy and collapsed into one cached table; bmm_a8w8_mxscale_opus moved to gemm_op_a8w8.py beside the launch entry it wraps; the local heuristic was dropped because upstream's _heuristic_mxscale_bmm_kid is the same function with the ids globalized. All eight call sites now use the unified entry and pass kid/split_k by keyword: the new tail is (workspace, kid, split_k), the reverse of the old (splitK, kernelId), and positionally both orders type-check and run. All 131 BMM kids are globalized. Checked for collisions first -- our 84 local ids shifted by 8000 do not touch upstream's 47. The 133 gfx950 rows of the bpreshuffle tuned table are renumbered with them, and re-verified: all 26 kids they name pass the B-layout, plain-scale and M-alignment gates. lookup_mxscale_bmm_config had two implementations differing only by the bpreshuffle switch. One is left, in policy.py, with the switch folded in. Codegen keeps both sides: upstream's @@SPLITK_PRELOAD@@ and our @@SFMPACK@@ / @@panel@@ describe different axes of the same template, and taking either side whole would have dropped a feature. Not done here: the tree builds only as far as this commit's own check went. The wave8 pipeline's three kargs.ws_handle reads are converted to ptr_ws, which is what the first real compile caught -- that file merged cleanly and so was never reviewed. A full codegen+compile of all 131 instances has not passed yet. Co-authored-by: Cursor <[email protected]>
Summary
This PR refactors the OPUS GEMM/BMM around one strict, exact-kernel-id contract from Python through generated C++ dispatch.
opus_gemm()andopus_bmm()entry points,Motivation
The previous path mixed kernel selection, validation, dispatch, and workspace management across Python and C++, resulting in duplicated wrappers, heuristic dispatch, and global workspace state.
This PR defines a strict exact-kid boundary: callers select the kernel and own the output/workspace tensors, while OPUS C++ validates and launches that exact kernel.
Architecture
A16W16
A8W8
Production paths
TunedGemm.mm/gemm_a16w16()->opus_gemm()->_execute_a16w16()opus_gemm_a16w16_launch()opus_bmm()->_launch_a16w16_bmm()->_execute_a16w16()gemm_a8w8()->opus_gemm()-> A8 backendopus_gemm_a8w8_launch()gemm_a8w8_blockscale()->opus_gemm()opus_gemm_a8w8_blockscale_launch()libtype=opusrow ->opus_gemm(layout="bpreshuffle")opus_gemm_a8w8_blockscale_bpreshuffle_launch()batched_gemm_a8w8_mxscale()-> split-1 checked raw path oropus_bmm(layout="mxscale_bmm")opus_gemm_a8w8_mxscale_bmm_launch()Workspace ownership and execution
torch.compile, MetaTensor, and FakeTensor keep the registeredtorch.opspath.Current A16 two-stage workspace layouts are:
[split_capacity, batch, padded_M, padded_N][split_capacity, batch, padded_M, padded_N][split_capacity, padded_M, padded_N]The experimental gfx1250 fused split-K source remains available for repair, but it is not registered and cannot be selected by the public API.
Tuning
csrc/gemm_a16w16/gemm_a16w16_tune.py --libtype opusPerformance
All 96 eager and 96 graph cases improved. Matching device show that the gains came from Python/C ABI dispatch, not kernel changes.
Guide
aiter/ops/opus/__init__.py: strict public GEMM/BMM router and contractsaiter/ops/opus/policy.py: high-level candidate and tuned-row policyaiter/ops/opus/launch_plan.py: immutable split-K/workspace planningaiter/ops/opus/gemm_op_a16w16.py: A16 executor, Torch workspace, and C ABIaiter/ops/opus/gemm_op_a8w8.py: A8 family adapters and pybind backendcsrc/opus_gemm/opus_gemm.cu: A16/A8 GEMM family entries and exact dispatchcsrc/opus_gemm/opus_bmm.cu: MXFP8 BMM exact dispatchcsrc/opus_gemm/gen_instances.pyandcodegen/gen_instances_gfx*.py:generated manifests, subset selection, and typed exact-kid tables
csrc/opus_gemm/opus_gemm_common.py: canonical registry and family metadata