Repository navigation
Conversation
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 |
There was a problem hiding this comment.
🔵 Needs a closer look
The four-XCD MLA scheduling change requires GPU validation of round-robin decode correctness and base/head latency, which this static review environment cannot provide.
No open issues 🎉
What changed in this PR
This PR completes the backend-specific die-count updates by making HIP MLA metadata use the device’s die count on gfx950, rather than assuming eight.
Changes:
- Adds a cached per-device helper that identifies die counts from the architecture and compute-unit count.
- Uses four dies for MI350P MLA scheduling while preserving eight for full-size gfx950 devices and one for other architectures.
| File | Description |
|---|---|
csrc/kernels/mla/metadata/v1_2_device.cuh |
Replaces the hardcoded gfx950 die count with the device query. |
csrc/include/aiter_hip_common.h |
Adds the cached die-count helper, mirroring the Python build-target table. |
Review effort: Balanced
There was a problem hiding this comment.
🔵 Needs a closer look
The four-XCD MLA scheduling changes still require hardware validation, particularly for round-robin correctness and base/head latency, which this review environment cannot verify because it cannot run HIP workloads.
No open issues 🎉
Review effort: Balanced
- Adds get_num_xcds_func to aiter_hip_common, a per-device probe behind SynchronizedCache, and reads it in the v1.2 MLA metadata instead of assuming eight dies on every gfx950 part. - Instantiates the IQ2R gate and down kernels for four and eight dies and launches the one the device reports. - Keeps the CU-aware generic split when Mega-MHC refuses its distributed variants, instead of dropping to split 1. - Plans the sampled top-k for the device's CU count instead of a fixed 256, and keys its workspace size by device.
243f3d0 to
a286f4c
Compare
|
I undid the PR stack, based each branch on main as one commit, and force-pushed. They don't depend on each other, so they can merge in any order. |
- Drops the sentence on when the distributed variants fall back to the generic kernel. That fallback predates this change, which only alters the split the fallback uses, and the sentence restated the current tuning's token range.
vpietila-amd
left a comment
There was a problem hiding this comment.
Looks mostly good. One small request to consider if we should revise get_num_xcds_func to use hipDeviceAttributeNumberOfXccs for detecting XCDs instead of a hand-written SKU table.
|
@aiter-bot review |
|
aiter-bot — queued behind 2 review(s); expect to start in about 57 min. The box reviews one PR at a time. |
aiter-bot
left a comment
There was a problem hiding this comment.
ROCm/aiter PR #6877 — [HIP] Fix the hardcoded die count in the HIP kernels
Review (advisory):
Validation (deterministic): NOT RUN — REVIEW_AUTO_VALIDATE=0 (auto-validation disabled); the single test target op_tests/test_topk_per_row.py exists but could not be run, and this box is 8× gfx942, where the changed gfx950-only paths (topk sampled compiles to traps off-gfx950, IQ2R, MLA v1.2 num_xcd) would not be exercised anyway — an environment gap, not a PR defect
Perf (advisory): NOT RUN — no gfx950 on this box (8× gfx942) and the auto-run disabled (REVIEW_AUTO_VALIDATE=0); the changed kernels are gfx950-only, so no base-vs-head timing could be taken here — an environment gap, not a PR defect
Size: 387 lines / 11 files
Design (advisory): the die count is resolved at runtime from a hand-written (arch, CU count) → dies SKU table inside get_num_xcds_func (silent 8-die default) rather than the hipDeviceAttributeNumberOfXccs query the repo already uses in chip_info.py and topk_per_row_kernels.cu
Human: recommend vpietila-amd review whether get_num_xcds_func in this PR should query hipDeviceAttributeNumberOfXccs instead of the hand-written SKU table, and what a gfx950 CU count the table does not list should do
3 finding(s) posted inline, on the lines they are about:
csrc/kernels/mla/metadata/v1_2_device.cuh:1408— The changed MLA v1.2 metadata (csrc/kernels/mla/metadata/v1_2_device.cuh:1408) is the default fast_mode=True…csrc/include/aiter_hip_common.h:737— get_num_xcds_func (csrc/include/aiter_hip_common.h:737) hand-writes a (arch, CU count) → dies SKU table with…aiter/ops/mega_mhc.py:316— sizes the CU-masked fallback's split by the full device CU count, so an HSA_CU_MASK/ROC_GLOBAL_CU_MASK run on…
- Asks HIP for hipDeviceAttributeNumberOfXccs in get_num_xcds_func, cached per device as before, instead of matching the architecture and CU count against a table of parts. - Fails with the device and the returned value when the query does not give at least one die, where an unlisted part used to get eight silently. Every supported HIP runtime provides the attribute, and the topk kernels already read it the same way.
- Breaks five calls and declarations in topk_per_row_sampled_kernels.cu that ran past 100 columns, with no change to the code.
|
No activity for 15 days, so this is now labelled |
Takes the die and CU counts from the device in the HIP kernels that assumed a full-size gfx950, and adds the
csrchelper for the die count, since none existed. On MI350P this makes Mega-MHC 2.6x faster on geomean from 1 to 1024 tokens, and leaves every other timing unchanged.Last of four, one per backend: FlyDSL (#5504), Triton (#5505), opus (#5848), this one.
Motivation
MI350P is a gfx950 with 128 CUs on 4 dies. Several HIP paths key on the target alone and assume MI355X's 256 CUs on 8 dies:
num_xcd = 8on every gfx950, so the work is dealt over dies the part does not have.glm53_remap8and theXCDtemplate argument).CU_COUNT = 256sizes the occupancy, wide-select and phase_b batching decisions.Technical Details
get_num_xcds_funcreadshipDeviceAttributeNumberOfXccs, per device behindSynchronizedCachelikeget_warp_size_funcandget_smem_size_func, and fails if the answer is not at least one die.topk_oneblock_read_devicealready reads the attribute the same way.glm53_remap8becomesglm53_remap_xcd<XCD>.topk_sampled_workspace_sizegainsdevice_id, and both Python caches are keyed by device.Testing
On MI350P (gfx950, 128 CUs, 4 dies), at 383ab81, all pass:
test_iq2r_glm53.py -k "not perf"test_mega_mhc.py --check-onlytest_topk_per_row.py --prefill_backend aiter sampledtest_mla_persistent.py -b 32 -c 4096test_mla_decode_update_metadata.pyTimed against the merge base, run base, head, base on one GPU; base is the mean of the two base runs. Mega-MHC is 2.6x faster on geomean from 1 to 1024 tokens (3.0x post, 2.3x no_post) and unchanged from 2048 tokens.
Mega-MHC on MI350P (HIP, H=5120, µs)
IQ2R, topk and MLA keep their timings: median speedup 1.00x for each, every shape within 2.5%.
A CU-masked run on MI355X (
HSA_CU_MASK=0:0-127, 128 of 256 CUs visible) takes the same fallback, but sizes its split by the device's 256 CUs, not the 128 the mask leaves. Mega-MHC, timed the same way; it is up to 4.14x faster up to 1024 tokens, 14% slower at 2048 tokens (post) and unchanged above.Mega-MHC on MI355X with half the CUs masked (HIP, H=5120, µs)
At 2048 tokens the split of 2 gives 256 workgroups for 128 visible CUs, which run in two waves where split 1 ran in one. Sizing the split by the mask would mean parsing
HSA_CU_MASKandROC_GLOBAL_CU_MASK; main's generic path already sizes by the device's CUs under a mask, and this PR leaves that as is.On MI355X, at 383ab81:
test_iq2r_glm53.py -k "not perf"(90 passed),test_mla_persistent.py -b 32 -c 4096andtest_topk_per_row.pypass, and the die count reads 8. On 256-CU parts without a CU mask every kernel runs as before.PR Self-Review
Reviewed revision
c3c1f92
Behavior and intent
On MI350P the MLA metadata and IQ2R remaps use 4 dies instead of 8, Mega-MHC falls back to a split generic kernel instead of split 1, and topk sampled plans for 128 CUs. The die count comes from HIP rather than a table of parts. MI355X and MI350X keep their current plans.
Validation and unverified scope
On MI350P every test listed under Testing passed, and Mega-MHC is 2.6x faster on geomean from 1 to 1024 tokens, up to 4.65x, with no shape slower; IQ2R, topk and MLA timings are unchanged. On MI355X the same tests pass and the die count reads 8.
A CU-masked run on MI355X is slower only at 2048 tokens (0.86x post, 0.96x no_post), since its split is sized for CUs the mask hides; below that it is faster, and above it unchanged.
Unverified: builds against ROCm older than 7.0.
PR-specific question
The MLA, IQ2R and topk changes apply to gfx950 only, and take their die or CU count from the device the kernel runs on, so one build serves both gfx950 parts. The Mega-MHC change applies only when its distributed variants are refused: below 256 CUs, or under a CU mask.
Changed op tests
op_tests/test_topk_per_row.py: passes the device to_sampled_workspace_size_cached. No test is added.