Hansung Kim
8d32a03d09
flash: Write DMA code for warp-specialized
...
TODO: result unverified
2024-09-07 20:32:08 -07:00
Hansung Kim
33bc084c37
flash: Fix DMA layout for GEMM II
2024-09-07 19:51:05 -07:00
Hansung Kim
e02892ab7d
flash: Fix DMA for up to GEMM II
...
yeah
2024-09-07 19:31:41 -07:00
Hansung Kim
d2f086344d
flash: Fix DMA addr stride, stop at S=Q*K
2024-09-07 15:48:37 -07:00
Hansung Kim
137df9bee2
WIP: flash: Use Gemmini DMA
...
Paused by the barrier bug in warp-divergent branches (tmask not being
considered)
2024-09-05 16:23:32 -07:00
Hansung Kim
bfb414c4eb
flash: Add DMA config logic
2024-09-05 16:23:32 -07:00
Hansung Kim
f028a97f75
sgemm_tcore: Verify wo DMA; warn untested against K-major A + DMA
2024-09-03 14:42:19 -07:00
Hansung Kim
70273fd00d
flash: Cleanup debug code
2024-09-02 00:40:05 -07:00
Hansung Kim
8125192846
flash: Specify leading_dim for split QK GEMM; fix uninit'd RF before GEMM
2024-09-02 00:15:57 -07:00
Hansung Kim
602fe4a400
flash: Change timing for QKV move
...
Verified with warp_specialized false; true remains to be fixed.
2024-09-01 22:06:46 -07:00
Hansung Kim
aea257349a
flash: Correct schedule with inter-warpgroup barriers
2024-09-01 20:40:51 -07:00
Hansung Kim
e5e65312d2
flash: Restructure to inter-warpgroup parallelism
...
This is similar to
https://tridao.me/blog/2024/flash3/#inter-warpgroup-overlapping-with-pingpong-scheduling
2024-09-01 19:58:33 -07:00
Hansung Kim
6cc1b5ca37
flash: Reduce smem_scratchpad alloc size
2024-09-01 16:02:06 -07:00
Hansung Kim
817cc9a5a5
flash: Fix overlap in smem alloc for P tile
2024-08-31 16:24:28 -07:00
Hansung Kim
bdd6e6a9ce
flash: Double-buffer between online softmax and GEMM II
...
TODO: O_after_PV at the last stage is incorrect.
2024-08-30 22:47:55 -07:00
Hansung Kim
042b47ff19
flash: Restructure for warp-specialization
2024-08-30 22:14:45 -07:00
Hansung Kim
1cfab40711
flash: Do Oi rescale with PV
...
Since Oi rescale has data dependency to previous Oi which gets produced
at the PV GEMM, both rescale+GEMM needs to be in a single pipeline stage
or otherwise it requires a stall. So instead, compute only the
rescale factor in the online softmax stage and apply rescaling right
before PV.
2024-08-30 20:11:07 -07:00
Hansung Kim
986d507223
flash: Fix single-tile GEMM for warp-specialized
...
With 4 warps, we can only do 32x64 GEMM; serialize 64x64 into 2 32x64
GEMM calls by split by the row.
2024-08-30 17:12:46 -07:00
Hansung Kim
72b6004e24
flash: Fix online softmax for warp-specialized
...
Note: now that threads_per_threadblock is passed as compile-time
constant, the compiler likes to completely loop unroll which can cause a
lot of stack spills.
todo fix GEMM part.
2024-08-29 21:50:02 -07:00
Hansung Kim
fd1ab358fa
flash: Add DOUBLE_BUF compile-time param (wip)
2024-08-29 14:18:56 -07:00
Hansung Kim
5ba06dfd9d
flash: Incomplete parallel stage-2 rowmax
2024-08-29 13:29:00 -07:00
Hansung Kim
3f20dd59c0
flash: Supply correct tile dims to single_tile
2024-08-20 19:50:45 -07:00
Hansung Kim
dde0372769
flash: Enable skipping Q*K for larger dimensions
2024-08-20 19:15:16 -07:00
Hansung Kim
615d36a5c2
flash: Reduce smem use for rowmax; verify result
2024-08-20 14:45:34 -07:00
Hansung Kim
d8d5df64e6
flash: Fix load addr for V tile; test with seqlen=128
2024-08-20 14:34:09 -07:00
Hansung Kim
df3c41aa0d
flash: data copy func for easy debugging
2024-08-19 21:41:37 -07:00
Hansung Kim
4080dec9d6
flash: Do exponential approx to rowsum and Oi as well
2024-08-19 20:52:57 -07:00
Hansung Kim
f6cc61241b
flash: 2nd-order taylor approx of exponential for P
2024-08-19 20:12:37 -07:00
Hansung Kim
64e48de8af
flash: Do accumulation of PV into O using the single_tile API
2024-08-19 18:08:58 -07:00
Hansung Kim
a98da9e3ca
flash: Add missing accum reg init and fix barrier count
2024-08-19 16:15:46 -07:00
Hansung Kim
1e042af571
flash: Write and verify O = O + PV step
2024-08-19 13:18:27 -07:00
Hansung Kim
b44b202a21
sgemm_impl: Rename to wmma
2024-08-18 16:21:22 -07:00
Hansung Kim
90f6effa97
flash: Pass smem_P arg to softmax func
2024-08-18 15:21:05 -07:00
Hansung Kim
d3de1b674a
flash: Compute exponents using prev/next/this rowmax values
...
maybe there is a better way than storing all three in sharedmem?
2024-08-15 22:10:02 -07:00
Hansung Kim
be08204e65
flash: Do proper allocation and init of QK/V/O tile
2024-08-15 21:26:14 -07:00
Hansung Kim
0ea27dd15a
flash: gitignore
2024-08-15 21:04:59 -07:00
Hansung Kim
e0daf226ef
flash: Change kernel arg to contain qkv; strip stimulus gen from host code
...
test data is now generated by the python script instead of the host
binary.
2024-08-15 21:03:02 -07:00
Hansung Kim
ac44633b39
flash: Compile time flag for skipping GEMM
2024-08-15 17:40:32 -07:00
Hansung Kim
f844d96eea
flash: Initialize rowmax/rowsum cache in sharedmem
2024-08-15 17:28:36 -07:00
Hansung Kim
745aa098ed
flash: Optimize spad use, fix rowsum
2024-08-15 16:54:56 -07:00
Hansung Kim
e809d25305
flash: Fix rowsum and write fake exp
...
GEMM part is disabled for faster debugging, the kernel reads the result
of A*B directly from input binary.
2024-08-15 16:32:21 -07:00
Hansung Kim
53dfc690b9
flash: Allocate smem properly for rowsum and scratch
2024-08-14 21:50:20 -07:00
Hansung Kim
9cabe3413b
Fix overlapping smem in rowmax
2024-08-14 21:09:53 -07:00
Hansung Kim
692d028afd
Add flash attention kernel skeleton
2024-08-14 20:46:09 -07:00