Safetensors Explorer and Quantization Tools
Run model_explorer.py to inspect layer structure before applying quant_explorer.py for quantization analysis.
Use model_explorer.py to inspect layer structure before quantizing with quant_explorer.py.
Summary
The author released two command‑line utilities for inspecting and quantizing safetensors: model_explorer.py and quant_explorer.py. model_explorer.py accepts a base repo and file, downloads only the header, and prints a tree of layers sorted by size, displaying dtype and shape for each leaf; it supports recent quantization formats NVFP4 and INT4. quant_explorer.py compares a full‑precision base model with a quantized variant, summarizing how many tensors were quantized (whitelist), kept (blacklist), downcast, or missing, and derives naming patterns such as 'blocks.*.attn.*' and 'blocks.*.mlp.*' for quantized layers. The tool outputs a classification summary (e.g., 224 tensors quantized, 130 kept, 44 downcasted) and highlights patterns like 'scale' as a blacklist and 'blocks.*.attn.*' as a whitelist. It also reports downcasted tensors and ambiguous BF16 tensors. The utilities are MIT‑licensed, use Python, and were developed with assistance from LLMs. They allow developers to audit layer structures before applying quantization and to understand which layers benefit most from INT8 or BF16 compression.
Key changes
- model_explorer.py displays layer tree sorted by size, dtype, and shape, supporting NVFP4 and INT4
- Downloads only headers, not full file, for local or HuggingFace hosted files
- quant_explorer.py compares base and quantized models, summarizing quantized, kept, downcast, and missing tensors
- Derives naming patterns for whitelist (e.g., 'blocks.*.attn.*') and blacklist (e.g., 'scale')
- Reports downcasted tensors and ambiguous BF16 tensors
- MIT‑licensed, Python utilities