Luigi commited on
Commit
1079080
·
verified ·
1 Parent(s): b0143c1

Correct the memory figures and record the optimization results

Browse files

The 241 MB RssAnon here is a decode-only number; the full pipeline peaks at 645 MB
warm, and the encoder's activations (+399 MB per 10 s window) are the largest
single consumer. End-to-end RTF on a Boox Tab Mini C went 6.28 -> 2.24 with the
transcript byte-identical throughout.

Files changed (1) hide show
  1. README.md +43 -0
README.md CHANGED
@@ -61,6 +61,45 @@ worst case for int8 SIMD. Back to back against the ggml build of the same model:
61
  Parity on speed at **half the unevictable memory**, which is the figure that
62
  decides whether an Android app survives memory pressure.
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  ## Fidelity
65
 
66
  | stage | vs reference | note |
@@ -77,6 +116,10 @@ per-channel scales beat the single per-tensor scale I8_S uses.
77
 
78
  * The encoder window is **fixed at 10 s**; longer audio must be windowed by the
79
  caller. Convolutions are causal, so a window needs left context and no lookahead.
 
 
 
 
80
  * The decoder graphs are **context-specific** — a ctx=128 prefill cannot be paired
81
  with a ctx=512 decode.
82
  * The **chat template is mandatory**. Feeding audio features without the surrounding
 
61
  Parity on speed at **half the unevictable memory**, which is the figure that
62
  decides whether an Android app survives memory pressure.
63
 
64
+ Those memory figures are **decode only**. Through the full pipeline on Android,
65
+ peak RssAnon is 906 MB: 173 MB of runtime/harness baseline, +55 MB compiling the
66
+ encoder, +231 MB compiling the head, +46 MB for the decoder graphs and their
67
+ 330 MB of weights (fully zero-copy — 330.1 MB mmap'd, 0.0 MB copied), and
68
+ **+399 MB of encoder activations**. The front end, not the BitNet decoder,
69
+ dominates memory as well as time.
70
+
71
+ Note also that XNNPACK's `weight_cache_file_path` fails **silently** if the path
72
+ is not writable — no error, no warning, weights packed into anonymous memory
73
+ instead, and peak RssAnon goes 906 MB to 1552 MB. Check the file exists after
74
+ compiling.
75
+
76
+ End to end through an Android app, 60 s of English in 10 s windows, every pair
77
+ measured back to back on one device:
78
+
79
+ | | RTF | wall |
80
+ |---|---:|---:|
81
+ | first working version | 6.28 | 377 s |
82
+ | + big-core pinning before graph compile | 4.95 | 297 s |
83
+ | + idle GEMM workers park instead of spinning | 3.42 | 205 s |
84
+ | + wide encoder mask, batched prompt remainder | 3.23 | 194 s |
85
+ | + chat-prefix KV reused across windows | 2.93 | 176 s |
86
+ | + pause-snapped windows and a silence gate | **2.24** | **134 s** |
87
+
88
+ **2.8x, transcript byte-identical at every step.** Only the last row processes
89
+ less audio; the rest is the same work done properly.
90
+
91
+ Per 10 s window the budget is encode 14.6 s, prefill 10.3 s, decode 7.7 s. The
92
+ audio front end — **not** the BitNet part — is the largest single cost. Dropping
93
+ one of its two tokenizer encoders would halve it and does not work: the acoustic
94
+ and semantic branches are nearly orthogonal (cos 0.0435) and comparable in
95
+ magnitude, so each carries a large share of the summed features the decoder was
96
+ trained on.
97
+
98
+ BitNet shrinks the decoder's weights 4x, but on an ARMv8.0 core with no dotprod
99
+ the ternary kernel is compute-bound, so that reduction buys memory rather than
100
+ speed. Decode runs 212-249 ms/token against a ~124 ms floor set by streaming
101
+ 328 MB of 2-bit weights; the LM head is only 42-46 ms/token of it.
102
+
103
  ## Fidelity
104
 
105
  | stage | vs reference | note |
 
116
 
117
  * The encoder window is **fixed at 10 s**; longer audio must be windowed by the
118
  caller. Convolutions are causal, so a window needs left context and no lookahead.
119
+ Widening it is not the free win it looks like: 30 s windows cut prompt tokens 25%
120
+ and the encoder is linear in window length, but its activations are not free —
121
+ peak RssAnon went 937 MB to 1739 MB and a 3.7 GB device killed the process
122
+ mid-decode.
123
  * The decoder graphs are **context-specific** — a ctx=128 prefill cannot be paired
124
  with a ctx=512 decode.
125
  * The **chat template is mandatory**. Feeding audio features without the surrounding