Commit b2a8efd
authored
refactor: Simplify Tauri plugin calls and update 'FA' setting (#6779)
* refactor: Simplify Tauri plugin calls and enhance 'Flash Attention' setting
This commit introduces significant improvements to the llama.cpp extension, focusing on the 'Flash Attention' setting and refactoring Tauri plugin interactions for better code clarity and maintenance.
The backend interaction is streamlined by removing the unnecessary `libraryPath` argument from the Tauri plugin commands for loading models and listing devices.
* **Simplified API Calls:** The `loadLlamaModel`, `unloadLlamaModel`, and `get_devices` functions in both the extension and the Tauri plugin now manage the library path internally based on the backend executable's location.
* **Decoupled Logic:** The extension (`src/index.ts`) now uses the new, simplified Tauri plugin functions, which enhances modularity and reduces boilerplate code in the extension.
* **Type Consistency:** Added `UnloadResult` interface to `guest-js/index.ts` for consistency.
* **Updated UI Control:** The 'Flash Attention' setting in `settings.json` is changed from a boolean checkbox to a string-based dropdown, offering **'auto'**, **'on'**, and **'off'** options.
* **Improved Logic:** The extension logic in `src/index.ts` is updated to correctly handle the new string-based `flash_attn` configuration. It now passes the string value (`'auto'`, `'on'`, or `'off'`) directly as a command-line argument to the llama.cpp backend, simplifying the version-checking logic previously required for older llama.cpp versions. The old, complex logic tied to specific backend versions is removed.
This refactoring cleans up the extension's codebase and moves environment and path setup concerns into the Tauri plugin where they are most relevant.
* feat: Simplify backend architecture
This commit introduces a functional flag for embedding models and refactors the backend detection logic for cleaner implementation.
Key changes:
- Embedding Support: The loadLlamaModel API and SessionInfo now include an isEmbedding: boolean flag. This allows the core process to differentiate and correctly initialize models intended for embedding tasks.
- Backend Naming Simplification (Refactor): Consolidated the CPU-specific backend tags (e.g., win-noavx-x64, win-avx2-x64) into generic *-common_cpus-x64 variants (e.g., win-common_cpus-x64). This streamlines supported backend detection.
- File Structure Update: Changed the download path for CUDA runtime libraries (cudart) to place them inside the specific backend's directory (/build/bin/) rather than a shared lib folder, improving asset isolation.
* fix: compare
* fix mmap settings and adjust flash attention
* fix: correct flash_attn and main_gpu flag checks in llamacpp extension
Previously the condition for `flash_attn` was always truthy, causing
unnecessary or incorrect `--flash-attn` arguments to be added. The
`main_gpu` check also used a loose inequality which could match values
that were not intended. The updated logic uses strict comparison and
correctly handles the empty string case, ensuring the command line
arguments are generated only when appropriate.1 parent 7b634f0 commit b2a8efd
File tree
7 files changed
+71
-95
lines changed- extensions/llamacpp-extension
- src
- src-tauri/plugins/tauri-plugin-llamacpp
- guest-js
- src
- gguf
7 files changed
+71
-95
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
152 | | - | |
| 152 | + | |
153 | 153 | | |
154 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
155 | 160 | | |
156 | 161 | | |
157 | 162 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
| 105 | + | |
110 | 106 | | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
| 107 | + | |
115 | 108 | | |
116 | 109 | | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
| 110 | + | |
121 | 111 | | |
122 | | - | |
| 112 | + | |
123 | 113 | | |
124 | 114 | | |
125 | 115 | | |
126 | 116 | | |
127 | 117 | | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
| 118 | + | |
132 | 119 | | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
| 120 | + | |
139 | 121 | | |
140 | 122 | | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
| 123 | + | |
147 | 124 | | |
148 | | - | |
| 125 | + | |
149 | 126 | | |
150 | 127 | | |
151 | 128 | | |
| |||
230 | 207 | | |
231 | 208 | | |
232 | 209 | | |
233 | | - | |
234 | | - | |
235 | 210 | | |
236 | | - | |
237 | 211 | | |
238 | 212 | | |
239 | 213 | | |
| |||
265 | 239 | | |
266 | 240 | | |
267 | 241 | | |
268 | | - | |
| 242 | + | |
269 | 243 | | |
270 | 244 | | |
271 | 245 | | |
| |||
274 | 248 | | |
275 | 249 | | |
276 | 250 | | |
277 | | - | |
| 251 | + | |
278 | 252 | | |
279 | 253 | | |
280 | 254 | | |
| |||
344 | 318 | | |
345 | 319 | | |
346 | 320 | | |
347 | | - | |
348 | | - | |
| 321 | + | |
| 322 | + | |
349 | 323 | | |
350 | 324 | | |
351 | 325 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| 46 | + | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| |||
69 | 71 | | |
70 | 72 | | |
71 | 73 | | |
72 | | - | |
| 74 | + | |
73 | 75 | | |
74 | 76 | | |
75 | 77 | | |
| |||
549 | 551 | | |
550 | 552 | | |
551 | 553 | | |
552 | | - | |
553 | | - | |
554 | | - | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
555 | 557 | | |
556 | 558 | | |
557 | 559 | | |
| |||
1644 | 1646 | | |
1645 | 1647 | | |
1646 | 1648 | | |
1647 | | - | |
| 1649 | + | |
1648 | 1650 | | |
| 1651 | + | |
| 1652 | + | |
| 1653 | + | |
| 1654 | + | |
| 1655 | + | |
| 1656 | + | |
| 1657 | + | |
1649 | 1658 | | |
1650 | 1659 | | |
1651 | 1660 | | |
1652 | | - | |
1653 | | - | |
1654 | | - | |
1655 | | - | |
1656 | | - | |
1657 | 1661 | | |
1658 | | - | |
| 1662 | + | |
1659 | 1663 | | |
1660 | 1664 | | |
1661 | 1665 | | |
| |||
1667 | 1671 | | |
1668 | 1672 | | |
1669 | 1673 | | |
1670 | | - | |
| 1674 | + | |
1671 | 1675 | | |
1672 | 1676 | | |
1673 | 1677 | | |
| |||
1688 | 1692 | | |
1689 | 1693 | | |
1690 | 1694 | | |
1691 | | - | |
1692 | 1695 | | |
1693 | 1696 | | |
1694 | | - | |
1695 | | - | |
1696 | | - | |
1697 | | - | |
1698 | | - | |
1699 | | - | |
1700 | | - | |
1701 | | - | |
1702 | | - | |
1703 | | - | |
1704 | | - | |
| 1697 | + | |
1705 | 1698 | | |
1706 | 1699 | | |
1707 | 1700 | | |
| |||
1717 | 1710 | | |
1718 | 1711 | | |
1719 | 1712 | | |
1720 | | - | |
1721 | | - | |
1722 | | - | |
1723 | | - | |
1724 | | - | |
1725 | | - | |
| 1713 | + | |
1726 | 1714 | | |
1727 | 1715 | | |
1728 | 1716 | | |
| |||
2042 | 2030 | | |
2043 | 2031 | | |
2044 | 2032 | | |
2045 | | - | |
| 2033 | + | |
| 2034 | + | |
| 2035 | + | |
| 2036 | + | |
2046 | 2037 | | |
2047 | 2038 | | |
2048 | 2039 | | |
| |||
2082 | 2073 | | |
2083 | 2074 | | |
2084 | 2075 | | |
2085 | | - | |
| 2076 | + | |
| 2077 | + | |
| 2078 | + | |
| 2079 | + | |
2086 | 2080 | | |
2087 | 2081 | | |
2088 | 2082 | | |
| |||
Lines changed: 18 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
10 | 17 | | |
11 | 18 | | |
12 | 19 | | |
| |||
29 | 36 | | |
30 | 37 | | |
31 | 38 | | |
32 | | - | |
33 | | - | |
34 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
35 | 42 | | |
36 | 43 | | |
37 | 44 | | |
38 | | - | |
39 | 45 | | |
40 | | - | |
| 46 | + | |
| 47 | + | |
41 | 48 | | |
42 | 49 | | |
43 | 50 | | |
44 | | - | |
| 51 | + | |
45 | 52 | | |
46 | 53 | | |
47 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | 44 | | |
46 | 45 | | |
47 | 46 | | |
| |||
52 | 51 | | |
53 | 52 | | |
54 | 53 | | |
55 | | - | |
| 54 | + | |
56 | 55 | | |
57 | 56 | | |
58 | 57 | | |
| |||
83 | 82 | | |
84 | 83 | | |
85 | 84 | | |
86 | | - | |
| 85 | + | |
87 | 86 | | |
88 | 87 | | |
89 | 88 | | |
90 | | - | |
| 89 | + | |
91 | 90 | | |
92 | 91 | | |
93 | 92 | | |
| |||
280 | 279 | | |
281 | 280 | | |
282 | 281 | | |
283 | | - | |
284 | 282 | | |
285 | 283 | | |
286 | | - | |
| 284 | + | |
287 | 285 | | |
288 | 286 | | |
289 | 287 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | 22 | | |
24 | 23 | | |
25 | 24 | | |
26 | 25 | | |
27 | | - | |
| 26 | + | |
28 | 27 | | |
29 | 28 | | |
30 | | - | |
| 29 | + | |
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
35 | | - | |
| 34 | + | |
36 | 35 | | |
37 | 36 | | |
38 | 37 | | |
| |||
410 | 409 | | |
411 | 410 | | |
412 | 411 | | |
413 | | - | |
| 412 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
66 | 65 | | |
67 | 66 | | |
68 | 67 | | |
| |||
0 commit comments