Commit 8a9cb75
Breeze encoder chunked vram (#431)
* breeze: chunk the speech-encoder conv stack to bound clone VRAM
The encoder graph was built at the exact reference-audio length, so conv
activations grew linearly (~45 MiB/s of reference) and every new length
triggered a full graph rebuild; a 60 s reference cost ~2.5 GB extra over
a 6 s one.
Split the encoder into two graphs. The conv stack now runs on fixed 5 s
chunks (120000 samples) preceded by a 9600-sample left overlap that covers
the stack's exact 5240-sample receptive field; chunk lengths are multiples
of the 960x transformer stride, so no per-stage right padding occurs and the
discarded overlap frames absorb the zero left pads that represent audio
start in the first chunk. Stitched outputs are bit-identical to a
single-pass encode of the same input (verified over 68 frames x 16
codebooks). The transformer, downsample, and projections run once over the
full frame sequence at frame scale, where even minute-long references cost
only tens of MiB.
Measured on a 2080 Ti (Vulkan, native q8_0 GGUF, peak minus idle baseline):
the VRAM slope over reference length drops from ~45 MiB/s to ~11 MiB/s
(remaining slope is the frame-scale transformer graph and the longer AR
prefill from reference codes), and a 60 s reference peaks ~1.4 GB lower.
Encode time for 60 s improves from 3561 ms to 2197 ms.
* breeze: bucket speech-encoder transformer graph capacity
The transformer graph was rebuilt at the exact frame count for every
distinct reference length. Round the capacity up to 125-frame (5 s) buckets
so lengths within a bucket share one graph. Unused bucket frames are
replicate-padded to match the downsample conv's Replicate right pad; causal
attention keeps padding frames invisible to real frames. Verified
bit-identical reference codes vs exact-length graphs at 6 s and 15 s; odd
lengths show sub-1% last-frame diffs from flash-attention tiling, the same
accepted noise class as the pre-existing length sensitivity. Single-run peak
VRAM is unchanged.
* ggml-vulkan, breeze: fused round-to-bf16 unary op on Vulkan
Vulkan previously paid a cast round trip (f32->bf16->f32, two kernels, a
bf16 intermediate tensor) at every activation-rounding point of the breeze
decoder. Add a round_bf16 compute shader (f32/f16/bf16 in, always f32 out,
round-to-nearest-even via the same fp32_to_bf16 bit trick the cpy shaders
use), register pipelines indexed by source type, handle the widened f32 dst
in the unary pipeline selection and op-support checks, and enable
fused_round for Vulkan in the breeze activation-cast policy.
Verified bit-identical breeze reference codes vs the cast round trip at 6 s
and 15 s references. Peak VRAM on a 2080 Ti drops ~250 MiB at a 60 s
reference (5491 -> 5239 MiB); no measurable change at 6 s.
* ggml-vulkan: handle row-strided inputs in fused round-to-bf16
The breeze activation-rounding policy admits row-strided views into
ggml_round_bf16 (ggml_is_contiguous_rows gate in qwen_decoder). The
Vulkan port dispatched every input to the flat shader, which indexes the
source as a contiguous array, so row-strided views read garbage and
clone output degenerated into noise. Route non-contiguous inputs to a
new round_bf16_strided shader built on generic_unary_head (same pattern
as sigmoid_strided), keeping the flat fast path for contiguous inputs.1 parent ff38f15 commit 8a9cb75
7 files changed
Lines changed: 319 additions & 51 deletions
File tree
- external/ggml/src/ggml-vulkan
- vulkan-shaders
- include/engine/models/breeze_tts
- src/models/breeze_tts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
811 | 811 | | |
812 | 812 | | |
813 | 813 | | |
| 814 | + | |
| 815 | + | |
814 | 816 | | |
815 | 817 | | |
816 | 818 | | |
| |||
4750 | 4752 | | |
4751 | 4753 | | |
4752 | 4754 | | |
| 4755 | + | |
| 4756 | + | |
| 4757 | + | |
| 4758 | + | |
| 4759 | + | |
| 4760 | + | |
| 4761 | + | |
| 4762 | + | |
| 4763 | + | |
4753 | 4764 | | |
4754 | 4765 | | |
4755 | 4766 | | |
| |||
9740 | 9751 | | |
9741 | 9752 | | |
9742 | 9753 | | |
| 9754 | + | |
| 9755 | + | |
| 9756 | + | |
| 9757 | + | |
| 9758 | + | |
| 9759 | + | |
| 9760 | + | |
| 9761 | + | |
| 9762 | + | |
| 9763 | + | |
| 9764 | + | |
| 9765 | + | |
| 9766 | + | |
9743 | 9767 | | |
9744 | 9768 | | |
9745 | 9769 | | |
| |||
11481 | 11505 | | |
11482 | 11506 | | |
11483 | 11507 | | |
| 11508 | + | |
| 11509 | + | |
| 11510 | + | |
| 11511 | + | |
| 11512 | + | |
11484 | 11513 | | |
11485 | 11514 | | |
11486 | 11515 | | |
| |||
13522 | 13551 | | |
13523 | 13552 | | |
13524 | 13553 | | |
| 13554 | + | |
| 13555 | + | |
| 13556 | + | |
| 13557 | + | |
| 13558 | + | |
| 13559 | + | |
| 13560 | + | |
13525 | 13561 | | |
13526 | 13562 | | |
13527 | 13563 | | |
| |||
15772 | 15808 | | |
15773 | 15809 | | |
15774 | 15810 | | |
| 15811 | + | |
| 15812 | + | |
| 15813 | + | |
15775 | 15814 | | |
15776 | 15815 | | |
15777 | 15816 | | |
| |||
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
880 | 880 | | |
881 | 881 | | |
882 | 882 | | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
883 | 889 | | |
884 | 890 | | |
885 | 891 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
49 | | - | |
| 50 | + | |
| 51 | + | |
50 | 52 | | |
51 | 53 | | |
52 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
64 | | - | |
65 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| |||
0 commit comments