Skip to content

[Example] add flashattention in example and modify ci test - #564

Closed
RuizeYu05 wants to merge 7 commits into
cornell-zhang:mainfrom
RuizeYu05:feat-implement-flashattention-using-allo
Closed

RuizeYu05 wants to merge 7 commits into
cornell-zhang:mainfrom
RuizeYu05:feat-implement-flashattention-using-allo

Conversation

@RuizeYu05

@RuizeYu05 RuizeYu05 commented Mar 6, 2026 •

Copy link
Copy Markdown

Description

I add the example of implementing flash attention using allo and modify the CI test to support the testing of my flash attention kernel.

Problems

Implementing flash attention using allo

Proposed Solutions

Add an example to the application of allo

Examples

Checklist

Please make sure to review and check all of these items:

  • PR's title starts with a category (e.g. [Bugfix], [IR], [Builder], etc)
  • All changes have test coverage (It would be good to provide ~2 different test cases to test the robustness of your code)
  • Pass the formatting check locally
  • Code is well-documented

@chhzh123

chhzh123 commented Mar 6, 2026

Copy link
Copy Markdown
Member

Thanks for your PR! I think you also need to update the requirements.txt. Check out the CI error

@RuizeYu05

Copy link
Copy Markdown
Author

Yeah I'm currently fixing it.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a FlashAttention example kernel implemented in Allo and wires it into CI so the example is exercised during PR runs.

Changes:

  • Added a FlashAttention Allo schedule/kernel implementation (get_scheduled_flash_attention).
  • Added a Python testbench that builds/runs the kernel and compares against a NumPy golden reference.
  • Updated GitHub Actions workflow to execute the FlashAttention testbench.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
examples/flashattention/test_flash.py Testbench that computes a golden attention output and validates the Allo-generated kernel (plus optional Vitis HLS synthesis).
examples/flashattention/flash_Atten.py Allo implementation/schedule for a tiled FlashAttention-style attention computation.
.github/workflows/config.yml Adds a CI step to run the FlashAttention testbench.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread examples/flashattention/test_flash.py
Comment thread examples/flashattention/test_flash.py Outdated
Comment thread examples/flashattention/test_flash.py Outdated
Comment thread examples/flashattention/flash_Atten.py
Comment thread examples/flashattention/flash_Atten.py Outdated
Comment thread .github/workflows/config.yml

@chhzh123 chhzh123 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you fix Copilot's suggestions (if they are valid)? Also, it'd be good to attach your performance results in the PR description

Comment thread examples/flashattention/flash_Atten.py
Comment thread examples/flashattention/test_flash.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Public parameter validation and unconditional HLS code-generation coverage need correction.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)

Comment thread examples/flashattention/test_flash.py

@Fangtangtang Fangtangtang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hi @RuizeYu05, sorry for the very delayed review.
Shall we put falshattention in this PR and MHA in #581 under the same directory named "attention"? It would also be great to add a README under this directory describing the kernels (e.g., algorithm/dataflow/performance results).
Also, the current CI only runs the simulator. Could you add this example to .github/workflows/fpga_weekly.yml to enable tests on hls?

Comment thread .github/workflows/config.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants