TTS on OpenVINO
· 14 min read

Qwen3-TTS on OpenVINO: Talker, Subcode and streaming decode

Contents
  1. RVQ codebooks within one audio frame
  2. Separating Talker, Subcode and decoder graphs
  3. Streaming chunk sizes

This export separates the long-context Talker, within-frame Subcode prediction and chunked waveform decoder. It gives the first audio chunk a smaller decoding window than steady output. Read the complexity discussion as a model of these different workloads, not a benchmark: one cached decoding step, total sequence work and memory capacity are different quantities.

RVQ codebooks within one audio frame

At a 12 Hz cadence, the model emits an audio frame. This frame is not a scalar token. It is a multi-codebook codec frame: a vertical stack of discrete codebook tokens that collectively represent a time-slice of acoustic waveform. A downstream vocoder/codec translates this stream into raw PCM audio.

Neural audio codecs rely on residual vector quantization (RVQ), a concept introduced in SoundStream (Zeghidour et al., 2021) which iteratively quantizes the residual signal, forming the basis of multi-codebook frames. Let the latent vector be xx, and qjq_j be the codeword from codebook jj. Codebook ii quantizes the residual:

ri  =  x  −  ∑j<iqj,r_i \;=\; x \;-\; \sum_{j<i} q_j,

The first codebook (r1=xr_1 = x) captures the coarse structure. The subsequent codebooks refine the error. Reconstruction is the sum x^=∑iqi\hat{x} = \sum_{i} q_i. With QQ codebooks of VV entries, a frame holds Qlog⁡2VQ \log_2 V bits. This rigid ordering dictates the compute distribution: I spend heavy autoregressive machinery on the primary first codebook, and a cheap, cached greedy loop on the remaining refinements. The coarse-then-fine token modeling was heavily validated by AudioLM (Borsos et al., 2022), confirming that the first token is load-bearing.

Separating Talker, Subcode and decoder graphs

I split generation into three stages to separate their compute requirements.

+-----------------------+       +-----------------------+       +-----------------------+
|  Talker Seed Graph    |       | Cached Subcode Graph  |       |   Decoder Stream      |
|  (Paged-KV Attention) |------>| (Greedy Fill)         |------>|   (Chunked Context)   |
|  O(n^2 d)             |       | O(Q d)                |       |   O(1) continuous     |
+-----------------------+       +-----------------------+       +-----------------------+
           |                               ^                               |
           v                               |                               v
  1st Codebook + Hidden State   Rest of the codebooks               PCM Waveform

The talker graph executes long-context autoregressive attention over the entire sequence history to produce the first codebook and a hidden state. This is the O(n2)O(n^2) component. At frame nn, it attends over nn prior positions. The total cost is O(n2d)O(n^2 d). This graph intrinsically requires a KV cache to collapse the recompute to O(n)O(n). I exported this as the seed graph in qwen3_tts_ov/exporter.py, leaving KV-cache parameters dynamic so the OpenVINO C++ backend can inject PagedAttention operations via AST rewrites.

# Exporting the grouped-query attention seed
input_shapes = [
    ov.PartialShape([-1, 1, config.hidden_size]),
    ov.PartialShape([3, -1, 1]),
    ov.PartialShape([-1, 1, 1, -1]),
    ov.PartialShape([-1]),
    # GQA: exporting the fewer KV heads to shrink cache size
    *[ov.PartialShape([1, kv_heads, -1, head_dim]) for _ in range(config.num_hidden_layers * 2)],
]
ov_model = ov.convert_model(wrapper.eval(), example_input=example_inputs, input=input_shapes)

The subcode_greedy_cached graph fills the remaining codebooks 2…Q2 \dots Q. Conditioned strictly on the talker’s hidden state, it executes a greedy loop. It does not attend over previous audio frames, but SubcodeGreedyCachedWrapper does maintain a bounded cache within the current frame. Its cost is O(Q⋅d)O(Q \cdot d), strictly constant in nn. In the exporter, I wired a loop over int(config.num_code_groups) - 1 heads. Splitting this out keeps the O(n)O(n) KV-cache work out of a loop that is O(1)O(1) in temporal context.

The streaming decoder is a convolutional/transformer hybrid that ingests chunks of completed frames to emit PCM audio. It maintains a bounded left-context window, ignoring distant history.

By cutting the model precisely at the boundaries where the computational shape changes, each subgraph compiles into an intermediate representation (IR) that the hardware scheduler can map optimally. OpenVINO allocates block tables for the talker, a static loop for the subcode, and a rolling buffer for the decoder.

Streaming chunk sizes

The decoder exports embed their chunking schedule directly into their filenames:

path = out_dir / f"speech_decoder_stream_c{left_context_frames}_t{chunk_frames}.xml"

A profile like c25_t12 enforces 25 frames of left-context and emits chunks of 12 tokens. The first chunk uses a different graph: c0_t8. I export a distinct, smaller graph with zero left-context and an 8-token width to minimize the time-to-first-audio (TTFA). The production build configures these precisely in qwen3_tts_ov/build_fastest.py.

Once these graphs can run independently, Paged-KV allocation and continuous batching determine how concurrent streams share them.

llmttsopenvinocodecarchitecture

Comments