Briefing

Safetensors Explorer and Quantization Tools

ai-dev
by /u/Puppet_Master_1337 ·

Run model_explorer.py to inspect layer structure before applying quant_explorer.py for quantization analysis.

What to do now

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

Affects

internal

Source angles · 2 perspectives

Black Forest Labs (Reddit)
Independent angle

Exploring safetensors and its quantization

Open
r/StableDiffusion
Independent angle

Safetensors Explorer and Quantization Tools

Open

Customer impact

Analyzing matches…

Ask about this story

Impact on an agency? Which customers? Compare historically Risks of waiting