Repository navigation
[spirv] Switch to use common target description - #17623
Conversation
| def MFMA_F16_32x32x8_F32 : I32EnumAttrCase<"MFMA_F16_32x32x8_F32", 1>; | ||
| // TODO: Create separate WMMA ops for AMD and NVIDIA GPUs | ||
| def WMMA_F16_16x16x16_F32 : I32EnumAttrCase<"WMMA_F16_16x16x16_F32", 2>; | ||
| def WMMA_F16_16x16x16_F16 : I32EnumAttrCase<"WMMA_F16_16x16x16_F16", 3>; |
There was a problem hiding this comment.
If this is supposed to be for cooperative matrix, we should define a separate attribute for it. This is not very clear from the descriptions below, but IREEGPU_MMAIntrinsic is effectively restricted to LLVMGPU. This is because lowering to amgpu.wmma/mfma (with an explicit layout) only makes sense for intrinsics used when targeting LLVM. We can make some of the interface methods on IREEGPU_MmaInterfaceAttr optional/FailureOr to allow opaque layouts. Then the KernelConfig logic will just look at shapes and doesn't have to care whether the mma kind is opaque or not.
There was a problem hiding this comment.
If it's possible to define external interface implementations on attributes, that sounds best and then we just define the interface on #spirv.coop_matrix_props_khr.
There was a problem hiding this comment.
The goal is to unify all the different GPU backends with one set of targets. So ideally we should have one #iree_gpu.target that works for both cuda/hip and vulkan. That's largely upheld now--if you look at how getVulkanTargetDetails and getCUDATargetDetails/getHIPTargetDetails, they go to the same underlying getAMDTargetDtails/getNVIDIATargetDetails. This makes sure we have the same wgp = and chip = in #iree_gpu.target. It also conceptually makes sense--it's the same hardware no matter what apis we use to drive it. Though I saied before it's "largely upheld"--we have the feature = part of #iree_gpu.target doing separate things for separate underlying backends. E.g., +sramecc,-xnack for hip, spirv:v1.3 for spirv, etc. That's more controlling what the llvm/spirv backend compiler in llvm/mlir. It's a bit annoying but I don't ever see a way to avoid that.
So I'd be hesitant to create separate mma attributes for separate gpu apis. we can create separate ones for separate vendors, which makes sense because they are different layouts. so that's what I meant we want to create separate ones for nvidia in the comment. even though they are opaque in the vulkan side; they certainly have a hardware layout. for amd side, we know exactly what wmma layout are. for nvidia side, wmma layout is not encoded in their ptx spec but you can figure it out like https://github.com/ahennequ/cuda-tensorcores-register-mapping. though if it's only for vulkan we might not need that info. so I agree with you that we may want to turn some interface methods on IREEGPU_MmaInterfaceAttr as optional.
There was a problem hiding this comment.
we can create separate ones for separate vendors, which makes sense because they are different layouts. so that's what I meant we want to create separate ones for nvidia in the comment. even though they are opaque in the vulkan side; they certainly have a hardware layout. for amd side, we know exactly what wmma layout are.
+1
There was a problem hiding this comment.
Ok, I see your point. Agreed that excessive duplication is not wanted and somewhat defeats the purpose of this unification. I think it could still be worth adding a generic opaque_mma attribute so that plumbing through all possible intrinsics for a vendor doesn't have to blow up the enum set, assuming we don't want to jump straight to fully fledged non-opaque implementation, but makes sense to do that later as needed.
There was a problem hiding this comment.
Actually one other follow up, I see that the vulkan-target-env flag is being dropped, and only see a single WMMA type added here. Are the other (say WMMA_I8_16x16x16_I32) ones still targetable with IREE after this change?
There was a problem hiding this comment.
I think it could still be worth adding a generic opaque_mma attribute so that plumbing through all possible intrinsics for a vendor doesn't have to blow up the enum set, assuming we don't want to jump straight to fully fledged non-opaque implementation, but makes sense to do that later as needed.
Yeah. I'm trying to cut at a reasonable place for a few things as follow ups and don't want to use one commit to change the whole world. We can do that as a next step. I put an item in #16341.
Actually one other follow up, I see that the vulkan-target-env flag is being dropped, and only see a single WMMA type added here. Are the other (say WMMA_I8_16x16x16_I32) ones still targetable with IREE after this change?
It will fail support for i8 cases. We aren't supporting them anyway for Vulkan previously?
And I'm expecting we are gonna to add that on HIP side next for upcoming workloads so Vulkan picks it up "freely" anyway.
|
Okay all tests are passing so this is ready for reviews now.. |
| def MFMA_F16_32x32x8_F32 : I32EnumAttrCase<"MFMA_F16_32x32x8_F32", 1>; | ||
| // TODO: Create separate WMMA ops for AMD and NVIDIA GPUs | ||
| def WMMA_F16_16x16x16_F32 : I32EnumAttrCase<"WMMA_F16_16x16x16_F32", 2>; | ||
| def WMMA_F16_16x16x16_F16 : I32EnumAttrCase<"WMMA_F16_16x16x16_F16", 3>; |
There was a problem hiding this comment.
we can create separate ones for separate vendors, which makes sense because they are different layouts. so that's what I meant we want to create separate ones for nvidia in the comment. even though they are opaque in the vulkan side; they certainly have a hardware layout. for amd side, we know exactly what wmma layout are.
+1
| .Case("mi300x", "gfx942") | ||
| .Case("mi300a", "gfx940") |
There was a problem hiding this comment.
BTW, isn't this off? I thought that the final HW for mi300a and x use the same target triple?
There was a problem hiding this comment.
hmm, okay I didn't know that.. Are you sure about this?
There was a problem hiding this comment.
We can change that separately in another PR
|
|
||
| StringRef normalizeARMGPUTarget(StringRef target) { | ||
| if (target == "valhall") | ||
| return "valhall1"; |
There was a problem hiding this comment.
Yes. We don't have a formal established target naming scheme for arm (from llvm or something) so i'm just making it up for our own uses. Trying to be consistent here to use valhallN like rdnaN or cdnaN. If people give just valhall we default to the lowest level of support there.
qedawkins
left a comment
There was a problem hiding this comment.
Awesome cleanup! I will take a closer look tomorrow, but most of the removed code is outside what I have immediate context on, so I'm inclined to just approve it.
| @@ -8,13 +8,13 @@ | |||
| #include "iree/compiler/tool_entry_points_api.h" | |||
There was a problem hiding this comment.
What is the reason these changes are included as a part of this PR?
There was a problem hiding this comment.
There are some header include changes in other places caused this file filed to compile. So I fixed some header include issue. And along the way dropped the llvm:: prefix which isn't necessary given using namespace.
| def MFMA_F16_32x32x8_F32 : I32EnumAttrCase<"MFMA_F16_32x32x8_F32", 1>; | ||
| // TODO: Create separate WMMA ops for AMD and NVIDIA GPUs | ||
| def WMMA_F16_16x16x16_F32 : I32EnumAttrCase<"WMMA_F16_16x16x16_F32", 2>; | ||
| def WMMA_F16_16x16x16_F16 : I32EnumAttrCase<"WMMA_F16_16x16x16_F16", 3>; |
There was a problem hiding this comment.
Ok, I see your point. Agreed that excessive duplication is not wanted and somewhat defeats the purpose of this unification. I think it could still be worth adding a generic opaque_mma attribute so that plumbing through all possible intrinsics for a vendor doesn't have to blow up the enum set, assuming we don't want to jump straight to fully fledged non-opaque implementation, but makes sense to do that later as needed.
| static const WgpDetails valhallWgp = { | ||
| computeBitwdiths, allStorageBits, allSubgroupOps, allDotProductOps, | ||
| /*mmaCount=*/0, /*mmaOps=*/nullptr, {16}, {512, 512, 512}, | ||
| 512, 32 * 1024}; |
There was a problem hiding this comment.
What is the motivation behind the formatting here? I see the max threads per dim on the second line here, unlike about where it's on the third line (only commenting because I see clang-format off and trying to understand what this is trying to capture).
There was a problem hiding this comment.
Just trying to organize this a bit better to avoid spanning many lines.. No particular reasons. You can call this formating a bit personal taste though. :)
| def MFMA_F16_32x32x8_F32 : I32EnumAttrCase<"MFMA_F16_32x32x8_F32", 1>; | ||
| // TODO: Create separate WMMA ops for AMD and NVIDIA GPUs | ||
| def WMMA_F16_16x16x16_F32 : I32EnumAttrCase<"WMMA_F16_16x16x16_F32", 2>; | ||
| def WMMA_F16_16x16x16_F16 : I32EnumAttrCase<"WMMA_F16_16x16x16_F16", 3>; |
There was a problem hiding this comment.
Actually one other follow up, I see that the vulkan-target-env flag is being dropped, and only see a single WMMA type added here. Are the other (say WMMA_I8_16x16x16_I32) ones still targetable with IREE after this change?
|
This appears to have broken some benchmark builds: https://github.com/iree-org/iree/actions/runs/9572945480/job/26393626504#step:7:706 |
This reverts commit 7b9fb12.
Reverts #17623 This appears to have broken some benchmark builds.
This relands iree-org#17623. This commit switches SPIR-V side to use the common `#iree_gpu.target` to describe the GPU characteristics. With it we can now remove the ad-hoc Vulkan attributes and dialects and unify how GPU are described across various GPU compiler backends in IREE. SPIR-V has some additional requirements that we need to account for: We have many vendors and APIs to handle there so this commit adds various AMD/ARM/NVIDIA/Qualcomm targets for development purposes so that we can specify them with a shorthand. In order to be extensible, leverage the `feature` field in `#iree_gpu.target` to specify additional capabilities with `cap:` prefix and extensions with `ext:` prefix. We also use the `feature` field to specify what SPIR-V version to target with the `spirv:v1.x` format. Right now the `SPIRVConvertGPUTarget` pass is invoked immediately before configuration. This is to stage the changes. As a next step we need to move it immediately before `ConvertToSPIRV` pass. `--iree-vulkan-target-env` is dropped given now we removed the whole Vulkan dialect and cannot control with a `#vk.target_env` attribute anymore. The default `--iree-vulkan-target-triple` now becomes `vp_android_baseline_2022`, which is a a good lowest common denominator to guarantee the generated SPIR-V is widely accepted. We are not considering SwiftShader now anymore like previously due to testing purposes. The `--iree-vulkan-target-triple` should be renamed given it's not a triple anymore--that will happen later together with other GPU backends (i.e., cuda/hip) to be consistent. In order to support cooperative matrix conversion, we added `WMMA_F16_16x16x16_F16`. For NVIDIA GPUs we are abusing it right now without considering the concrete explicit layout--that is fine given in Vulkan they are opaque anyway. But this need to be fixed if we are targeting WMMA in CUDA. We now contruct a `#iree_gpu.target` to specify the target to drive SPIR-V CodeGen. Progress towards iree-org#16341 ci-extra: test_nvidia_gpu,test_nvidia_a100,test_amd_mi250, build_test_all_macos_arm64,build_and_test_android
This relands iree-org#17623. This commit switches SPIR-V side to use the common `#iree_gpu.target` to describe the GPU characteristics. With it we can now remove the ad-hoc Vulkan attributes and dialects and unify how GPU are described across various GPU compiler backends in IREE. SPIR-V has some additional requirements that we need to account for: We have many vendors and APIs to handle there so this commit adds various AMD/ARM/NVIDIA/Qualcomm targets for development purposes so that we can specify them with a shorthand. In order to be extensible, leverage the `feature` field in `#iree_gpu.target` to specify additional capabilities with `cap:` prefix and extensions with `ext:` prefix. We also use the `feature` field to specify what SPIR-V version to target with the `spirv:v1.x` format. Right now the `SPIRVConvertGPUTarget` pass is invoked immediately before configuration. This is to stage the changes. As a next step we need to move it immediately before `ConvertToSPIRV` pass. `--iree-vulkan-target-env` is dropped given now we removed the whole Vulkan dialect and cannot control with a `#vk.target_env` attribute anymore. The default `--iree-vulkan-target-triple` now becomes `vp_android_baseline_2022`, which is a a good lowest common denominator to guarantee the generated SPIR-V is widely accepted. We are not considering SwiftShader now anymore like previously due to testing purposes. The `--iree-vulkan-target-triple` should be renamed given it's not a triple anymore--that will happen later together with other GPU backends (i.e., cuda/hip) to be consistent. In order to support cooperative matrix conversion, we added `WMMA_F16_16x16x16_F16`. For NVIDIA GPUs we are abusing it right now without considering the concrete explicit layout--that is fine given in Vulkan they are opaque anyway. But this need to be fixed if we are targeting WMMA in CUDA. We now contruct a `#iree_gpu.target` to specify the target to drive SPIR-V CodeGen. Progress towards iree-org#16341 ci-extra: test_nvidia_gpu,test_nvidia_a100,test_amd_mi250, build_test_all_macos_arm64,build_and_test_android Signed-off-by: Lei Zhang <[email protected]>
This relands #17623. This commit switches SPIR-V side to use the common `#iree_gpu.target` to describe the GPU characteristics. With it we can now remove the ad-hoc Vulkan attributes and dialects and unify how GPU are described across various GPU compiler backends in IREE. SPIR-V has some additional requirements that we need to account for: We have many vendors and APIs to handle there so this commit adds various AMD/ARM/NVIDIA/Qualcomm targets for development purposes so that we can specify them with a shorthand. In order to be extensible, leverage the `feature` field in `#iree_gpu.target` to specify additional capabilities with `cap:` prefix and extensions with `ext:` prefix. We also use the `feature` field to specify what SPIR-V version to target with the `spirv:v1.x` format. Right now the `SPIRVConvertGPUTarget` pass is invoked immediately before configuration. This is to stage the changes. As a next step we need to move it immediately before `ConvertToSPIRV` pass. `--iree-vulkan-target-env` is dropped given now we removed the whole Vulkan dialect and cannot control with a `#vk.target_env` attribute anymore. The default `--iree-vulkan-target-triple` now becomes `vp_android_baseline_2022`, which is a a good lowest common denominator to guarantee the generated SPIR-V is widely accepted. We are not considering SwiftShader now anymore like previously due to testing purposes. The `--iree-vulkan-target-triple` should be renamed given it's not a triple anymore--that will happen later together with other GPU backends (i.e., cuda/hip) to be consistent. In order to support cooperative matrix conversion, we added `WMMA_F16_16x16x16_F16`. For NVIDIA GPUs we are abusing it right now without considering the concrete explicit layout--that is fine given in Vulkan they are opaque anyway. But this need to be fixed if we are targeting WMMA in CUDA. We now contruct a `#iree_gpu.target` to specify the target to drive SPIR-V CodeGen. Progress towards #16341 ci-extra: test_nvidia_gpu,test_nvidia_a100,test_amd_mi250, build_test_all_macos_arm64,build_and_test_android,test_on_moto-edge-x30 --------- Signed-off-by: Lei Zhang <[email protected]>
This commit switches SPIR-V side to use the common `#iree_gpu.target` to describe the GPU characteristics. With it we can now remove the ad-hoc Vulkan attributes and dialects and unify how GPU are described across various GPU compiler backends in IREE. #### SPIR-V SPIR-V has some additional requirements that we need to account for: We have many vendors and APIs to handle there so this commit adds various AMD/ARM/NVIDIA/Qualcomm targets for development purposes so that we can specify them with a shorthand. In order to be extensible, leverage the `feature` field in `#iree_gpu.target` to specify additional capabilities with `cap:` prefix and extensions with `ext:` prefix. We also use the `feature` field to specify what SPIR-V version to target with the `spirv:v1.x` format. Right now the `SPIRVConvertGPUTarget` pass is invoked immediately before configuration. This is to stage the changes. As a next step we need to move it immediately before `ConvertToSPIRV` pass. #### Vulkan `--iree-vulkan-target-env` is dropped given now we removed the whole Vulkan dialect and cannot control with a `#vk.target_env` attribute anymore. The default `--iree-vulkan-target-triple` now becomes `vp_android_baseline_2022`, which is a a good lowest common denominator to guarantee the generated SPIR-V is widely accepted. We are not considering SwiftShader now anymore like previously due to testing purposes. The `--iree-vulkan-target-triple` should be renamed given it's not a triple anymore--that will happen later together with other GPU backends (i.e., cuda/hip) to be consistent. In order to support cooperative matrix conversion, we added `WMMA_F16_16x16x16_F16`. For NVIDIA GPUs we are abusing it right now without considering the concrete explicit layout--that is fine given in Vulkan they are opaque anyway. But this need to be fixed if we are targeting WMMA in CUDA. #### Metal / WebGPU We now contruct a `#iree_gpu.target` to specify the target to drive SPIR-V CodeGen. Progress towards iree-org#16341 ci-extra: test_nvidia_gpu,test_nvidia_a100,test_amd_mi250, build_test_all_macos_arm64,build_and_test_android
) Reverts iree-org#17623 This appears to have broken some benchmark builds.
This commit switches SPIR-V side to use the common `#iree_gpu.target` to describe the GPU characteristics. With it we can now remove the ad-hoc Vulkan attributes and dialects and unify how GPU are described across various GPU compiler backends in IREE. #### SPIR-V SPIR-V has some additional requirements that we need to account for: We have many vendors and APIs to handle there so this commit adds various AMD/ARM/NVIDIA/Qualcomm targets for development purposes so that we can specify them with a shorthand. In order to be extensible, leverage the `feature` field in `#iree_gpu.target` to specify additional capabilities with `cap:` prefix and extensions with `ext:` prefix. We also use the `feature` field to specify what SPIR-V version to target with the `spirv:v1.x` format. Right now the `SPIRVConvertGPUTarget` pass is invoked immediately before configuration. This is to stage the changes. As a next step we need to move it immediately before `ConvertToSPIRV` pass. #### Vulkan `--iree-vulkan-target-env` is dropped given now we removed the whole Vulkan dialect and cannot control with a `#vk.target_env` attribute anymore. The default `--iree-vulkan-target-triple` now becomes `vp_android_baseline_2022`, which is a a good lowest common denominator to guarantee the generated SPIR-V is widely accepted. We are not considering SwiftShader now anymore like previously due to testing purposes. The `--iree-vulkan-target-triple` should be renamed given it's not a triple anymore--that will happen later together with other GPU backends (i.e., cuda/hip) to be consistent. In order to support cooperative matrix conversion, we added `WMMA_F16_16x16x16_F16`. For NVIDIA GPUs we are abusing it right now without considering the concrete explicit layout--that is fine given in Vulkan they are opaque anyway. But this need to be fixed if we are targeting WMMA in CUDA. #### Metal / WebGPU We now contruct a `#iree_gpu.target` to specify the target to drive SPIR-V CodeGen. Progress towards iree-org#16341 ci-extra: test_nvidia_gpu,test_nvidia_a100,test_amd_mi250, build_test_all_macos_arm64,build_and_test_android Signed-off-by: Lubo Litchev <[email protected]>
) Reverts iree-org#17623 This appears to have broken some benchmark builds. Signed-off-by: Lubo Litchev <[email protected]>
) This relands iree-org#17623. This commit switches SPIR-V side to use the common `#iree_gpu.target` to describe the GPU characteristics. With it we can now remove the ad-hoc Vulkan attributes and dialects and unify how GPU are described across various GPU compiler backends in IREE. SPIR-V has some additional requirements that we need to account for: We have many vendors and APIs to handle there so this commit adds various AMD/ARM/NVIDIA/Qualcomm targets for development purposes so that we can specify them with a shorthand. In order to be extensible, leverage the `feature` field in `#iree_gpu.target` to specify additional capabilities with `cap:` prefix and extensions with `ext:` prefix. We also use the `feature` field to specify what SPIR-V version to target with the `spirv:v1.x` format. Right now the `SPIRVConvertGPUTarget` pass is invoked immediately before configuration. This is to stage the changes. As a next step we need to move it immediately before `ConvertToSPIRV` pass. `--iree-vulkan-target-env` is dropped given now we removed the whole Vulkan dialect and cannot control with a `#vk.target_env` attribute anymore. The default `--iree-vulkan-target-triple` now becomes `vp_android_baseline_2022`, which is a a good lowest common denominator to guarantee the generated SPIR-V is widely accepted. We are not considering SwiftShader now anymore like previously due to testing purposes. The `--iree-vulkan-target-triple` should be renamed given it's not a triple anymore--that will happen later together with other GPU backends (i.e., cuda/hip) to be consistent. In order to support cooperative matrix conversion, we added `WMMA_F16_16x16x16_F16`. For NVIDIA GPUs we are abusing it right now without considering the concrete explicit layout--that is fine given in Vulkan they are opaque anyway. But this need to be fixed if we are targeting WMMA in CUDA. We now contruct a `#iree_gpu.target` to specify the target to drive SPIR-V CodeGen. Progress towards iree-org#16341 ci-extra: test_nvidia_gpu,test_nvidia_a100,test_amd_mi250, build_test_all_macos_arm64,build_and_test_android,test_on_moto-edge-x30 --------- Signed-off-by: Lei Zhang <[email protected]> Signed-off-by: Lubo Litchev <[email protected]>
This commit switches SPIR-V side to use the common
#iree_gpu.targetto describe the GPU characteristics.With it we can now remove the ad-hoc Vulkan attributes and
dialects and unify how GPU are described across various GPU
compiler backends in IREE.
SPIR-V
SPIR-V has some additional requirements that we need to
account for:
We have many vendors and APIs to handle there so this commit
adds various AMD/ARM/NVIDIA/Qualcomm targets for
development purposes so that we can specify them with
a shorthand.
In order to be extensible, leverage the
featurefield in#iree_gpu.targetto specify additional capabilities withcap:prefix and extensions withext:prefix. We alsouse the
featurefield to specify what SPIR-V version totarget with the
spirv:v1.xformat.Right now the
SPIRVConvertGPUTargetpass isinvoked immediately before configuration. This is to
stage the changes. As a next step we need to move
it immediately before
ConvertToSPIRVpass.Vulkan
--iree-vulkan-target-envis dropped given now weremoved the whole Vulkan dialect and cannot control with
a
#vk.target_envattribute anymore.The default
--iree-vulkan-target-triplenow becomesvp_android_baseline_2022, which is a a good lowestcommon denominator to guarantee the generated SPIR-V
is widely accepted. We are not considering SwiftShader
now anymore like previously due to testing purposes.
The
--iree-vulkan-target-tripleshould be renamedgiven it's not a triple anymore--that will happen later
together with other GPU backends (i.e., cuda/hip) to
be consistent.
In order to support cooperative matrix conversion, we
added
WMMA_F16_16x16x16_F16. For NVIDIA GPUswe are abusing it right now without considering the
concrete explicit layout--that is fine given in Vulkan
they are opaque anyway. But this need to be fixed if
we are targeting WMMA in CUDA.
Metal / WebGPU
We now contruct a
#iree_gpu.targetto specifythe target to drive SPIR-V CodeGen.
Progress towards #16341
ci-extra: test_nvidia_gpu,test_nvidia_a100,test_amd_mi250, build_test_all_macos_arm64,build_and_test_android