You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@MaheshRavishankar@qedawkins I was not able to get a repro for IREE at this moment, but was able to identify that the issue is due to sharedMemBytes being set to 0 in the call to hipModuleLaunchKernel
Will try to get the repo mlir/inputs to get the actual fix in,
There weren't significant changes in the IR beyond changes to the constant data: See gist
After discussion with @AWoloszyn, the suggested solution is to reimplement support for the kernel_param block_shared_memory_size because there seems to be some kernel whose functionality unexpectedly depends on this param. Will provide udpate with which kernel specifically, soon.
If there is a kernel unexpectedly depending on that param, it might be stale. Unless there is a HIP quirk that makes specifying shared memory dynamically useful, we should avoid it. IOW the fix would be in the kernel still using the param, not to reimplement block_shared_memory_size.
We can try undoing the revert, dropping the field from the revert, and recompiling the model to see if we get an error coming from whatever kernel is trying to use it.
@pravg-amd we probably need help reproing properly. Codegen team has been having trouble actually reproing this. We need a better repro to be able to solve this issue faster.
I was verifying compiling the above mlir files and running using the actual inputs with and without the reverted changes through iree-run-module. I do see correct outputs in both the cases.
Looking at shortfin to find if the issue is indeed in shortfin's invocation of the iree apis. Will have a update on the root cause for this issue as soon as possible.
Removing the field block_shared_memory_size:uint32 (deprecated); from ~/iree/runtime/src/iree/schemas/hip_executable_def.fbs with revert being undone,
It fails in shortfin with the following error
ValueError: iree/runtime/src/iree/hal/drivers/hip/native_executable.c:109: INVALID_ARGUMENT; flatbuffer verification failed: vtable offset out of range or unaligned; while invoking native function hal.executable.create; while calling import;
The issue seems to be with the env setup being used for shortfin. When a pip package is installed and the shortfin is built using iree source locally, there seems to be some libraries which are not updated to make use of the updated sources.
Printing the value of flatbuffer_data.data_length in native_executable.c helps in confirming the issue with shortfin.
iree-run-module
Without revert - flatbuffer_data.data_length = 112212
With revert - flatbuffer_data.data_length = 112868
Shortfin
With revert - flatbuffer_data.data_length = 112868
Without revert - flatbuffer_data.data_length = 112868
Thanks for confirming the issue! In retrospect, deprecating the field the way that I did was likely not the right call with the implicated change as it meant pre-existing vmfbs could successfully load + run incorrectly because the block_shared_memory_size was no longer used.
We can either drop the field entirely now, or keep it deprecated and continue passing it on dispatch and make sure the compiler never sets a non-zero value. That way old vmfbs will continue working as expected.
We'll always need to keep the field until we make a breaking format change. Give it a release or two of always being 0 and then we can remove support and see if anyone notices. We don't make guarantees today that artifacts from one release will work with another (though one day we will).
So anything generated + run with matching compiler and runtime versions will be consistent before and after the change. The issue is that a vmfb generated with differing versions will successfully run but produce invalid results. To enumerate the cases:
On the compiler side:
Before:
We set blockSharedMemorySize to the amount of shared memory (and use no statically allocated shared memory)
After:
We never populate the field (so always defaults to 0)
On the runtime side:
Before:
We use the block_shared_memory_size specified in the flatbuffer and pass that as the amount of shared memory on dispatch.
After:
We ignore the block_shared_memory_size field and always pass 0, regardless of what the deprecated flatbuffer field says. My reasoning at the time was that since we shouldn't ever be setting the deprecated field anyway, we don't want to ever accidentally double dip on memory requested.
So that means if you took an old vmfb it would still load with the new runtime changes but wouldn't get any of the shared memory it asked for, which doesn't cause faults (IDT shared memory can fault), but instead just produces garbage (unallocated) values. A newly compiled vmfb would probably work with the previous runtime though.
Activity
Revert "[Codegen][ROCDL] Drop nominal support for dynamic shared mem (i…
MaheshRavishankar commentedon Jun 5, 2025
It would be really helpful if you could give us the
MLIR input
IREE compile command
Run command
Input files and IRPA files to use.
pravg-amd commentedon Jun 5, 2025
@MaheshRavishankar @qedawkins I was not able to get a repro for IREE at this moment, but was able to identify that the issue is due to sharedMemBytes being set to 0 in the call to hipModuleLaunchKernel
Will try to get the repo mlir/inputs to get the actual fix in,
stream_command_buffer.c
The sharedMemBytes contains the values when added a print before the call
pravg-amd commentedon Jun 5, 2025
MLIR files
attention_and_matmul_spec_gfx942.txt
flux_vae_bs1_1024x1024_bf16.txt
flux_t5xxl_bs1_512_bf16.txt
flux_schnell_sampler_bs1_512_1024x1024_bf16.txt
flux_dev_sampler_bs1_512_1024x1024_bf16.txt
flux_clip_bs1_77_bf16.txt
Revert "[Codegen][ROCDL] Drop nominal support for dynamic shared mem … (
Muzammiluddin-Syed-ECE commentedon Jun 11, 2025
There weren't significant changes in the IR beyond changes to the constant data: See gist
After discussion with @AWoloszyn, the suggested solution is to reimplement support for the kernel_param
block_shared_memory_sizebecause there seems to be some kernel whose functionality unexpectedly depends on this param. Will provide udpate with which kernel specifically, soon.qedawkins commentedon Jun 12, 2025
If there is a kernel unexpectedly depending on that param, it might be stale. Unless there is a HIP quirk that makes specifying shared memory dynamically useful, we should avoid it. IOW the fix would be in the kernel still using the param, not to reimplement
block_shared_memory_size.We can try undoing the revert, dropping the field from the revert, and recompiling the model to see if we get an error coming from whatever kernel is trying to use it.
MaheshRavishankar commentedon Jun 13, 2025
@pravg-amd we probably need help reproing properly. Codegen team has been having trouble actually reproing this. We need a better repro to be able to solve this issue faster.
pravg-amd commentedon Jun 16, 2025
@MaheshRavishankar Had a call with @Muzammiluddin-Syed-ECE to reproduce the error using shortfin.
I was verifying compiling the above mlir files and running using the actual inputs with and without the reverted changes through iree-run-module. I do see correct outputs in both the cases.
Looking at shortfin to find if the issue is indeed in shortfin's invocation of the iree apis. Will have a update on the root cause for this issue as soon as possible.
qedawkins commentedon Jun 16, 2025
If you need a smoking gun, we can try my suggestion above (undo the revert and drop the field from the flatbuffer).
pravg-amd commentedon Jun 16, 2025
Removing the field block_shared_memory_size:uint32 (deprecated); from ~/iree/runtime/src/iree/schemas/hip_executable_def.fbs with revert being undone,
It fails in shortfin with the following error
4 remaining items
pravg-amd commentedon Jun 16, 2025
Thanks @qedawkins @MaheshRavishankar @benvanik for helping in tracking down the issue.
The issue seems to be with the env setup being used for shortfin. When a pip package is installed and the shortfin is built using iree source locally, there seems to be some libraries which are not updated to make use of the updated sources.
Printing the value of flatbuffer_data.data_length in native_executable.c helps in confirming the issue with shortfin.
qedawkins commentedon Jun 16, 2025
Thanks for confirming the issue! In retrospect, deprecating the field the way that I did was likely not the right call with the implicated change as it meant pre-existing vmfbs could successfully load + run incorrectly because the
block_shared_memory_sizewas no longer used.We can either drop the field entirely now, or keep it deprecated and continue passing it on dispatch and make sure the compiler never sets a non-zero value. That way old vmfbs will continue working as expected.
benvanik commentedon Jun 16, 2025
We'll always need to keep the field until we make a breaking format change. Give it a release or two of always being 0 and then we can remove support and see if anyone notices. We don't make guarantees today that artifacts from one release will work with another (though one day we will).
MaheshRavishankar commentedon Jun 16, 2025
Oh.. wait I relanded the original change. We probably want to fix that @qedawkins to set the dynamic shared memory size to 0 always.
qedawkins commentedon Jun 16, 2025
So anything generated + run with matching compiler and runtime versions will be consistent before and after the change. The issue is that a vmfb generated with differing versions will successfully run but produce invalid results. To enumerate the cases:
On the compiler side:
Before:
We set
blockSharedMemorySizeto the amount of shared memory (and use no statically allocated shared memory)After:
We never populate the field (so always defaults to 0)
On the runtime side:
Before:
We use the
block_shared_memory_sizespecified in the flatbuffer and pass that as the amount of shared memory on dispatch.After:
We ignore the
block_shared_memory_sizefield and always pass 0, regardless of what the deprecated flatbuffer field says. My reasoning at the time was that since we shouldn't ever be setting the deprecated field anyway, we don't want to ever accidentally double dip on memory requested.So that means if you took an old vmfb it would still load with the new runtime changes but wouldn't get any of the shared memory it asked for, which doesn't cause faults (IDT shared memory can fault), but instead just produces garbage (unallocated) values. A newly compiled vmfb would probably work with the previous runtime though.
MaheshRavishankar commentedon Jun 17, 2025
Ok, that makes it clear. Can we actually error out instead? I guess that would mean a version bump
qedawkins commentedon Jun 17, 2025
I don't know what the procedure is for making a backend specific breaking format change. Do we have individual versioning per backend?
benvanik commentedon Jun 17, 2025
Let's not break the format - keep it deprecated for now.
benvanik commentedon Jun 17, 2025
(if you want to error on older files, then have the executable loader in the runtime code error out if the field is present and non-zero)
qedawkins commentedon Jun 17, 2025
Aw, deprecating a field removed the getter
benvanik commentedon Jun 17, 2025
aww, then probably have to keep it, do the check for a release, and then mark as deprecated.
qedawkins commentedon Jun 17, 2025
#21118 adds the error message.
Revert "[Codegen][ROCDL] Drop nominal support for dynamic shared mem … (
Reland "[Codegen][ROCDL] Drop nominal support for dynamic shared mem (#…