How PivCo works
- PivCo-Huffman by Marcin Zukowski, 2026, in OpenZL 0.3 (arXiv 2606.05765), used by the GeoZL codecs
lanes(0x72D713) andplanar_zigzag_lanes(0x72D712).
Huffman is one of the oldest compression methods, and its bit order forces a decoder to read one code after another. PivCo keeps the Huffman codes but stores their bits in a different order, so many readers can decode the same block together. Eight symbols follow the whole path below, from Huffman codes to the bitmaps GeoZL writes.
Huffman, and why it is serial
The example string is a b a c a b a a. Five of eight symbols are a, so shorter codes save bits. Huffman builds a code where common symbols get short codes, so a becomes 0, b becomes 10 and c becomes 11.
Each code follows a path through the tree. The first bit says whether we go left (to a) or right. On the right there is one more choice, left for b and right for c. Because no code is the start of another, the codes need no separators. The concatenated stream has eleven bits, 01001101000.
Concatenation makes Huffman decoding serial. The fourth symbol cannot be located before decoding the first three. Watch the reader below. It can only box a code once it reaches the code's last bit, and only then does the next code have a start. The fourth symbol, the slot marked with a question mark, is found only after the three codes before it.
There is only one place to start reading, so a second reader has nothing to do until the first one is finished. Fast decoders hide some of the wait with lookup tables and several interleaved streams, but the chain itself stays. What a GPU wants from a format explains why a chain like this is the main obstacle on a GPU.
Storing the bits by tree node
PivCo writes code bits in tree order instead of symbol order. Every symbol passes through the root, so the root gets one bit per symbol, which is the first bit of its code. Here, that is 01010100, where a 0 means a and a 1 means "b or c, ask the next node".
Only three symbols reach the “b or c” node. It stores their second bits as 010, where 0 means b and 1 means c. No symbol reaches a after the root, so it needs no later bitmap. The animation places all first bits at the root. Only the second bits of b, c and b enter the child in arrival order.
There are eight at the root and three at the child, eleven in total, exactly as many as the glued Huffman string. PivCo retains the codes and their eleven bits. Each bit moves to the node where decoding uses it. Each of these per-node bit strings is called a bitmap, and one bitmap holds the decision for every symbol that reaches its node.
Count the 1s before you
Decoding asks each symbol two questions, in the same order the tree does. The root asks "is it a?". A 0 says yes. A 1 says no, and that alone narrows the answer to b or c, because a is the only other choice. The second bitmap then settles it, 0 for b and 1 for c.
Give every symbol its own reader, called a thread in the animation. Thread t reads bit t of the root, all of them at once. Five threads read a 0, so their symbol is a and they are done. The other three, t1, t3 and t5, know only that the answer is b or c.
Each of those three finds its own bit in the b or c bitmap with popcount, as in the box above. t1 counts no 1s before it and reads place 0, a 0, so b. t3 counts one and reads place 1, a 1, so c. t5 counts two and reads place 2, a 0, so b.
No thread waits for another, because each one needs only a count of 1s, and popcount gives it in one instruction. For bitmaps longer than one word, the threads add their per-word counts with a prefix sum. A deeper tree repeats this count and child move at every level.
The same counts also work in the other direction. A decoder can start at the leaves and merge each pair of children into its parent by the parent's bitmap, which is how GeoZL runs it on a GPU, described in From compressed bytes to a GPU tensor.
The real format
The real format adds three things to the picture. PivCo never stores the tree, only the Huffman weights, and the encoder and the decoder each rebuild the same tree from them. OpenZL caps codes at 12 bits, so no tree is deeper than 12 levels.
Nodes are written in pre-order, each node before its left subtree and then its right. An internal node stores a byte-aligned bitmap and the count of 1s in it, and the count is left out when both children are constant leaves. A constant leaf stores nothing. A flat leaf, used where every remaining code has the same length, stores one fixed-width index per symbol.
The count tells a decoder how many symbols go right, so it can find where every node's data starts without decoding anything. GeoZL also checks each count against its bitmap, and the tree depth against 12, before it decodes, and rejects a frame that disagrees.
A real lane is far longer than eight symbols, so PivCo cuts it into blocks of 32768 symbols, each with its own bitmaps. Blocks are independent, so they decode at the same time too.
Thanks
PivCo is not our idea. Marcin Zukowski described PivCo-Huffman in 2026, in arXiv 2606.05765, and almost everything on this page follows from that paper.
It ships in OpenZL 0.3, and GeoZL calls OpenZL's PivCo kernels instead of writing its own, so the lanes codecs get a well tested coder for free. Thanks to the OpenZL team for building it in the open. Any mistake in how we explain it here is ours.