[gfx1250][tdm] Add K-loop hoist descriptor helpers and modify build script#484
Merged
[gfx1250][tdm] Add K-loop hoist descriptor helpers and modify build script#484
Conversation
…t tweaks
TDM (python/flydsl/expr/rocdl/tdm_ops.py)
- Add K-loop hoist helpers that let MoE-style K-reduction loops patch only
dgroup0 lane 2 (the per-K-tile global addr_lo) of an otherwise hoisted
base descriptor, instead of rebuilding the full 4xi32 descriptor every
iteration:
- `update_tensor_descriptor_2d_addr_lo`
- `update_tensor_gather_descriptor_addr_lo`
(carry-unsafe fast path; lo-32 add only)
- `update_tensor_descriptor_2d_addr_lo_hi`
- `update_tensor_gather_descriptor_addr_lo_hi`
- `update_tensor_descriptor_2d_addr64`
- `update_tensor_gather_descriptor_addr64`
(carry-safe variants via the new `add_addr_with_carry` helper, needed
when per-CTA base + cumulative K-tile delta can cross a 4 GiB boundary
in lo-32-bit arithmetic; otherwise the descriptor silently aliases
into the wrong 4 GiB page and the GPU deadlocks in
`amdgpu_mes_reg_write_reg_wait` with no recoverable signal).
Build scripts
- scripts/build.sh: forward `HIP_PLATFORM` (default `amd`) to cmake as a
cache var, because the shipped `/opt/rocm/lib/cmake/hip/hip-config.cmake`
has `if("OFF") ... set(hip_HIPCONFIG_EXECUTABLE) ...` and cannot
auto-detect the platform.
- scripts/build_llvm.sh: enable `lld` in `LLVM_ENABLE_PROJECTS`, turn on
`MLIR_ENABLE_ROCM_RUNNER`, and pass `HIP_PLATFORM=amd` for the same
reason.
Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds new Python-side TDM (gfx1250) descriptor “K-loop hoist” helpers to cheaply patch the per-iteration global address portion of an otherwise-hoisted descriptor (including a carry-safe 64-bit variant), and updates build scripts to better interoperate with ROCm HIP CMake configuration.
Changes:
- Introduce descriptor patching helpers in
tdm_ops.pyto update dgroup0 lane 2 (addr_lo) and optionally lane 3 (addr_hi with type bits preserved), plus anadd_addr_with_carryutility for carry-safe address updates. - Update
scripts/build.shto forwardHIP_PLATFORMinto the FlyDSL CMake configure. - Update
scripts/build_llvm.shto enablelld, turn onMLIR_ENABLE_ROCM_RUNNER, and passHIP_PLATFORM.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| scripts/build.sh | Prints/defaults HIP_PLATFORM and forwards it to FlyDSL’s CMake configure. |
| scripts/build_llvm.sh | Enables additional LLVM/MLIR components and sets HIP_PLATFORM for the LLVM/MLIR build. |
| python/flydsl/expr/rocdl/tdm_ops.py | Adds K-loop descriptor hoist/patch helpers, including a carry-safe addr_hi update path. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
coderfeli
approved these changes
May 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…t tweaks
TDM (python/flydsl/expr/rocdl/tdm_ops.py)
update_tensor_descriptor_2d_addr_loupdate_tensor_gather_descriptor_addr_lo(carry-unsafe fast path; lo-32 add only)update_tensor_descriptor_2d_addr_lo_hiupdate_tensor_gather_descriptor_addr_lo_hiupdate_tensor_descriptor_2d_addr64update_tensor_gather_descriptor_addr64(carry-safe variants via the newadd_addr_with_carryhelper, needed when per-CTA base + cumulative K-tile delta can cross a 4 GiB boundary in lo-32-bit arithmetic; otherwise the descriptor silently aliases into the wrong 4 GiB page and the GPU deadlocks inamdgpu_mes_reg_write_reg_waitwith no recoverable signal).Build scripts
HIP_PLATFORM(defaultamd) to cmake as a cache var, because the shipped/opt/rocm/lib/cmake/hip/hip-config.cmakehasif("OFF") ... set(hip_HIPCONFIG_EXECUTABLE) ...and cannot auto-detect the platform.lldinLLVM_ENABLE_PROJECTS, turn onMLIR_ENABLE_ROCM_RUNNER, and passHIP_PLATFORM=amdfor the same reason.Motivation
Technical Details
Test Plan
Test Result
Submission Checklist