What a GPU wants from a format
- PFOR (CTid
0x72D70D) and PivCo-Huffman inside the lanes codecs (CTids0x72D713and0x72D712).
A GPU decodes in a way a CPU never has to. Thousands of threads run the same small program at once, and every one of them has to find its own input without waiting for another. This part is about what that asks of a compressed format, and which of GeoZL's codecs can give it. The reason to care is that a model wants its batch as a tensor in GPU memory, which is what Rumi asks GeoZL for.
That requirement splits the current codecs cleanly. GPU decoding supports layouts ending in PFOR or lanes. med and generic entropy graphs use the CPU path. Fixing the lanes format for GPU decoding also costs some compression ratio, as the last section explains.
A wave, 32 threads in step
A GPU runs its threads in groups of 32, and the 32 threads of a group execute the same instruction at the same moment, each on its own value. We call that group a wave (a warp on NVIDIA, a SIMD-group on Apple). It is the SIMD register from part one again, with 32 lanes instead of 8.
The figure gives 8 threads of a wave three jobs and counts the turns each one takes. Each thread is a column and each turn a row, so time runs down the panel. Green finishes in one turn, yellow in three, and red in eight.
Green. One instruction, x = 2 × x, gives eight results in one turn. Any work a thread can do with its own value alone runs like this, and a decoder wants as much of its work as possible to look like it.
Yellow. Sometimes a thread needs values from other threads. In the figure every thread holds a count and wants the total up to itself, close to what PivCo asks below, how many 1s come before it. A shuffle lets a thread read a value from another thread of its wave, register to register, for about the cost of an add. In turn 1 every thread adds the value one thread back, in turn 2 two back and in turn 3 four back, and the rings follow t7 as it does. After three turns every thread has its total, and nobody waited. This is the wave prefix sum, the doubling from a prefix sum inside a register with threads in place of lanes, and a wave of 32 needs five turns.
Red. Now the threads follow a raindrop downhill on a small elevation grid, one step each. A step looks at the eight neighbours of the cell where the drop is and moves it to the lowest. t0 starts at A1 and finds B2. t1 cannot even start until it knows the drop is at B2, and then finds B3, and so on. No thread knows where to look until the thread before it has moved the drop, so there is nothing to shuffle and the threads take turns, one busy and the rest waiting, eight turns here and 32 on a real wave. Reading variable-length codes, such as Huffman's, has the same shape, and the next section shows it.
PFOR, where every thread starts at once
PFOR packs a block at one bit width b and moves the high bits of the few values that do not fit, the exceptions, to a side list. Every value in the body has the same width, so the start of a value is a multiplication. In the lane layout from part one, with 16-bit samples, thread t finds its eight values at bit t × b of every lane, usually with one 16-byte load.
An exception takes one more step, because its thread has to find its high bits in the side list. Every thread builds the same bit mask, with one bit set at each exception position. In the figure, only bit 7 is set. The high bits of an exception sit at its rank, which is the number of exceptions before it. So a thread counts the set bits below its own position with popcount, reads the high bits at that rank, and ORs them in above its low b bits. A block stores the positions either as a list or as a bitmap; the PFOR page describes both.
Nothing here waits on another thread. The block format came from SIMD on a CPU, long before the GPU decoder, and the GPU reads the same frames unchanged. Bytes to tensors follows the kernel through one real 256-value block.
PivCo, decoding from the leaves up
Plain Huffman writes each code in one piece, so a thread cannot find where its code starts until it has read every code before it. PivCo-Huffman keeps the same codes and only reorders the bits, one bitmap per node of the tree with one bit for every symbol that reaches it.
Root-down traversal. A symbol visits one bitmap per bit of its code, up to twelve, so threads with short codes sit idle while the long ones finish. Finding each thread's place also needs a rank directory over the bitmaps, built in a separate pass and about two thirds the size of the frames it serves.
Leaf-up decoding. GeoZL starts at the deepest level and writes each node's symbols in order. The threads of a wave work on the same node, and no rank directory is needed.
The figure decodes a b a c a b a a with a = 0, b = 10 and c = 11. A leaf repeats its symbol once for every symbol that reaches it. A node merges what its two children wrote, where a 0 in its bitmap takes the next symbol from the left child and a 1 the next from the right.
Position i of a node takes the left symbol numbered by the 0s before i, or the right one numbered by the 1s before it. A thread owns one byte of the bitmap, eight positions, counts its 1s with popcount, and a wave prefix sum tells it how many 1s come before its byte.
A node writes over the range its children used, so even levels write the lane buffer and odd levels write scratch, with a barrier between levels so a parent merges only once its children are done. The level loop is short, and Bytes to tensors shows how four waves share one block.
One idea, two shapes
PFOR and PivCo both work in independent blocks, 256 values for PFOR and 32 768 symbols of one byte lane for PivCo, so a batch splits into thousands of blocks that all decode at once. In planar>zigzag>pfor the independent piece is a strip of a band of rows, since its prediction restarts at the edges of every strip, and one wave walks the blocks of each strip.
| PFOR | PivCo | |
| position | slot × b | count of 1s before you |
| block | 256 values | 32 768 symbols per byte lane |
| best for | small residuals that do not repeat | bytes with a skewed distribution |
| recipes | planar>zigzag>pfor, id>pfor | planar>zigzag>lanes, id>lanes |
Why the lane format is fixed
PivCo works on bytes, so the lanes codec splits a 16-bit raster into a low-byte lane and a high-byte lane, which is where its name comes from. A GPU kernel must know a frame's layout from its CTid alone. The lanes codec therefore writes each byte lane as PivCo Huffman or byte PFOR, whichever is smaller. It never delegates a lane to FSE or another generic entropy codec based on the data. That closed choice lets the GPU plan every lanes frame without first running a data-dependent OpenZL selector.
The trade-off appears on skewed lanes. Huffman cannot use less than one bit per symbol, while FSE can, so a lane dominated by one value may compress worse. A class map is flat over large areas, and after prediction most residuals may be zero, which is exactly that case.
Data read only on a CPU can use planar>zigzag>transpose>entropy instead. A different GPU encoding needs its own CTid rather than a data-dependent branch inside lanes.
Other ways to decode on the GPU
The format of the files you already have often decides where to start. nvImageCodec reads TIFF and JPEG 2000, cog3pio reads GeoTIFFs through nvTIFF, a proposed Zarr integration uses nvCOMP to decode zstd, and cuSZp reads its own format. The table compares those paths with GeoZL and Rumi.
With GeoZL and cuSZp, you can inspect and change the GPU codecs themselves. nvImageCodec, cog3pio and the Zarr proposal have open libraries around closed NVIDIA decoders.
| GeoZL with Rumi | nvImageCodec | cog3pio | Zarr with nvCOMP | cuSZp | |
| source code | open | open library; closed nvTIFF and nvJPEG2000 decoders | open library; closed nvTIFF decoder | open zarr-python; closed nvCOMP | open |
| GPUs | CUDA and Metal from one Slang source, extensible to Vulkan, WebGPU or HIP | NVIDIA; TIFF needs Volta or newer | NVIDIA, with CUDA wheels for Linux only | NVIDIA | NVIDIA |
| GPU codecs | only PFOR and PivCo | none | none | none | its own codec, decoded in one kernel |
| bounded error | not supported on the GPU | no | no | no | float32 and float64 only |
| Python output | DLPack for PyTorch, JAX or TensorFlow | DLPack and the CUDA array interface | DLPack, or CuPy with the cuda extra | CuPy arrays, which other libraries take through DLPack | a PyTorch tensor you allocate |
| existing files | none | COGs with Deflate, LZW or JPEG, plus Sentinel-2 JPEG 2000. No ZSTD or LERC | GeoTIFFs and COGs that nvTIFF decodes | Zarr arrays compressed with zstd | none |
| status | released; format may still change | released | released 0.1.0; API still changing | open pull request | released |
Green marks a strength, yellow a partial fit and red a gap.
The table compares what each path supports, not how fast it is. We have not yet run these options side by side on the same data and GPUs, so where open codecs stand against NVIDIA's closed decoders is still an open question. It needs more experiments and a shared benchmark.
A GPU read also has to fetch compressed bytes, plan the work on the CPU and put the result where the caller needs it. The next part, Bytes to tensors, follows one batch from file to tensor.