mlboydaisuke commited on
Commit
7fae5be
·
verified ·
1 Parent(s): 4517956

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +77 -0
README.md ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ tags:
4
+ - executorch
5
+ - xnnpack
6
+ - pte
7
+ - on-device
8
+ - automatic-speech-recognition
9
+ base_model:
10
+ - openai/whisper-small
11
+ ---
12
+ # Whisper-small — ExecuTorch (encoder + decoder)
13
+
14
+ Speech recognition in two `.pte` files: the encoder runs once per 30-second window, the
15
+ decoder once per generated token. Putting them in one graph would re-encode the audio on
16
+ every step.
17
+
18
+ | graph | build | file | size (MB) | corr vs fp32 eager | ms | eager ms |
19
+ |---|---|---|---|---|---|---|
20
+ | encoder | XNNPACK fp32 | `whisper_small_encoder_xnnpack_fp32.pte` | 352.8 | 1.000000 | 357.4 | 144.7 |
21
+ | encoder | XNNPACK fp16 | `whisper_small_encoder_xnnpack_fp16.pte` | 180.5 | 1.000000 | 619.5 | 144.4 |
22
+ | encoder | XNNPACK int8 | `whisper_small_encoder_xnnpack_int8.pte` | 98.3 | 0.998973 | 333.2 | 144.1 |
23
+ | encoder | Core ML | `whisper_small_encoder_coreml_all.pte` | 176.8 | 0.999942 | 95.5 | 143.4 |
24
+ | decoder | XNNPACK fp32 | `whisper_small_decoder_xnnpack_fp32.pte` | 774.0 | 1.000000 | 91.2 | 55.3 |
25
+ | decoder | XNNPACK fp16 | `whisper_small_decoder_xnnpack_fp16.pte` | 387.3 | 0.999994 | 188.6 | 55.3 |
26
+ | decoder | Core ML | `whisper_small_decoder_coreml_all.pte` | 307.6 | 0.999863 | 13.7 | 55.6 |
27
+
28
+ Every file takes and returns fp32 tensors (token ids stay int64), so any encoder pairs with
29
+ any decoder. The lightest working pair is 405.9 MB.
30
+
31
+ - **Source**: [openai/whisper-small](https://huggingface.co/openai/whisper-small)
32
+ - **License**: Apache-2.0
33
+ - **Encoder input**: log-mel spectrogram `[1, 80, 3000]` — 30 s at 16 kHz, 80 mel bins, hop
34
+ 160, window 400, exactly what `WhisperFeatureExtractor` produces
35
+ - **Decoder input**: the encoder output plus `decoder_input_ids [1, 128]` int64,
36
+ left-aligned and padded. Start with `<|startoftranscript|>`, a language token,
37
+ `<|transcribe|>`, `<|notimestamps|>`.
38
+
39
+ ## Decoding
40
+
41
+ No KV cache: the decoder is a static graph over a fixed 128-token window, so a greedy step
42
+ is take `argmax` of row `len-1`, append it, run again. Stop at `<|endoftext|>` (50257). 128
43
+ tokens covers a 30-second window of ordinary speech; past that, start a new window.
44
+
45
+ That costs a full 128-position forward pass per token, which is the price of a static graph
46
+ that runs unchanged across runtimes and precisions.
47
+
48
+ ## Verification (Mac arm64, executorch 1.4.0, torch 2.13.0)
49
+
50
+ The two wrappers compose back to `WhisperForConditionalGeneration` exactly — max_abs_diff
51
+ **0.000e+00** — and every graph matches torch fp32 eager at the correlations above. Timings
52
+ are medians over 5 runs in one process: a relative reference, not a device number.
53
+
54
+ ## Two things worth knowing about the sizes
55
+
56
+ **The decoder `.pte` is larger than the decoder's weights.** Whisper ties `proj_out.weight`
57
+ to `decoder.embed_tokens.weight`, but the two uses need different representations: an
58
+ embedding table the portable kernels index into, and the same values packed into the XNNPACK
59
+ delegate's blob for the output matmul. Tying them in PyTorch does not tie them here.
60
+ Referencing the weight through `F.linear` instead of the `proj_out` module does not either —
61
+ exported both ways, whisper-tiny's decoder comes out at 198.0 MB exactly.
62
+
63
+ **The decoder has no int8 build.** PT2E puts an observer on the int64 `decoder_input_ids`
64
+ feeding the token embedding, and the lookup then refuses a float index (`tensors used as
65
+ indices must be long, int, byte or bool`). The encoder takes float mel and quantizes without
66
+ complaint, which is where the size is worth taking anyway.
67
+
68
+ ## Conversion
69
+
70
+ ```bash
71
+ python convert/export_whisper.py small
72
+ ```
73
+
74
+ The ExecuTorch tree ships a single-graph Whisper example under `examples/models/whisper`;
75
+ this is that model with the halves separated.
76
+
77
+ (conversion scripts: [executorch-models](https://github.com/john-rocky/executorch-models))