Repository navigation
Commit 2c984cf
perf: Flash Next reads a prompt chunk's n-gram rows on 16 threads, same bytes
HostTable.gather copied a prompt's n-gram rows with one fancy index per file, so rows whose pages were not in the
page cache were read from disk one page fault at a time. On a DGX Spark with a 131,072-token cache the ~31 GB tables
barely fit in the page cache, and how much of them the start-up prefetch leaves cached varies from start to start.
A gather of 1,024 rows or more (a prompt chunk of 64 tokens or more) now copies on up to 16 threads, 512 rows or
more each. numpy's fancy indexing releases the GIL, so the page faults overlap: staging costs about 0.07 ms a fault
instead of 0.25 ms. Decode steps keep the single-threaded copy. The bytes are the same.
One Spark, 131,072-token cache, default 2,048-row chunks, a fresh process each with the n-gram files dropped from
the page cache before it (the start-up prefetch refills what fits), release and branch alternated, every prompt new
text: 606 tokens 0.37-0.55 -> 0.36-0.42 s, 1,118 tokens 0.56-0.73 -> 0.55-0.59 s, 4,186 tokens 1.95-2.31 ->
1.92-1.97 s, 8,192 tokens 3.65-4.29 -> 3.60-3.70 s, 32,768 tokens 15.1-16.5 -> 15.1-15.2 s, 120,000 tokens
65.4-65.7 -> 64.7-65.3 s. Decode unchanged.
Checked: the threaded copy is byte-identical to the single-threaded one (new test, and 1,000 to 131,072 random rows
of the real table); teacher-forced NLL through the prompt and the decode path identical to the release on all
119,980 values; 55 replayed benchmark replies byte-identical; drafted vs serial 9/9; needles 9/9.1 parent b4042e8 commit 2c984cf
2 files changed
Lines changed: 41 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
16 | 23 | | |
17 | 24 | | |
18 | 25 | | |
| |||
61 | 68 | | |
62 | 69 | | |
63 | 70 | | |
| 71 | + | |
| 72 | + | |
64 | 73 | | |
65 | 74 | | |
66 | 75 | | |
| |||
77 | 86 | | |
78 | 87 | | |
79 | 88 | | |
80 | | - | |
81 | | - | |
82 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
83 | 92 | | |
84 | 93 | | |
85 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
86 | 106 | | |
87 | 107 | | |
88 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
108 | 126 | | |
109 | 127 | | |
110 | 128 | | |
| |||
0 commit comments