model_normalize
Skill by InternLM
Normalizes Hugging Face model checkpoints by quantizing bf16 or fp16 weights to per-block FP8 and repacking safetensors into standard shards of about 4GB. Aimed at people preparing training-engine checkpoints for HF, vLLM and SGLang.
Install model_normalize
Built from the published package, never by AI.
git clone --depth 1 https://github.com/InternLM/xtuner /tmp/xtuner && mkdir -p ~/.claude/skills && cp -r /tmp/xtuner/.claude/skills/model_normalize ~/.claude/skills/model-normalizeRun in your terminal. Claude Code loads skills from ~/.claude/skills automatically.
git clone --depth 1 https://github.com/InternLM/xtuner /tmp/xtuner && mkdir -p ~/.gemini/antigravity-cli/skills && cp -r /tmp/xtuner/.claude/skills/model_normalize ~/.gemini/antigravity-cli/skills/model-normalizeAntigravity CLI loads skills from ~/.gemini/antigravity-cli/skills, or .agents/skills for one project.
Skills can run scripts on your machine. Some need an API key: check the README.
About
model_normalize converts model checkpoints into a format that HF, vLLM and SGLang can consume. It quantizes large bf16 or fp16 linear weights to per-block FP8 using 128 by 128 blocks and float8_e4m3fn. It can also re-shard arbitrary safetensors directories into the HF-standard model-{i:05d}-of-{n:05d} layout with shards of about 4GB and a fresh model.safetensors.index.json.
The tool has a reference-guided mode that reads the index of an existing FP8 checkpoint and reproduces its quantization decisions. Its heuristic mode uses built-in rules for attention, dense MLP, MoE expert and linear-attention matrices. Norms, routers, biases, embeddings and the vision tower stay in their original dtype. It is aimed at people preparing training-engine checkpoints for inference engines.
Written from the project's SKILL.md and checked against it.
What it can do
- Reference-guided FP8 conversionReproduces the quantization decisions of an existing FP8 checkpoint of the same architecture.
- Heuristic FP8 conversionQuantizes attention, MLP, MoE expert and shared expert matrices using a built-in rule set.
- Standard repackRe-shards safetensors into HF-standard shards of at most the chosen size, with a fresh index file.
- Automatic repack after to-fp8Runs the repack step on quantized output when source shard names are non-standard.
- Per-block scale outputStores per-block float32 scales as name_scale_inv in the same shard as the weight.
- Config quantization blockWrites a quantization_config block to config.json with FP8 settings and modules to skip.
- Copy handoff promptAsks the user where to place outputs and copies files rather than moving them.
What you need
- Python to run the model_normalize.py script
- A Hugging Face style model checkpoint in safetensors format
- An existing FP8 checkpoint of the same architecture, for reference-guided mode
Try asking
- Convert my bf16 checkpoint in /models/my-model to FP8 using the heuristic mode
- Repack the safetensors shards in this folder into 4GB HF-standard shards
- Quantize my model to FP8 using the FP8 reference at /models/ref-fp8
Good to know
- The heuristic rule set was validated against InternS2 and Qwen3-MoE FP8 references only.
- Output is written to a staging directory and must be copied to its final place.
- Conversion skips quantization for norms, routers, biases, embeddings and the vision tower.
Security check
ANo download-and-run commands, hidden instructions or signs of sending keys out were found.
Checked automatically: .claude/skills/model_normalize/SKILL.md, .claude/skills/model_normalize/convert_interns2_to_fp8.sh, .claude/skills/model_normalize/heuristics.py, .claude/skills/model_normalize/hf_to_fp8.py, .claude/skills/model_normalize/model_normalize.py, .claude/skills/model_normalize/repack_hf.py. This looks for known risky patterns and is not a full audit. How grades work
Inside the skill
-
SKILL.md8 KB -
convert_interns2_to_fp8.sh932 B -
heuristics.py4 KB -
hf_to_fp8.py10 KB -
model_normalize.py5 KB
Show all 6 files
-
repack_hf.py6 KB
Alternatives to model_normalize
All alternatives →Aligns a Qwen Code feature with a Codex or Claude Code reference agent. It runs both under the same scenario, captures HTTP and terminal traces, and compares them until behavior matches.
Searches, views, creates, updates, and deletes the user's Google Contacts from an AI assistant. It is for people who want to manage their address book through conversation. A one-time Google connect is required before it returns data.
Guides an AI assistant on error handling choices. It covers when to use Result, Option, ? propagation, unwrap, expect and panic, plus anyhow and thiserror.
Caveman is an agent skill that makes an AI assistant reply in a terse style. It cuts filler and keeps technical facts, code, commands and errors exact. It is built for users who want shorter, cheaper replies.
docs-sync audits or updates English SDK documentation against the requested implementation scope. It is for maintainers who want docs to match main branch features, configuration options, and defaults.
Guides an AI assistant through setting up and running monorepos with pnpm workspaces, Turborepo and Nx. Aimed at developers who need faster builds, shared code and managed dependencies across multiple packages.
Compare with agent-reproduce-align, google_contacts or m06-error-handling
model_normalize: common questions
What is the difference between reference-guided and heuristic FP8 conversion?
Reference-guided mode copies the exact quantization set from an existing FP8 checkpoint's index. Heuristic mode applies built-in name-based rules when no reference is available.
Does it change the names of my safetensors files?
Yes, when to-fp8 detects non-standard shard names it repacks the output into model-NNNNN-of-NNNNN.safetensors names. Passing --no-repack keeps the source naming.
Which weights are quantized to FP8?
Large linear weights for self-attention, dense MLP, MoE experts, shared experts and linear-attention projections are quantized. Everything else stays in its original dtype.
How do I install model_normalize?
Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.
Is model_normalize free?
The code is published under the Apache-2.0 licence. The service it connects to may have its own pricing.
Is model_normalize safe to use?
It scores 85 of 100. Grades: maintenance A, licence A, quality A. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.
What are alternatives to model_normalize?
Similar skills: agent-reproduce-align, google_contacts, m06-error-handling, caveman.
