[{"data":1,"prerenderedAt":491},["ShallowReactive",2],{"navigation":3,"\u002Fguides\u002Ftransformers":222,"\u002Fguides\u002Ftransformers-surround":486},[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":203,"body":224,"description":480,"extension":481,"kind":482,"language":482,"links":482,"meta":483,"navigation":482,"path":204,"seo":484,"stem":205,"summary":482,"__hash__":485},"docs\u002F30.guides\u002F51.transformers.md",{"type":225,"value":226,"toc":474},"minimark",[227,241,256,261,355,361,365,368,391,405,409,420,424,436,470],[228,229,230,231,235,236,240],"p",{},"For HuggingFace models stored as safetensors, the\n",[232,233,234],"a",{"href":200},"safetensors patcher"," is enough — it intercepts\nloading at the ",[237,238,239],"code",{},"safe_open"," boundary.",[228,242,243,244,247,248,251,252,255],{},"For non-safetensors HuggingFace checkpoints, use\n",[237,245,246],{},"patch_transformers()"," instead. It patches\n",[237,249,250],{},"transformers.modeling_utils.load_state_dict"," so PyTorch-pickle and\nsharded HuggingFace loaders both transparently decompress sibling\n",[237,253,254],{},".ptwm"," files.",[257,258,260],"h2",{"id":259},"default-behaviour","Default behaviour",[262,263,268],"pre",{"className":264,"code":265,"language":266,"meta":267,"style":267},"language-python shiki shiki-themes material-theme-lighter github-light github-dark","from ptwm import patch_transformers\npatch_transformers()\n\nfrom transformers import AutoModelForCausalLM\nmodel = AutoModelForCausalLM.from_pretrained(\"path\u002Fto\u002Fmodel\")\n","python","",[237,269,270,289,300,307,320],{"__ignoreMap":267},[271,272,275,279,283,286],"span",{"class":273,"line":274},"line",1,[271,276,278],{"class":277},"sVHd0","from",[271,280,282],{"class":281},"su5hD"," ptwm ",[271,284,285],{"class":277},"import",[271,287,288],{"class":281}," patch_transformers\n",[271,290,292,296],{"class":273,"line":291},2,[271,293,295],{"class":294},"slqww","patch_transformers",[271,297,299],{"class":298},"sP7_E","()\n",[271,301,303],{"class":273,"line":302},3,[271,304,306],{"emptyLinePlaceholder":305},true,"\n",[271,308,310,312,315,317],{"class":273,"line":309},4,[271,311,278],{"class":277},[271,313,314],{"class":281}," transformers ",[271,316,285],{"class":277},[271,318,319],{"class":281}," AutoModelForCausalLM\n",[271,321,323,326,330,333,336,339,342,346,350,352],{"class":273,"line":322},5,[271,324,325],{"class":281},"model ",[271,327,329],{"class":328},"smGrS","=",[271,331,332],{"class":281}," AutoModelForCausalLM",[271,334,335],{"class":298},".",[271,337,338],{"class":294},"from_pretrained",[271,340,341],{"class":298},"(",[271,343,345],{"class":344},"sjJ54","\"",[271,347,349],{"class":348},"s_sjI","path\u002Fto\u002Fmodel",[271,351,345],{"class":344},[271,353,354],{"class":298},")\n",[228,356,357,358,360],{},"PTWM decompresses a sibling ",[237,359,254],{}," shard in memory and leaves the\non-disk file untouched.",[257,362,364],{"id":363},"replace-local-files","Replace local files",[228,366,367],{},"To cache the decompressed result on disk for future loads:",[262,369,371],{"className":264,"code":370,"language":266,"meta":267,"style":267},"patch_transformers(replace_local_file=True)\n",[237,372,373],{"__ignoreMap":267},[271,374,375,377,379,383,385,389],{"class":273,"line":274},[271,376,295],{"class":294},[271,378,341],{"class":298},[271,380,382],{"class":381},"s99_P","replace_local_file",[271,384,329],{"class":328},[271,386,388],{"class":387},"s39Yj","True",[271,390,354],{"class":298},[228,392,393,394,396,397,400,401,404],{},"This deletes the ",[237,395,254],{}," shard after a successful decompression and\nwrites the canonical ",[237,398,399],{},".safetensors"," \u002F ",[237,402,403],{},".bin"," in its place. Useful for\none-time decompression on a workstation; unhelpful in CI, where the\nsmaller artefact should stay on disk.",[257,406,408],{"id":407},"compatibility","Compatibility",[228,410,411,412,415,416,419],{},"Tested against ",[237,413,414],{},"transformers >= 4.45",". The patch intercepts only\n",[237,417,418],{},"load_state_dict","; nothing else in the HuggingFace stack changes.",[257,421,423],{"id":422},"combining-patchers","Combining patchers",[228,425,426,429,430,432,433,435],{},[237,427,428],{},"patch_safetensors()"," and ",[237,431,246],{}," are independent; call\nthem together as needed. The safetensors patcher handles the\n",[237,434,239],{}," path; the transformers patcher catches everything else.",[262,437,439],{"className":264,"code":438,"language":266,"meta":267,"style":267},"from ptwm import patch_safetensors, patch_transformers\npatch_safetensors()\npatch_transformers()\n",[237,440,441,457,464],{"__ignoreMap":267},[271,442,443,445,447,449,452,455],{"class":273,"line":274},[271,444,278],{"class":277},[271,446,282],{"class":281},[271,448,285],{"class":277},[271,450,451],{"class":281}," patch_safetensors",[271,453,454],{"class":298},",",[271,456,288],{"class":281},[271,458,459,462],{"class":273,"line":291},[271,460,461],{"class":294},"patch_safetensors",[271,463,299],{"class":298},[271,465,466,468],{"class":273,"line":302},[271,467,295],{"class":294},[271,469,299],{"class":298},[471,472,473],"style",{},"html pre.shiki code .sVHd0, html code.shiki .sVHd0{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#D73A49;--shiki-default-font-style:inherit;--shiki-dark:#F97583;--shiki-dark-font-style:inherit}html pre.shiki code .su5hD, html code.shiki .su5hD{--shiki-light:#90A4AE;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .slqww, html code.shiki .slqww{--shiki-light:#6182B8;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sP7_E, html code.shiki .sP7_E{--shiki-light:#39ADB5;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .smGrS, html code.shiki .smGrS{--shiki-light:#39ADB5;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sjJ54, html code.shiki .sjJ54{--shiki-light:#39ADB5;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .s_sjI, html code.shiki .s_sjI{--shiki-light:#91B859;--shiki-default:#032F62;--shiki-dark:#9ECBFF}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);}html pre.shiki code .s99_P, html code.shiki .s99_P{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#E36209;--shiki-default-font-style:inherit;--shiki-dark:#FFAB70;--shiki-dark-font-style:inherit}html pre.shiki code .s39Yj, html code.shiki .s39Yj{--shiki-light:#39ADB5;--shiki-default:#005CC5;--shiki-dark:#79B8FF}",{"title":267,"searchDepth":302,"depth":302,"links":475},[476,477,478,479],{"id":259,"depth":291,"text":260},{"id":363,"depth":291,"text":364},{"id":407,"depth":291,"text":408},{"id":422,"depth":291,"text":423},"Patch `transformers.modeling_utils.load_state_dict` to transparently decompress `.ptwm` payloads.","md",null,{},{"title":203,"description":480},"pZv4CNNhx6srA_noxzIr_hp24VnfqzrXXBmKvXqSqFs",[487,489],{"title":199,"path":200,"stem":201,"description":488,"children":-1},"Patch the safetensors loader so existing code decompresses sibling `.ptwm` payloads transparently.",{"title":207,"path":208,"stem":209,"description":490,"children":-1},"Reference for the Python package and the Rust crate.",1784796352969]