You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In BreezeTTS 2, the depth decoder executes 15 autoregressive codebook steps for every audio frame (codebooks 1 through 15). At 12.5 frames per second, this results in 187.5 depth decoding iterations per second of audio. Because depth decoding represents ~60% of total inference time, reducing per-step overhead significantly improves generation latency and throughput.
Identified Bottlenecks in src/models/breeze_tts/generator.cpp (dev branch)
Multiple Graph Computations and Syncs per Step:
Each codebook step executes separate graph dispatches:
depth_projection->logits_cfg() (head_graphs_[codebook - 1] linear projection)
project_audio_embedding_row() (projector_single_ linear projection)
Each separate graph calls compute_backend_graph() and ggml_backend_synchronize(), multiplying synchronization and dispatch overhead.
Per-Step Heap Allocator Churn:
In generate_frame(), each of the 15 steps performs multiple heap allocations:
project_audio_embedding_row() allocates embedding vector and run_graph() allocates output.
logits_cfg() allocates input, run_graph() allocates output, and logits_cfg() allocates out for CFG combination.
next_pair, cond_hidden_now, and uncond_hidden_now allocate and reassign vectors dynamically each step.
Proposed Optimization Strategy
Persistent Staging & Scratch Buffers (Immediate / High Impact):
Add pre-allocated member scratch buffers (input_staging_, output_staging_, combined_logits_) inside BreezeDepthProjectionRuntime and BreezeGeneratorRuntime::Impl.
Pass existing buffers or views to run_graph and logits_cfg to perform readbacks and CFG combinations completely in-place without vector allocations.
Pre-allocate cond_hidden_now, uncond_hidden_now, and next_pair in Impl.
Benchmark Results in Reference Port:
In Breeze-TTS-2.cpp, eliminating per-step context and staging heap churn dropped depth decode time from 60.60 ms/frame to 50.47 ms/frame on CPU (~17% speedup) with zero numeric deviation.
We are preparing a PR targeting dev to implement the pre-allocated staging optimization for src/models/breeze_tts/generator.cpp.
Activity