Commit af620a1
authored
feat: flash attention support for hexagon-npu (#45)
* add flash attn op
* expend src tensor size
* add flash attn sources
* add quantize row functions
* make a separated file for vec_dot
* wip
* wip
* refactor: rename quants.hpp includes and add vec_dot to type traits
* add flash_attn impl
* split vec_scale_f32
* move vec_reduction_qf32 to vec_ops
* add vec_scale_f16
* opt
* add vec_mad
* implement vec_mad_f16
* opt
* add op template
* opt
* add align version
* enable flash attn
* wip
* log print improve
* add profiler log
* wip
* wip
* add multi sub proc perf tracker
* increase log buffer
* remove sub prov pcycle
* wip
* wip
* add prefetch for vec_dot
* wip
* wip
* opt f16 vec dot
* opt f16 vecdot
* reuse vec_dot_product_impl in vec dot f32
* small opt to unblock pipeline
* opt on aligned address
wip
* Revert "opt on aligned address"
This reverts commit 27be1eb.
* add profiler log at thread_pool
* wip
* invalidate all...
* Reapply "opt on aligned address"
This reverts commit f075a4c.
* add is_constant for tensor config
* disable align tensor opt in mul_mat
* wip
* wip
* vec_scale_impl: unrolling the loop
* wip
* wip
* replace reinterpret_cast with direct pointer access for write/read buffers
* add fetch
* wip
* wip
* wip
* add log
* check tensor shape at flash_attn
* wip
* wip
* fix: update tensor type handling in flash_attn_impl
* wip
* fix: align cache size
* fix: qf16->hf
* fix: swap order of elements in vector combine for correct scaling
* fix: opt f16 scale and mad
* fix leftover fetch
* wip
* load into vector pair
* opt cache size calculation in flash_attn_impl
* refactoring: hold vtcm at thread local object
* wip
* add profiler log
* mark tensors as modified
* restrict tensor invalidation to the first thread in compute_impl
* Revert "restrict tensor invalidation to the first thread in compute_impl"
This reverts commit 0a8ff2b.
* invalidate last tensor in compute_impl
* invalidate last tensor in compute function
* wip
* refactor dequantize_row_q4_0 to simplify vector alignment
* wip
* refactoring: move VTCM quota calculation to thread pool
* wip
* fix: correct condition check for HEXAGON_SDK_ROOT existence
* wip
* wip
* wip
* wip
* fix: update condition checks match the naming
* fix: improve tensor handling checks and logging in graph and operation implementations
* wip1 parent da5dc57 commit af620a1
File tree
27 files changed
+1860
-801
lines changed- ggml/src/ggml-qnn
- npu
- device
- host
- idl
27 files changed
+1860
-801
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
132 | | - | |
133 | | - | |
| 131 | + | |
| 132 | + | |
134 | 133 | | |
135 | 134 | | |
136 | | - | |
| 135 | + | |
137 | 136 | | |
138 | 137 | | |
139 | 138 | | |
140 | 139 | | |
141 | | - | |
| 140 | + | |
142 | 141 | | |
143 | 142 | | |
144 | 143 | | |
| |||
208 | 207 | | |
209 | 208 | | |
210 | 209 | | |
211 | | - | |
212 | | - | |
| 210 | + | |
213 | 211 | | |
214 | 212 | | |
215 | 213 | | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
221 | 220 | | |
222 | 221 | | |
223 | 222 | | |
| 223 | + | |
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
| 13 | + | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
| |||
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
23 | | - | |
| 22 | + | |
24 | 23 | | |
25 | 24 | | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
56 | 60 | | |
57 | 61 | | |
| 62 | + | |
58 | 63 | | |
59 | 64 | | |
60 | 65 | | |
61 | 66 | | |
62 | | - | |
63 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
64 | 70 | | |
65 | 71 | | |
66 | | - | |
67 | | - | |
| 72 | + | |
| 73 | + | |
68 | 74 | | |
69 | 75 | | |
70 | 76 | | |
| |||
78 | 84 | | |
79 | 85 | | |
80 | 86 | | |
81 | | - | |
82 | | - | |
83 | 87 | | |
84 | 88 | | |
| 89 | + | |
| 90 | + | |
85 | 91 | | |
86 | 92 | | |
87 | | - | |
88 | 93 | | |
89 | 94 | | |
90 | 95 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
28 | | - | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
0 commit comments