[{"data":1,"prerenderedAt":425},["ShallowReactive",2],{"navigation":3,"\u002Fconcepts\u002Fcodecs\u002Fhuffman":222,"\u002Fconcepts\u002Fcodecs\u002Fhuffman-surround":420},[4,8,168,206,210,214,218],{"title":5,"path":6,"stem":7},"Quickstart","\u002Fquickstart","01.quickstart",{"title":9,"path":10,"stem":11,"children":12},"Concepts","\u002Fconcepts","20.concepts",[13,15,19,23,84,88,92,96,100],{"title":9,"path":10,"stem":14},"20.concepts\u002Findex",{"title":16,"path":17,"stem":18},"Preprocessing Graph","\u002Fconcepts\u002Fppg","20.concepts\u002F2.ppg",{"title":20,"path":21,"stem":22},"Plane decomposition","\u002Fconcepts\u002Fplanes","20.concepts\u002F3.planes",{"title":24,"path":25,"stem":26,"children":27},"Codecs","\u002Fconcepts\u002Fcodecs","20.concepts\u002F4.codecs",[28,32,36,40,44,48,52,56,60,64,68,72,76,80],{"title":29,"path":30,"stem":31},"Arithmetic","\u002Fconcepts\u002Fcodecs\u002Farithmetic","20.concepts\u002Fcodecs\u002Farithmetic",{"title":33,"path":34,"stem":35},"Context Mixing Lite","\u002Fconcepts\u002Fcodecs\u002Fcontext-mixing-lite","20.concepts\u002Fcodecs\u002Fcontext-mixing-lite",{"title":37,"path":38,"stem":39},"FPC","\u002Fconcepts\u002Fcodecs\u002Ffpc","20.concepts\u002Fcodecs\u002Ffpc",{"title":41,"path":42,"stem":43},"Huffman LLM 5-Bit","\u002Fconcepts\u002Fcodecs\u002Fhuff-llm","20.concepts\u002Fcodecs\u002Fhuff-llm",{"title":45,"path":46,"stem":47},"Huffman","\u002Fconcepts\u002Fcodecs\u002Fhuffman","20.concepts\u002Fcodecs\u002Fhuffman",{"title":49,"path":50,"stem":51},"Identity","\u002Fconcepts\u002Fcodecs\u002Fidentity","20.concepts\u002Fcodecs\u002Fidentity",{"title":53,"path":54,"stem":55},"Neural Predictor","\u002Fconcepts\u002Fcodecs\u002Fneural-predictor","20.concepts\u002Fcodecs\u002Fneural-predictor",{"title":57,"path":58,"stem":59},"Order-1 Arithmetic","\u002Fconcepts\u002Fcodecs\u002Forder1-arithmetic","20.concepts\u002Fcodecs\u002Forder1-arithmetic",{"title":61,"path":62,"stem":63},"Order-1 Scale AC","\u002Fconcepts\u002Fcodecs\u002Forder1-scale-ac","20.concepts\u002Fcodecs\u002Forder1-scale-ac",{"title":65,"path":66,"stem":67},"Per-Group Codebook","\u002Fconcepts\u002Fcodecs\u002Fper-group-codebook","20.concepts\u002Fcodecs\u002Fper-group-codebook",{"title":69,"path":70,"stem":71},"rANS","\u002Fconcepts\u002Fcodecs\u002Frans","20.concepts\u002Fcodecs\u002Frans",{"title":73,"path":74,"stem":75},"tANS","\u002Fconcepts\u002Fcodecs\u002Ftans","20.concepts\u002Fcodecs\u002Ftans",{"title":77,"path":78,"stem":79},"Zstd","\u002Fconcepts\u002Fcodecs\u002Fzstd","20.concepts\u002Fcodecs\u002Fzstd",{"title":81,"path":82,"stem":83},"Zstd Dictionary","\u002Fconcepts\u002Fcodecs\u002Fzstd-dict","20.concepts\u002Fcodecs\u002Fzstd-dict",{"title":85,"path":86,"stem":87},"Container format","\u002Fconcepts\u002Fcontainer","20.concepts\u002F5.container",{"title":89,"path":90,"stem":91},"Delta compression","\u002Fconcepts\u002Fdelta","20.concepts\u002F6.delta",{"title":93,"path":94,"stem":95},"Extensibility","\u002Fconcepts\u002Fextensibility","20.concepts\u002F7.extensibility",{"title":24,"path":25,"stem":97,"children":98},"20.concepts\u002Fcodecs\u002Findex",[99],{"title":24,"path":25,"stem":97},{"title":101,"path":102,"stem":103,"children":104},"Transforms","\u002Fconcepts\u002Ftransforms","20.concepts\u002Ftransforms\u002Findex",[105,106,110,114,118,122,126,130,134,140,144,148,152,156,160,164],{"title":101,"path":102,"stem":103},{"title":107,"path":108,"stem":109},"Alpha-Stable Normalize","\u002Fconcepts\u002Ftransforms\u002Falpha-stable-normalize","20.concepts\u002Ftransforms\u002Falpha-stable-normalize",{"title":111,"path":112,"stem":113},"Bit Reorder","\u002Fconcepts\u002Ftransforms\u002Fbit-reorder","20.concepts\u002Ftransforms\u002Fbit-reorder",{"title":115,"path":116,"stem":117},"Block Microscaling Repack","\u002Fconcepts\u002Ftransforms\u002Fblock-microscaling-repack","20.concepts\u002Ftransforms\u002Fblock-microscaling-repack",{"title":119,"path":120,"stem":121},"Burrows-Wheeler","\u002Fconcepts\u002Ftransforms\u002Fburrows-wheeler","20.concepts\u002Ftransforms\u002Fburrows-wheeler",{"title":123,"path":124,"stem":125},"Byte Split & Nibble Split","\u002Fconcepts\u002Ftransforms\u002Fbyte-split","20.concepts\u002Ftransforms\u002Fbyte-split",{"title":127,"path":128,"stem":129},"Concat","\u002Fconcepts\u002Ftransforms\u002Fconcat","20.concepts\u002Ftransforms\u002Fconcat",{"title":131,"path":132,"stem":133},"Delta","\u002Fconcepts\u002Ftransforms\u002Fdelta","20.concepts\u002Ftransforms\u002Fdelta",{"title":135,"path":136,"stem":137,"children":138},"Index Bitwidth Pack","\u002Fconcepts\u002Ftransforms\u002Findex-bitwidth-pack","20.concepts\u002Ftransforms\u002Findex-bitwidth-pack",[139],{"title":135,"path":136,"stem":137},{"title":141,"path":142,"stem":143},"IntDelta","\u002Fconcepts\u002Ftransforms\u002Fint-delta","20.concepts\u002Ftransforms\u002Fint-delta",{"title":145,"path":146,"stem":147},"Mantissa Zero Strip","\u002Fconcepts\u002Ftransforms\u002Fmantissa-zero-strip","20.concepts\u002Ftransforms\u002Fmantissa-zero-strip",{"title":149,"path":150,"stem":151},"Move to Front","\u002Fconcepts\u002Ftransforms\u002Fmove-to-front","20.concepts\u002Ftransforms\u002Fmove-to-front",{"title":153,"path":154,"stem":155},"MxFp4 Deinterleave","\u002Fconcepts\u002Ftransforms\u002Fmxfp4-deinterleave","20.concepts\u002Ftransforms\u002Fmxfp4-deinterleave",{"title":157,"path":158,"stem":159},"Predictor XOR","\u002Fconcepts\u002Ftransforms\u002Fpredictor-xor","20.concepts\u002Ftransforms\u002Fpredictor-xor",{"title":161,"path":162,"stem":163},"Reshape","\u002Fconcepts\u002Ftransforms\u002Freshape","20.concepts\u002Ftransforms\u002Freshape",{"title":165,"path":166,"stem":167},"Spherical Normalize","\u002Fconcepts\u002Ftransforms\u002Fspherical-normalize","20.concepts\u002Ftransforms\u002Fspherical-normalize",{"title":169,"path":170,"stem":171,"children":172},"Guides","\u002Fguides","30.guides\u002F00.index",[173,174,178,182,186,190,194,198,202],{"title":169,"path":170,"stem":171},{"title":175,"path":176,"stem":177},"CLI usage","\u002Fguides\u002Fcli","30.guides\u002F01.cli",{"title":179,"path":180,"stem":181},"Python API","\u002Fguides\u002Fpython-api","30.guides\u002F02.python-api",{"title":183,"path":184,"stem":185},"Writing your first extension","\u002Fguides\u002Fextension-authoring","30.guides\u002F03.extension-authoring",{"title":187,"path":188,"stem":189},"Trust and security","\u002Fguides\u002Ftrust-and-security","30.guides\u002F04.trust-and-security",{"title":191,"path":192,"stem":193},"Random access","\u002Fguides\u002Frandom-access","30.guides\u002F10.random-access",{"title":195,"path":196,"stem":197},"Tuning","\u002Fguides\u002Ftuning","30.guides\u002F11.tuning",{"title":199,"path":200,"stem":201},"Safetensors","\u002Fguides\u002Fsafetensors","30.guides\u002F50.safetensors",{"title":203,"path":204,"stem":205},"Transformers","\u002Fguides\u002Ftransformers","30.guides\u002F51.transformers",{"title":207,"path":208,"stem":209},"API reference","\u002Fapi","40.api",{"title":211,"path":212,"stem":213},"Benchmarks","\u002Fbenchmarks","50.benchmarks",{"title":215,"path":216,"stem":217},"Extensions","\u002Fextensions","60.extensions",{"title":219,"path":220,"stem":221},"Contributing","\u002Fcontributing","90.contributing",{"id":223,"title":45,"body":224,"description":414,"extension":415,"kind":416,"language":416,"links":416,"meta":417,"navigation":416,"path":46,"seo":418,"stem":47,"summary":416,"__hash__":419},"docs\u002F20.concepts\u002Fcodecs\u002Fhuffman.md",{"type":225,"value":226,"toc":409},"minimark",[227,232,245,250,253,256,357,370,378,382,385,389,405],[228,229,231],"h1",{"id":230},"huffman-codec","Huffman Codec",[233,234,235,236,239,240,244],"p",{},"The ",[237,238,45],"code",{}," codec provides canonical Huffman entropy coding for PTWM planes. It is one of the two peer byte coders (along with ",[241,242,69],"a",{"href":243},"rans",") in the dispatcher.",[246,247,249],"h2",{"id":248},"theory","Theory",[233,251,252],{},"Huffman coding assigns variable-length prefix codes to symbols based on their frequency. More frequent symbols receive shorter codes, reducing the overall file size.",[233,254,255],{},"PTWM's implementation is heavily optimized for performance:",[257,258,263],"pre",{"className":259,"code":260,"language":261,"meta":262,"style":262},"language-mermaid shiki shiki-themes material-theme-lighter github-light github-dark","graph LR\n    subgraph Payload [\"Huffman Payload\"]\n        H[Header: Packed Weight Table]\n        subgraph Bitstreams [4 Interleaved Backward Bitstreams]\n            B1[Stream 0]\n            B2[Stream 1]\n            B3[Stream 2]\n            B4[Stream 3]\n        end\n    end\n    H --> Bitstreams\n    B1 -->|Decoded in Parallel| Out[Output Byte Plane]\n    B2 --> Out\n    B3 --> Out\n    B4 --> Out\n","mermaid","",[237,264,265,273,279,285,291,297,303,309,315,321,327,333,339,345,351],{"__ignoreMap":262},[266,267,270],"span",{"class":268,"line":269},"line",1,[266,271,272],{},"graph LR\n",[266,274,276],{"class":268,"line":275},2,[266,277,278],{},"    subgraph Payload [\"Huffman Payload\"]\n",[266,280,282],{"class":268,"line":281},3,[266,283,284],{},"        H[Header: Packed Weight Table]\n",[266,286,288],{"class":268,"line":287},4,[266,289,290],{},"        subgraph Bitstreams [4 Interleaved Backward Bitstreams]\n",[266,292,294],{"class":268,"line":293},5,[266,295,296],{},"            B1[Stream 0]\n",[266,298,300],{"class":268,"line":299},6,[266,301,302],{},"            B2[Stream 1]\n",[266,304,306],{"class":268,"line":305},7,[266,307,308],{},"            B3[Stream 2]\n",[266,310,312],{"class":268,"line":311},8,[266,313,314],{},"            B4[Stream 3]\n",[266,316,318],{"class":268,"line":317},9,[266,319,320],{},"        end\n",[266,322,324],{"class":268,"line":323},10,[266,325,326],{},"    end\n",[266,328,330],{"class":268,"line":329},11,[266,331,332],{},"    H --> Bitstreams\n",[266,334,336],{"class":268,"line":335},12,[266,337,338],{},"    B1 -->|Decoded in Parallel| Out[Output Byte Plane]\n",[266,340,342],{"class":268,"line":341},13,[266,343,344],{},"    B2 --> Out\n",[266,346,348],{"class":268,"line":347},14,[266,349,350],{},"    B3 --> Out\n",[266,352,354],{"class":268,"line":353},15,[266,355,356],{},"    B4 --> Out\n",[358,359,360,364,367],"ul",{},[361,362,363],"li",{},"It uses a canonical Huffman formulation.",[361,365,366],{},"The weight table is nibble-packed.",[361,368,369],{},"It writes to four interleaved backward bitstreams, allowing the decoder to execute fused parallel decodes.",[233,371,235,372,374,375,377],{},[237,373,45],{}," codec is typically selected by the compressor's trial-encoding dispatcher when it yields a smaller payload than ",[237,376,69],{}," on a specific plane.",[246,379,381],{"id":380},"usage","Usage",[233,383,384],{},"This codec accepts any plane descriptor and operates directly on raw bytes. It guarantees a raw fallback if the data is incompressible.",[246,386,388],{"id":387},"references","References",[358,390,391],{},[361,392,393,394,398,399],{},"David A. Huffman, \"A Method for the Construction of Minimum-Redundancy Codes\", ",[395,396,397],"em",{},"Proceedings of the IRE"," (1952). ",[241,400,404],{"href":401,"rel":402},"https:\u002F\u002Fieeexplore.ieee.org\u002Fdocument\u002F1697831",[403],"nofollow","Link",[406,407,408],"style",{},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":262,"searchDepth":281,"depth":281,"links":410},[411,412,413],{"id":248,"depth":275,"text":249},{"id":380,"depth":275,"text":381},{"id":387,"depth":275,"text":388},"Canonical Huffman entropy coder optimized for fast fused decoding.","md",null,{},{"title":45,"description":414},"tOxPEsniKeAgM9FpPETLV8Y_jx9YzvCTILQYrq-MXRU",[421,423],{"title":41,"path":42,"stem":43,"description":422,"children":-1},"Field-separated Huffman codec for 16-bit float planes.",{"title":49,"path":50,"stem":51,"description":424,"children":-1},"A pass-through codec that performs no compression.",1784796355330]