Tail-biting trellis
Trellis quantization stores a tile of weights as one bit stream. Each weight reads a sliding window of the stream, and the stream is a ring, so the last windows wrap around and bite into the first bits.
What the figure shows
The ring holds T·K = 64 bits. The orange band is the window of the current weight: L = 8 bits that end at bit K·(i + 1). Moving to the next weight slides the window K bits clockwise, so consecutive weights share L − K bits. That sharing is the trellis: each weight only gets K new bits, but it picks them knowing the bits it inherits.
The first few weights' windows start before bit 0. Their missing bits come from the end of the ring, which is the tail-biting: the encoder has to choose the last bits of the tile so that they also make good prefixes for the first weights. A tile of 256 weights at K = 2 stores exactly 512 bits, with no extra bits to start the trellis.
Searching for the bits
The encoder picks the bit stream that minimizes the tile's squared error with a Viterbi search over the 2L states. The heat map shows the cost of reaching each state at each step; the blue line is the chosen path. The ring adds one constraint: the path must end in a state whose low L − K bits equal the first state's high L − K bits.
- Exact runs one constrained search per possible seam (2L−K of them) and keeps the best. It is the true optimum, and too slow at L = 16.
- Two-pass is QTIP's method, also used by exllamav3: search the tile rotated by T/2 with no constraint, read the seam bits from the middle of that path, then run one search with the seam fixed. It usually matches exact, and sometimes misses by a little.
- Free ignores the ring. It is a lower bound that would need L − K extra bits to store.
Click New targets a few times and watch the gap between exact and two-pass. Set show:
'two-pass' to animate that path instead.