commit | bb542eee65fa0a498963df1f2ee2f205a3dd8bd0 | [log] [tgz] |
---|---|---|
author | Stanley Winata <68087699+raikonenfnu@users.noreply.github.com> | Thu Oct 31 16:56:00 2024 -0700 |
committer | GitHub <noreply@github.com> | Thu Oct 31 16:56:00 2024 -0700 |
tree | 47f50e3aa6b9e57d5bff0a363fade09019f89bdf | |
parent | 20c83470b4186944e14c67488d295f3f0f33ecce [diff] |
[LLVMGPU] Add Virtual MFMA layout that maximizes load through adjusted K-width (#18930) The main use case for the virtual intrinsics are to change the layout of intrinsics in K-dimension, such that we can coalesce reads from shared memory to register. Currently, the "native" intrinsics need to enforce the "native" layout (i.e read 4 element per thread for MFMA_F32_16x16x16), however since we know that K-dim is a reduction dimension which is associative, we can read the data in non "native"/"correct" but "faster"/"more elements per read" way but as long as we match the K-dim on both lhs and rhs we will still get correct results (i.e read 8 contiguous element per thread from shared memory along dimension K for and then slice them into two MFMA_F32_16x16x16)). an IR example for this is if we want to do a 16x16x32(MxNxK) matmul with MFMA_F32_16x16x16_F16 intrinsics, on lane 0 we used to have something like: ``` lhs_0 = read(lhs_shared_mem[0:4]) rhs_0 = read(rhs_shared_mem[0:4]) mma_0 = vector.contract(lhs_0, rhs_0) (16 offset since MFMA_F32_16x16x16xF16 has intrinsic K size of 16) lhs_1 = read(lhs_shared_mem[16 + 0: 16 + 4]) rhs_1 = read(rhs_shared_mem[16 + 0 : 16 + 4]) mma_1 = vector.contract(lhs_1, rhs_1, mma_0) ``` With this optimization, we will turn into something like: ``` lhs_reg = read(lhs_shared_mem[0:8]) rhs_reg = read(rhs_shared_mem[0:8]) lhs_0 = slice(lhs_reg, [0 : 4]) rhs_0 = slice(rhs_reg, [0 : 4]) mma_0 = vector.contract(lhs_0, rhs_0) lhs_1 = slice(lhs_reg, [4 : 8]) rhs_1 = slice(rhs_reg, [4 : 8]) mma_1 = vector.contract(lhs_0, rhs_0, mma_0) ``` Currently, we are plumbing it in as MMA intrinsic enums for two variants of unrolled k == 2 on the F16s(per discussion with @qedawkins and @Groverkss ), as they are the easiest and non tangly way to integrate/plumb through. all though in the future we can expose this attribute as k-width for maximizing generability. --------- Signed-off-by: Stanley Winata <stanley.winata@amd.com>
IREE (Intermediate Representation Execution Environment, pronounced as “eerie”) is an MLIR-based end-to-end compiler and runtime that lowers Machine Learning (ML) models to a unified IR that scales up to meet the needs of the datacenter and down to satisfy the constraints and special considerations of mobile and edge deployments.
See our website for project details, user guides, and instructions on building from source.
IREE is still in its early phase. We have settled down on the overarching infrastructure and are actively improving various software components as well as project logistics. It is still quite far from ready for everyday use and is made available without any support at the moment. With that said, we welcome any kind of feedback on any communication channels
Package | Release status |
---|---|
GitHub release (stable) | |
GitHub release (nightly) | |
Python iree-compiler | |
Python iree-runtime |
Host platform | Build status |
---|---|
Linux | |
macOS | |
Windows |
For the full list of workflows see https://iree.dev/developers/general/github-actions/.
See our website for more information.
Community meeting recordings: IREE YouTube channel
IREE is licensed under the terms of the Apache 2.0 License with LLVM Exceptions. See LICENSE for more information.