GeoZL

How PivCo works

  • PivCo-Huffman by Marcin Zukowski, 2026, in OpenZL 0.3 (arXiv 2606.05765), used by the GeoZL codecs lanes (0x72D713) and planar_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.

inabacabaa
code01001101000
a = 0, b = 10, c = 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.

A single reader walks the glued bits 01001101000 one at a time. Each symbol of the output appears only when its code ends, so the fourth symbol, c, is known only after the three codes before it.
one reader, one bit at a time, so a symbol is known only when its code ends

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.

The first bit of every symbol drops into the root bitmap 01010100 at once. Then only b, c and b send their second bit to the b or c node, filling slots 0, 1 and 2 with 010.
the root holds one bit per symbol, its child only the symbols that reached it

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.

Nine steps. Eight threads read the root bitmap 01010100. The five that read 0 are a. t1, t3 and t5 read 1, so each is b or c. The b or c bitmap keeps one bit per 1 in the root, in the same order, so a thread's place in it is the number of 1s before it. Popcount gives t5 a count of 2, place 2 holds a 0, so t5 is b. t1 and t3 do the same at the same time and get b and c.
each thread finds its slot from a count, not from its neighbour's answer

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.

The example tree, rebuilt by both sides from the Huffman weights. The root is an internal node with bitmap 01010100, its left child a is a constant leaf and its right child b or c is an internal node with bitmap 010 and constant leaves b and c. In the block the nodes are written in pre-order, the root bitmap, its count of 1s, 3, and the b or c bitmap without a count because both its children are leaves. The leaves store nothing. A real lane is cut into blocks of 32768 symbols.
The example as it is stored. Bitmaps in pre-order, a count of 1s where the decoder needs it, nothing for the leaves.

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.