fix(ck): [CK] LCOMPILER-2577: Remove erroneous __restrict__ qualifier - #10574
Open
michaelselehov wants to merge 7 commits into
Open
fix(ck): [CK] LCOMPILER-2577: Remove erroneous __restrict__ qualifier#10574michaelselehov wants to merge 7 commits into
michaelselehov wants to merge 7 commits into
Conversation
The gridwise GEMM kernels take a pointer to block-shared LDS memory. Every thread of the block writes into that memory, and other threads then read it after `block_sync_lds()`. The `__restrict__` qualifier does not hold here. Clang lowers `__restrict__` to LLVM `noalias`. LangRef states that `noalias` also prohibits modifications through other threads, see llvm/llvm-project#211507. The compiler is therefore free to keep an LDS value in a register across the barrier, and the kernel reads stale data. This is analogous to ROCm#10229 and ROCm#9629. JIRA ID: LCOMPILER-2577
✅ All Checks Passed — Ready for Review
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
|
🎉 All checks passed! This PR is ready for review. |
iq136boy
approved these changes
Aug 10, 2026
ronlieb
approved these changes
Aug 12, 2026
|
@shumway ok to land ? |
Contributor
Author
|
I stopped re-running the failed CI jobs. This error repeats over and over again: |
|
@shumway can this be landed now ? we need a code owner to approve |
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.
Motivation
The gridwise GEMM kernels take a pointer to block-shared LDS memory. Every thread of the block writes into that memory, and other threads then read it after
block_sync_lds(). The__restrict__qualifier does not hold for such a pointer.Clang lowers
__restrict__to LLVMnoalias. LangRef states thatnoaliasalso prohibits modifications through other threads, see llvm/llvm-project#211507. The compiler is therefore free to keep an LDS value in a register across the barrier. The kernel then reads stale data and produces wrong results.JIRA ID: LCOMPILER-2577
Technical Details
This is analogous to #10229 and #9629.
The failing test is
TestGroupedConvndBwdData2d/9.Test2D. The kernel that fails the numerical check isDeviceGroupedConvBwdDataMultipleD_Xdl_CShuffle_v1<256, 64, 16, 16, 4, 4, Default, 16, 16, 1, 1, 4, 1, 1, 1>. It usesgridwise_gemm_multiple_d_xdl_cshuffle.hppandgridwise_gemm_xdlops_v2r3.hpp. This patch removes__restrict__fromp_sharedin both headers, 4 places in total.I confirmed all sides on MI300X (gfx942):
__restrict__present__restrict__removed__restrict__presentThe baseline compiler contains a revert of llvm/llvm-project#196923 "Reapply [AA] No synchronization effects for never-escaping identified local". That commit tells alias analysis that a synchronizing operation cannot affect an object that never escapes the function. Together with the invalid
__restrict__, this lets the compiler drop the values that other threads wrote into LDS.Test Plan
Build and run, on MI300X:
Test Result
Before:
With this patch:
Submission Checklist