Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reland "[spirv] Switch to use common target description" #17699

Merged
merged 8 commits into from
Jun 20, 2024

Conversation

antiagainst
Copy link
Contributor

@antiagainst antiagainst commented Jun 19, 2024

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

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 <antiagainst@gmail.com>
Signed-off-by: Lei Zhang <antiagainst@gmail.com>
@antiagainst antiagainst added the benchmarks:android-gpu Run default Android GPU benchmarks label Jun 19, 2024
Copy link

github-actions bot commented Jun 19, 2024

Abbreviated Benchmark Summary

@ commit 8291dfe5797d4cc41a29cfc2c8ac1c701e05be7c (vs. base 7c410492bdcbfdd4972de827d995bfb8482841a5)

Regressed Latencies 🚩

Benchmark Name Average Latency (ms) Median Latency (ms) Latency Standard Deviation (ms)
MobileBertSquad\_int8(tflite) [arm-valhall-vulkan\_android31-vulkan\_spirv][default-flags] vulkan(none)[full-inference,default-flags] with default @ pixel-6-pro[gpu] 97.672 (vs. 85.114, 14.76%↑) 97.240 0.872
MobileBertSquad\_fp16(tflite) [arm-valhall-vulkan\_android31-vulkan\_spirv][experimental-flags,fuse-padding,max-concurrency,demote-f32-to-f16] vulkan(none)[full-inference,default-flags] with default @ pixel-6-pro[gpu] 102.534 (vs. 95.119, 7.80%↑) 102.345 3.090

No improved or regressed compilation metrics 🏖️

For more information:

Source Workflow Run

Signed-off-by: Lei Zhang <antiagainst@gmail.com>
Signed-off-by: Lei Zhang <antiagainst@gmail.com>
@MacDue
Copy link
Member

MacDue commented Jun 19, 2024

(typo in PR title Raland -> Reland)

@ScottTodd ScottTodd changed the title Raland "[spirv] Switch to use common target description" Reland "[spirv] Switch to use common target description" Jun 19, 2024
This reverts commit 13328fb.

Signed-off-by: Lei Zhang <antiagainst@gmail.com>
Signed-off-by: Lei Zhang <antiagainst@gmail.com>
@antiagainst
Copy link
Contributor Author

@ScottTodd @kuhar this should be good now--android tests and benchmarks are fixed.

.git-blame-ignore-revs Outdated Show resolved Hide resolved
This reverts commit e1d881f.

Signed-off-by: Lei Zhang <antiagainst@gmail.com>
Copy link
Collaborator

@ScottTodd ScottTodd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment, otherwise LGTM

Signed-off-by: Lei Zhang <antiagainst@gmail.com>
@antiagainst
Copy link
Contributor Author

Looks test_amd_mi250 is just stuck there. That was fine in the previous patch already; so I'll just land this for now.

@ScottTodd
Copy link
Collaborator

Looks test_amd_mi250 is just stuck there. That was fine in the previous patch already; so I'll just land this for now.

That runner went offline for maintenance yeah.

@ScottTodd ScottTodd merged commit 90f29a6 into iree-org:main Jun 20, 2024
56 of 57 checks passed
@antiagainst antiagainst deleted the reland-vulkan-target branch June 20, 2024 02:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
benchmarks:android-gpu Run default Android GPU benchmarks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants