Add packet-switched flash attention programming example#1532
Draft
erwei-xilinx wants to merge 1 commit into
Draft
Add packet-switched flash attention programming example#1532erwei-xilinx wants to merge 1 commit into
erwei-xilinx wants to merge 1 commit into
Conversation
Recover the original packet-switched flash attention design as a standalone example. This design uses dma_packet channels to time-multiplex Q and K data through shared compute tile S2MM DMA channels via hardware packet routing in the stream switch. Channel routing: L2ToL1Chan1 (Q): dma_packet — broadcast to all compute tiles L2ToL1Chan2 (K): dma_packet — broadcast to all compute tiles L2ToL1Chan3 (V): dma_stream — circuit-switched per cascade stage Includes both NPU2 (AIE2P, attn.py + attn_pkt.cc) and NPU1 (AIE2, attn_npu1.py + attn_npu1.cc) variants. The NPU1 variant reuses the kernel from kernel_fusion_based with k-major B-block indexing and adapted DMA layouts for mmul<4,8,4>. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
programming_examples/flash_attention/packet_switched/channel_type="dma_packet"for Q and K routing through shared compute tile S2MM DMA channels, demonstrating hardware packet routing in the stream switchChannel routing
L2ToL1Chan1(Q)dma_packetL2ToL1Chan2(K)dma_packetL2ToL1Chan3(V)dma_streamFiles
attn.py+attn_pkt.ccattn_npu1.py+attn_npu1.ccMakefilerun-npu1) and NPU2 (run)run_npu1_makefile_peano.litrun_npu2_makefile_peano.litTest plan
make run-npu1with defaults LK=512 LKP=64 LQ=512 LQP=256 DK=64 NUM_HEADS=2)make runwith same defaults)dma_packetchannel declarations in generated MLIR viamake print/make print-npu1🤖 Generated with Claude Code