The architecture of Qwen3-TTS-12Hz: two summed streams, 16 codes per 80 millisecond frame, 2.10 B parameters
A read of the Qwen3-TTS-12Hz checkpoint from its safetensors headers rather than its model card, covering the talker, the 15 step depth predictor, and the RVQ decoder that turns 2.2 kbit per second of codes back into 24 kHz audio.

On this page
Audio edition
0:00 / 25:34
Ready
The configuration file shipped with the 1.7 B checkpoint of Qwen3-TTS-12Hz declares a semantic codebook of 4,096 entries, and every semantic codebook tensor in the checkpoint is 2,048 rows deep. It configures a three section multimodal rotary embedding that the reference implementation builds from a single position index, so the multimodal part collapses to ordinary rotary embedding before it reaches the attention scores. The name says 1.7 billion and the headers add up to 2.10 billion.
I found all three while porting the model to Rust for a book narrator, by reading tensor shapes before writing any model code. What follows is the architecture as the checkpoint describes itself, with parameter counts taken from safetensors headers and codebook statistics read out of the weights.
Glossary
Every term below appears later with a specific meaning in this model, so the definitions are narrowed to this model rather than left general.
Frame. One 80 millisecond slice of audio, described by 16 integer codes. The model produces 12.5 of them per second.
Code. One integer in the range 0 to 2,047, an index into a codebook. Sixteen of them describe one frame.
Codebook. A learned table of 2,048 vectors, each 256 numbers wide. A code is looked up in it to recover a vector.
Residual vector quantisation, or RVQ. Sixteen codebooks applied in sequence, each one describing what the sum of the previous ones failed to capture, so the first carries the coarsest information and the sixteenth the finest.
Semantic and acoustic codebooks. The split in this model is 1 semantic and 15 acoustic, held in two separate quantiser stacks whose outputs are added.
Talker. The 28 layer transformer that reads text and emits codebook 0, one code per frame.
Depth predictor. The 5 layer transformer that fills codebooks 1 to 15 for a frame the talker has already started. The reference code calls it the sub-talker.
Codec decoder. The convolutional stack, with a transformer inside it, that turns 16 codes per frame into 1,920 waveform samples per frame.
Autoregressive. Each step conditions on the output of the previous step, so steps cannot be run at the same time. Both transformers above are autoregressive.
Prefill and decode. Prefill runs the prompt through a transformer in one pass, and decode advances one position at a time afterwards. Prefill is parallel over positions and decode is not.
Key value cache. The stored keys and values of every position already processed, so a decode step attends to history without recomputing it. One position costs 229,376 bytes at float32 here, from 28 layers holding 8 key value heads of 128 numbers, twice.
Grouped query attention. Several query heads share one key and value head. The talker has 16 query heads over 8 key value heads, which halves the cache.
Rotary position embedding. Position is encoded by rotating pairs of numbers inside each attention head by an angle proportional to the position. The base is 1,000,000 in the talker and the depth predictor, and 10,000 in the decoder’s transformer.
QK normalisation. Queries and keys are normalised across the head dimension, before the rotation, using a learned weight per head dimension. The talker and the depth predictor use it and the decoder’s transformer does not.
RMSNorm. Normalisation by root mean square with no mean subtraction and no bias, the norm used throughout the two language stacks.
LayerScale. A learned per channel weight applied to a residual branch before it is added back. Present only in the decoder’s transformer.
Sliding window attention. Attention restricted to the most recent positions rather than all of them. The decoder’s transformer uses a window of 72 frames, which is 5.76 seconds, and both other stacks attend to everything.
Causal convolution. A convolution padded only on the left, so an output sample depends on earlier input and never on later input. Every convolution in the decoder is causal.
Transposed convolution. A convolution run in reverse to increase the sample rate, producing as many output samples per input sample as its stride. Six of them raise 12.5 Hz to 24 kHz.
Dilation. The gap between the input samples a convolution kernel reads. Dilations of 1, 3 and 9 in successive residual units widen the receptive field without more parameters.
ConvNeXt block. A depthwise convolution, a layer normalisation, and a widening then narrowing pointwise pair, scaled and added back as a residual.
SnakeBeta. The activation used in the waveform stack. It adds to its input a periodic term, the
square of the sine of the input scaled by exp(alpha), divided by exp(beta) plus a small
constant, with both parameters learned per channel and stored as logarithms. The periodicity is what
lets a convolutional stack produce a pitched signal.
x-vector. A fixed length vector summarising a speaker’s voice, 2,048 numbers wide here, produced by an ECAPA-TDNN speaker encoder.
In context learning. Conditioning by example: the reference clip’s own codes and transcript are placed in the prompt, so the model continues in that voice rather than being told about it.
Logits. The unnormalised scores over a vocabulary, one per candidate code, that sampling converts into a choice.
Top-k, top-p and temperature. Sampling controls: keep the k highest scoring candidates, keep the smallest set whose probability sums to p, and flatten or sharpen the distribution before drawing.
Real time factor. Computation time divided by audio duration. A factor of 0.5 means one second of speech costs half a second of computation, and lower is better.
Quantisation. Storing weights in fewer bits than they were trained in. The q8_0 format here is
one byte per parameter with a shared scale for every block of 32.
The frame
Everything in the model is organised around a frame of 80 milliseconds. At a 24 kHz output rate that is 1,920 samples, and the decoder’s six upsampling stages multiply out to exactly that figure: two stages of 2, then 8, 5, 4 and 3. The frame rate of 12.5 Hz is where the name comes from, and it is half the 25 Hz of CosyVoice3, which halves the number of autoregressive steps needed per second of speech and is the main reason a model of 2.10 B parameters runs faster than a 995 M model on the same laptop.
Sixteen codes describe a frame, each an index into a codebook of 2,048 entries, so a frame is 176 bits and the code stream is 2,200 bits per second. The 24 kHz signed 16 bit audio it expands into is 384,000 bits per second, a compression of 175 times, and the entire acoustic burden of the model is carried across that gap by learned codebooks rather than by the code stream.
The frame is also the clock for text. One text token is consumed per frame, which fixes the ratio between input and output at 12.5 tokens per second of audio and makes segmentation behave differently from a model that consumes its text first and generates afterwards.
What the checkpoint contains
Two files hold everything: model.safetensors in bfloat16 for the language side, and
speech_tokenizer/model.safetensors in float32 for the codec. Grouped by tensor prefix from the
headers rather than from the model card, the components divide as follows.
| component | parameters |
|---|---|
| talker trunk, 28 layers | 1,409,408,000 |
| text embedding table, 151,936 by 2,048 | 311,164,928 |
| depth predictor, all parts | 175,125,760 |
| codec decoder, the part inference runs | 114,323,137 |
| codec encoder, never run at inference | 56,234,304 |
| speaker encoder, ECAPA-TDNN | 12,001,088 |
| talker codec embedding and output head | 12,582,912 |
| text projection | 8,388,608 |
| norms and biases | 6,144 |
| total | 2,099,234,881 |
The published 1.7 B counts the trunk and its embedding tables and stops there. Two entries in that table never take part in synthesis: the codec encoder exists because the file is a full audio tokeniser rather than a decoder, and the speaker encoder runs once per voice, offline, to produce an x-vector that is then stored alongside the reference clip.
The depth predictor divides further, and the division is where its cost comes from. Its five transformer layers hold 78.7 million parameters and its fifteen output heads 31.5 million, with the exact counts below.
| part | parameters |
|---|---|
| five transformer layers | 78,654,720 |
| fifteen codebook embedding tables | 62,914,560 |
| fifteen output heads | 31,457,280 |
| projection into predictor width | 2,097,152 |
The five layer stack is read fifteen times per frame and each output head once, so the predictor moves 1.18 GB of weights per frame at one byte per parameter while holding under a tenth of the trunk’s parameters.
The talker and its two streams
The talker is a Qwen3 decoder of ordinary shape, and the differences from the Qwen2 stacks in neighbouring speech models are small enough to pass a shape check while changing the output.
| property | value |
|---|---|
| hidden width | 2,048 |
| layers | 28 |
| query heads | 16 |
| key value heads | 8 |
| head width | 128 |
| feed forward width | 6,144 |
| normalisation | RMSNorm, epsilon 1e-6 |
| rotary base | 1,000,000 |
| attention biases | none |
| QK normalisation | yes, before the rotation |
| attention span | full causal, no sliding window |
Queries and keys are normalised per head before rotation, using a learned weight of 128 numbers each, which neither of the two models I ported before this one has. The attention projections carry no bias, while the text projection carries one, so a single rule applied to the whole checkpoint drops two bias vectors and still loads.
Two vocabularies meet inside the talker. Text arrives through a 151,936 row embedding table and a two layer projection with a SiLU between its halves, both halves 2,048 by 2,048. Codes arrive through a separate 3,072 row table, of which rows 0 to 2,047 are real codes and the remainder are control tokens: padding at 2,148, beginning at 2,149, end at 2,150, and a think or nothink pair above those. The ten language tags occupy 2,050 to 2,071 in that same control range. The output head is 3,072 by 2,048 and predicts codebook 0 only, with the top 1,024 rows suppressed during generation apart from the end token, so a control identifier cannot be emitted as though it were a code.
The two streams are added, not concatenated. Every position the talker attends over is the sum of a text hidden state and a codec embedding, which is the single design decision the rest of the model follows from. A position advances both streams at once, so text is consumed at exactly one token per frame and the model has no separate encoder pass over the sentence.
The prompt is assembled in that summed form. The codec stream opens with a think tag, the language identifier and a think end tag, followed by the speaker x-vector occupying one position, then padding and a beginning token. Over the same positions the text stream carries padding, ending with its own beginning token, and the two are added everywhere except the last codec position, which is left free for the first content.
In context cloning fills that position and many after it. The text side becomes the reference clip’s transcript followed by the target text and an end token, while the codec side becomes a beginning token followed by one embedding per frame of the reference clip, each of those embeddings itself the sum of the frame’s 16 codebook lookups. The two are added position by position, and whichever runs longer spills into a trailing buffer that the decode loop consumes one position per frame. A ten second reference clip therefore adds 125 positions to the prompt and to the key value cache, which is why prefill cost tracks the reference rather than the sentence.
The x-vector itself comes from an ECAPA-TDNN speaker encoder in the same file, whose final projection is 2,048 wide, matching the talker’s hidden width exactly. The 0.6 B variant of this model has a 1,024 wide talker and a 1,024 wide speaker projection, which is the one place the two sizes differ structurally rather than by scale. Because the embedding is consumed as a single position, the encoder can be run once per voice and never loaded again.
The depth predictor and the per-frame loop
The talker produces one code per frame and the frame needs sixteen, so a second transformer fills the rest. It is five layers at 1,024 wide with the same 16 query heads over 8 key value heads, the same QK normalisation, and a head width of 128, which is where its shape stops being derivable. Sixteen heads of 128 is 2,048, not the 1,024 hidden width, and the query projection in the checkpoint is 2,048 by 1,024 to match. Dividing width by head count gives 64, every subsequent shape still divides, and the model runs while attending over the wrong axis.
Fifteen output heads of 2,048 by 1,024 produce the fifteen residual codes, and fifteen embedding tables convert those codes back into vectors. Those tables are 2,048 by 2,048, at the talker’s width rather than the predictor’s, because they serve two consumers: the predictor reads them through a resizing projection, and the talker sums all sixteen of a frame’s embeddings at full width to build its own next input. Sizing them by the module they belong to is a load time shape error.
One frame runs as follows.
- First, the talker takes one step and its final hidden state goes through the codec head, giving 3,072 logits from which codebook 0 is sampled.
- Second, that code is looked up in the talker’s own codec table, and the pair of vectors, the talker hidden state and the code 0 embedding, is projected to 1,024 and prefilled into the predictor.
- Third, fifteen times in sequence, the predictor’s last position goes through the matching output head, a code is sampled from 2,048 logits, and its embedding is projected back to 1,024 and appended as the next position.
- Fourth, all sixteen embeddings are summed at talker width, the next text hidden state is added, and the result is the talker’s input for the following frame.
That is 28 transformer layers plus fifteen passes of five layers, so 103 layer passes and sixteen sampling round trips for every 80 milliseconds of audio. The reference code calls the predictor a sub-talker and its outputs a multi token prediction block, which suggests the residual codebooks come out together, while the third step above is a loop with a key value cache in which each of the fifteen depends on the one before it. The predictor never exceeds seventeen positions, so its cache is negligible and its cost is entirely weight reading.
That shape also removes work outright. Each depth step feeds the resizing projection exactly one row of one embedding table, and a linear map applied to a single row is a row of the mapped table, so all fifteen tables can be multiplied through the projection once at load and every step becomes a lookup. That deletes fifteen matrix multiplications against an 8 MB weight per frame without changing a single output value.
Sampling is configured separately for the two stacks. Both use temperature 0.9 and top-k 50, and both leave top-p at 1.0, but the talker applies a repetition penalty of 1.05 while the predictor applies none. Passing a talker style top-p of 0.9 down to the residual codebooks pushes every frame’s fine acoustic detail toward the mode, and because codebook 0 still carries the words, the result stays intelligible and turns metallic rather than failing in a way that is obvious from a transcript.
The codec decoder
The decoder turns 16 codes per frame into 1,920 samples per frame through dequantisation, a transformer, two rate doublings and a waveform stack, all of them running over a whole span of frames rather than one frame at a time.
Dequantisation is split in two. One stack holds the single semantic codebook and another holds the fifteen acoustic ones, each stack narrowing to 256 numbers for lookup and widening back to 512 afterwards, and the two results are added. Each codebook is 2,048 by 256, including the semantic one, although the configuration file describes the semantic codebook as 4,096 entries. No code in the reference implementation reads that field.
The codebooks are not stored as vectors. Each holds embedding_sum and cluster_usage, the
running accumulators of the exponential moving average used to train them, and a lookup is the sum
divided by the usage with a floor of 1e-5. The usage is far from uniform: within the first
acoustic codebook it runs from 0.0358 to 4.643, a ratio of 130 across rows of the same table.
Reading embedding_sum directly gives every row a scale error of up to that factor and still
produces audio, so only a numerical comparison against the reference separates it from a correct
load.
A transformer sits between the codes and the convolutions. After a causal convolution of kernel 3 widens the quantiser output to 1,024, an input projection narrows it to 512 for eight transformer layers, and an output projection widens it back. Those layers hold 30,427,136 parameters, 27% of the decoder’s 114,323,137, so a description of this stage as a convolutional network omits about a quarter of it.
Its shape differs from the two language stacks in three ways. Attention runs at 1,024 across 16 heads of 64 with no grouping, so the query, key and value projections are all 1,024 by 512 and attention is twice as wide as the residual stream it reads from. Both residual branches carry a learned per channel LayerScale. Attention is restricted to a sliding window of 72 frames, which is 5.76 seconds, and this is the only place in the model where a window is live: the talker configures one and disables it.
Upsampling happens in two groups. Two stages of transposed convolution with stride 2, each followed by a ConvNeXt block, take 12.5 Hz to 50 Hz at a constant width of 1,024. A causal convolution of kernel 7 then widens to 1,536 and four decoder blocks take 50 Hz to 24 kHz at strides 8, 5, 4 and 3, halving the channel count at each one, from 1,536 down to 96. Each block applies SnakeBeta, the upsampling convolution, and three residual units at dilations 1, 3 and 9, every unit being an activation, a convolution of kernel 7, another activation and a convolution of kernel 1. The output is a SnakeBeta at 96 channels, a causal convolution of kernel 7 down to one channel, and a clamp to plus or minus one.
SnakeBeta adds to its input a periodic term, the square of the sine of the input scaled by
exp(alpha), divided by exp(beta) plus a small constant, with both parameters learned per channel
and stored as logarithms.
x + 1/(exp(beta) + 1e-9) * sin^2(x * exp(alpha))
The periodic term is what allows a stack of convolutions to produce a pitched signal at all, and it
also sets the numerical precision the stage needs. Storing
the waveform stack in float16 measured 1.17 times faster and missed my fixtures by six times, at a
relative error of 3.1e-2 against a tolerance of 5.0e-3. The cause is in the expression: any error
in x is multiplied by exp(alpha) before the sine, and there are 29 SnakeBeta applications in
series between the head convolution and the output, so rounding is amplified rather than
accumulated.
Every convolution in the decoder is padded on the left only, both transposed convolutions included, and the transformer’s window covers only past frames. The stage is therefore causal end to end, which is what makes chunked decoding exact. The port decodes 300 frames at a time with 25 frames of left context and discards the context’s audio, and the frame to sample mapping stays exact because one frame is always 1,920 samples.
Configuration that does nothing
An unusual amount of this checkpoint’s configuration is present, plausible and never read, and each dead field describes an architecture the model does not have.
The talker configures a three section multimodal rotary embedding with sections of 24, 20 and 20. The reference builds all three sections from the same cumulative sum over the attention mask, so the interleaving function returns its first argument unchanged and what reaches the rotation is ordinary half split rotary embedding. Implementing the configured version produces a different model that also runs.
Alongside it sits a field declaring 13 position identifiers per second, which has no readers and does not match the 12.5 Hz frame rate either. The talker also declares a sliding window and then sets the flag that would enable it to false, so its attention is full causal while the decoder’s, which declares nothing unusual, is the windowed one.
The codec configuration claims 4,096 entries for the semantic codebook against tensors of 2,048 rows, and declares 16 valid quantisers while the encoder in the same file holds 32 codebooks, one semantic and 31 acoustic. Both facts matter on the encode path: a voice asset built by running all 32 is silently wrong from the seventeenth codebook onward, since the decoder has nothing to look those codes up in.
The prompt has a similar gap between where a reader expects the assembly and where it happens. The processor exposed by the reference applies no chat template, and the model wrapper is what wraps the text in an assistant turn before tokenising, then slices those tokens back off. Tokenising raw text and applying the same slices removes the first three words, silently, in a voice that still sounds correct.
Shapes are load bearing and configuration fields are a record of intent, which is why the port was written from the tensor headers first and the configuration second.
What the shape decides
The frame rate is where the speed comes from. At 12.5 Hz a second of speech costs 12.5 talker steps and 187.5 depth steps, half what a 25 Hz model costs, and that is why the largest of the three models I run is also the fastest. Measured on an M4 MacBook Pro with one byte weights, a short passage runs at 0.665 real time factor with the talker holding 89% of it and the decoder 11%, and a hundred segment chapter at two byte weights runs at 0.260 once segments batch. The profiling that produced those figures is a separate post.
Nothing in the model requires a complete utterance. The talker and the predictor are autoregressive by construction, and the decoder is causal in every convolution and windowed to the past in its transformer. One frame is 80 milliseconds of audio against roughly 53 milliseconds of computation at that measured rate, so a single stream has real headroom. The work that is missing is state rather than speed: chunked decoding currently recomputes 25 frames of left context, which is 8% overhead at 300 frame chunks and 625% at four, and carrying the convolution tails forward instead would make small chunks exact and cheap.
Text and audio share one clock, and that is the failure mode. Since one text token is consumed per frame, a generation that outlives its text is fed padding indefinitely and keeps producing frames until it chooses the end token, so a segment can continue speaking after its sentence has run out. The symptom is audible and the measurement is exact: text positions never consumed are counted, and frames per character against the median of the same request identifies which segment ran long.
The limit that no amount of engineering moves is the language tag. It is one of ten identifiers in the control range, prefilled into the codec stream before generation begins, and there is no eleventh. English, German, Spanish, Chinese, Japanese, French, Korean, Russian, Italian and Portuguese are the complete list, which places Swahili and every other African language outside a model I would otherwise use for everything.



