Skip to content
New issue

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

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

Already on GitHub? # to your account

POC for Buffer Descriptor Analysis #569

Closed
wants to merge 3 commits into from

Conversation

jamestclin
Copy link

@jamestclin jamestclin commented Aug 7, 2023

This draft shows an implementation of an analysis for generating Buffer Descriptors.

  • Problem formulation:
    • Input:
      • LinAlg IR converted from Triton IR by --triton-to-linalg conversion pass
      • Make dynamic strides/sizes from function argument to constant strides/sizes in arith.constant (task 3.2.1., this is done manually at the moment)
    • Output:
      • Buffer descriptor with constant length/steps/wraps, and dynamic base (base pointer address, a function of program_id)
  • Proposed method in high-level:
    • Analysis is done by visiting all the memref.copy/memref.tensor_store in the function and recursively call visitor functions for operands until reaching memref.reinterpretcast.
    • Buffer descriptor is propagated from memref.reinterpretcast to memref.copy/memref.tensor_store by recursion of visitor functions.
  • Able to handle tasks 3.2.2. and 3.2.3. for triton tutorials:
    • add vector, softmax, and layernorm
    • matmul (works for various group sizes)
    • fused attention (only works for full attention that comes with constant for-loop tripcount. The original tutorial example is masked attention where the tripcount is dynamic to the program_id)
  • Known limitation:
    • Memory block size masking/padding is skipped
    • Multiple load of a tensor in a single for loop iteration isn't supported
    • For-loop has to have constant tripcount to infer the BD for task 3.2.3.
    • Haven't looked into the case of nested for-loop

// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// (c) Copyright 2023 Xilinx Inc.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Advanced Micro Devices, Inc.

Copy link
Author

Choose a reason for hiding this comment

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

Will update the name here. Also, git checks show errors regarding clang formatting, and compilation warning. Will fix them as well.

// (c) Copyright 2023 Xilinx Inc.
//
//===----------------------------------------------------------------------===//

Copy link
Collaborator

Choose a reason for hiding this comment

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

What does this do? Is it really specific to your target, or is it more general?

Copy link
Author

Choose a reason for hiding this comment

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

It's more to the target. Any suggestion on where this header file should live?

@makslevental makslevental marked this pull request as ready for review November 27, 2023 20:42
@makslevental makslevental marked this pull request as draft November 27, 2023 20:42
@stephenneuendorffer
Copy link
Collaborator

@jamestclin What's the status with this?

@jamestclin
Copy link
Author

Close this PR for now, as the POC isn't in the current pursuit.

@jamestclin jamestclin closed this Nov 30, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants