Commit 4b48a53
authored
server : optimize get_token_probabilities (ggml-org#24796)
Use std::partial_sort to order only the requested top-n tokens instead
of the full vocabulary
logprobs sort: vocab=128000 n_top=0 iters=100
full sort: 8555.6 us/op
partial sort: 704.3 us/op
Signed-off-by: Adrien Gallouët <angt@huggingface.co>1 parent e475fa2 commit 4b48a53
3 files changed
Lines changed: 27 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
1238 | 1239 | | |
1239 | 1240 | | |
1240 | 1241 | | |
1241 | | - | |
| 1242 | + | |
1242 | 1243 | | |
1243 | 1244 | | |
1244 | 1245 | | |
| |||
1257 | 1258 | | |
1258 | 1259 | | |
1259 | 1260 | | |
1260 | | - | |
1261 | | - | |
1262 | | - | |
1263 | | - | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
1264 | 1271 | | |
1265 | 1272 | | |
1266 | | - | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
1267 | 1281 | | |
1268 | | - | |
1269 | | - | |
1270 | | - | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
1271 | 1285 | | |
1272 | 1286 | | |
1273 | | - | |
1274 | | - | |
| 1287 | + | |
| 1288 | + | |
1275 | 1289 | | |
1276 | 1290 | | |
1277 | 1291 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
326 | 326 | | |
327 | 327 | | |
328 | 328 | | |
329 | | - | |
| 329 | + | |
330 | 330 | | |
331 | 331 | | |
332 | 332 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1824 | 1824 | | |
1825 | 1825 | | |
1826 | 1826 | | |
1827 | | - | |
1828 | | - | |
| 1827 | + | |
1829 | 1828 | | |
1830 | 1829 | | |
1831 | 1830 | | |
| |||
0 commit comments