modelopt-ptq
Skill5.6k starsChanged 3 days agoApache-2.0View on GitHub
Use when the user asks to "quantize a model", "run PTQ", "post-training quantization", "NVFP4 quantization", "FP8 quantization", "INT8 quantization", "INT4 AWQ", "quantize LLM", "quantize MoE", "quantize VLM", or needs to produce a quantized HuggingFace checkpoint from a pretrained model using ModelOpt. Do NOT use for multi-candidate recipe exploration or optimization (use modelopt-quant-recipe-search).
- Installs packages
Trending
More talk lately.about the whole repository
Who's talking about NVIDIA/Model-Optimizer
- @github-trending.bsky.social“📦 NVIDIA / Model-Optimizer ⭐ 3,886 (+22) 🗒 Python A unified library of SOTA model optimization techniques …”Bluesky · Sep 25, 2026 · 5 likes
- onnxsim/onnxsim“Maintaining status of this project”GitHub · Jan 6, 2026 · 5 reactions
- vllm-project/vllm“Add LM head quantization support for ModelOpt”GitHub · May 8, 2026 · 4 reactions
- @chrisshort.net“to optimize inference speed. #devopsish”Bluesky · Sep 27, 2026 · 1 likes
- @dailygithubtrends.bsky.social“今日のGitHubトレンド NVIDIA/Model-Optimizer NVIDIA Model Optimizerは、量子化やプルーニング、蒸留などの手法を用いてモデルを高速化するためのライブラリです。 …”Bluesky · Sep 26, 2026 · 1 likes
The biggest 5 of 54 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 54
Talked about on GitHub and Bluesky (54 times).
On GitHub · 50
- Jan 6, 2026Maintaining status of this project — onnxsim/onnxsim5 reactions · 4 comments
- May 8, 2026Add LM head quantization support for ModelOpt — vllm-project/vllm4 reactions · 7 comments
- Apr 12, 2026Add support for ModelOpt MXFP8 non-gated MoE with ReLU2 — vllm-project/vllm1 reaction · 3 comments
- Apr 2, 2026[Bugfix] Fix NVFP4+MTP crash: force unquantized mtp.fc for Qwen3.5 — vllm-project/vllm1 reaction
- Feb 8, 2026[ModelOpt MXFP8] — sgl-project/sglang1 reaction · 5 comments
45 more on GitHub
- Jan 21, 2026ORT inference fails after upgrading model's opset from 20 to 21 — microsoft/onnxruntime1 reaction · 5 comments
- Nov 15, 2026Watch list: who to follow and where (Edge0 upstream, Qwen4, llama.cpp, MLX, the labs) — toshi38/Edge00 reactions
- Nov 14, 2026Bump nvidia-modelopt from 0.47.0 to 0.48.0 — marek-burza/shrubbery0 reactions
- Nov 11, 2026build(deps-dev): bump nvidia-modelopt from 0.47.0 to 0.48.0 — verl-project/verl0 reactions · 4 comments
- Nov 10, 2026Prepare ModelOpt catalog onboarding: original six skills plus QAD — NVIDIA/skills0 reactions
- Nov 8, 2026build(deps-dev): bump nvidia-modelopt from 0.47.0 to 0.48.0 — ysq111333/verl_jev0 reactions
- Nov 5, 2026python3Packages.nvidia-modelopt: 0.47.0 -> 0.48.0 — NixOS/nixpkgs0 reactions · 1 comment
- Nov 2, 2026claude-code-marketplaces.github.nvidia.model-optimizer: 0.47.0 → 0.48.0 — sudosubin/agents.nix0 reactions
- Nov 2, 2026codex-plugins.github.nvidia.model-optimizer: 0.47.0 → 0.48.0 — sudosubin/agents.nix0 reactions
- Nov 2, 2026claude-code-plugins.github.nvidia.model-optimizer: 0.47.0 → 0.48.0 — sudosubin/agents.nix0 reactions
- Nov 2, 2026build(deps): Update nvidia-modelopt requirement from ~=0.47.0 to ~=0.48.0 — Jonah-May-OSS/wyoming-whisper-trt0 reactions · 2 comments
- Nov 2, 2026codex-marketplaces.github.nvidia.model-optimizer: 0.47.0 → 0.48.0 — sudosubin/agents.nix0 reactions
- Oct 28, 2026claude-code-plugins.github.nvidia.model-optimizer: init at 0.47.0 — sudosubin/agents.nix0 reactions
- Oct 28, 2026claude-code-marketplaces.github.nvidia.model-optimizer: init at 0.47.0 — sudosubin/agents.nix0 reactions
- Oct 28, 2026[ONNX GraphSurgeon] Export fails for a single initializer larger than 2 GiB before external-data saving — NVIDIA/TensorRT0 reactions · 2 comments
- Oct 28, 2026[Bug] make_graph serializes an individual >2 GiB initializer before external-data saving — onnx/onnx0 reactions
- Oct 26, 2026build(deps-dev): bump nvidia-modelopt from 0.44.0 to 0.47.0 — WncFht/verl-opd0 reactions
- Oct 22, 2026chore(deps-dev): Bump nvidia-modelopt from 0.44.0 to 0.47.0 — yiqiu0215/verl-main0 reactions
- Oct 14, 2026Bump nvidia-modelopt from 0.44.0 to 0.47.0 — zery00568/verlxx0 reactions
- Oct 8, 2026Add native packed-cache attention tests — yingguo-trt/Model-Optimizer0 reactions
- Oct 8, 2026Add inline-media CLI HTTP tests — yeyu-nvidia/Model-Optimizer0 reactions
- Oct 8, 2026Add FP8 zero-scale and export tests — raashish1601/Model-Optimizer0 reactions
- Oct 8, 2026Add native CUDA coverage for MXFP4 packing — raashish1601/Model-Optimizer0 reactions
- Oct 8, 2026Add NVFP4 offloaded export tests and collector typing — niko4244/Model-Optimizer0 reactions
- Oct 4, 2026codex-plugins.github.nvidia.model-optimizer: init at 0.47.0 — sudosubin/agents.nix0 reactions
- Oct 4, 2026codex-marketplaces.github.nvidia.model-optimizer: init at 0.47.0 — sudosubin/agents.nix0 reactions
- Oct 2, 2026build(deps-dev): bump nvidia-modelopt from 0.44.0 to 0.47.0 — ydwhhh/gspo0 reactions
- Sep 30, 2026build(deps-dev): bump nvidia-modelopt from 0.44.0 to 0.47.0 — verl-project/verl0 reactions · 1 comment
- Sep 29, 2026Admin AI: Install skills https://github.com/mattpocock/skills https://github.com/ — mehrshadevilb-cell/ArtistYar-Website0 reactions
- Sep 29, 2026Admin AI: Install skills https://github.com/mattpocock/skills https://github.com/ — mehrshadevilb-cell/ArtistYar-Website0 reactions
- Sep 27, 2026🔥 GitHub Trending AI 早报 · 2026-09-27 · Top 6 项目 — happydog-intj/ai-xiaohongshu-daily0 reactions
- Sep 27, 2026🔥 GitHub Trending AI 早报 · 2026-09-27 · Top 6 项目 — Mystery406/ai-xiaohongshu-daily0 reactions
- Sep 27, 2026Github trending [NVIDIA/Model-Optimizer] 一站式模型量化优化加速 — web1992/github-trending0 reactions
- Sep 26, 2026🔥 GitHub Trending AI 早报 · 2026-09-27 · Top 6 项目 — Mystery406/ai-xiaohongshu-daily0 reactions
- Sep 26, 2026🔥 GitHub Trending AI 早报 · 2026-09-27 · Top 6 项目 — happydog-intj/ai-xiaohongshu-daily0 reactions
- Sep 25, 2026Github trending [NVIDIA/Model-Optimizer] 模型推理加速优化库 — web1992/github-trending0 reactions
- Sep 19, 2026Bump nvidia-modelopt from 0.46.0 to 0.46.1 — marek-burza/shrubbery0 reactions
- Sep 17, 2026Add Anima 2B support to Model Optimizer for calibrated PTQ and future NVFP4 QAT/QAD — ruwwww/Model-Optimizer0 reactions
- Sep 16, 2026build(deps-dev): bump nvidia-modelopt from 0.44.0 to 0.46.1 — verl-project/verl0 reactions · 1 comment
- Sep 15, 2026Bump nvidia-modelopt from 0.44.0 to 0.46.1 — HuipengHuang/opd-rl0 reactions
- Sep 9, 2026build(deps-dev): bump nvidia-modelopt from 0.44.0 to 0.46.0 — HuipengHuang/verl-baseline0 reactions
- Sep 9, 2026[None][docs] retarget ModelOpt examples llm_ptq paths to hf_ptq — NVIDIA/TensorRT-LLM0 reactions · 1 comment
- Sep 4, 2026DeepSeek-V4-Pro-0813-NVFP4 — Bibbleq/frontier-model-tracker0 reactions · 1 comment
- Aug 28, 2026[Doc] Broken links in READMEs referencing files removed by legacy TensorRT backend cleanup — NVIDIA/TensorRT-LLM0 reactions · 1 comment
- Aug 19, 2026Fix ModelOpt integration for the >=0.44 list quant_cfg format — huggingface/diffusers0 reactions
On Bluesky · 4
- Sep 25, 2026📦 NVIDIA / Model-Optimizer ⭐ 3,886 (+22) 🗒 Python A unified library of SOTA model optimization techniques like quantization,… — @github-trending.bsky.social5 likes and reposts
- Sep 27, 2026to optimize inference speed. #devopsish — @chrisshort.net1 likes and repost
- Sep 26, 2026今日のGitHubトレンド NVIDIA/Model-Optimizer NVIDIA Model Optimizerは、量子化やプルーニング、蒸留などの手法を用いてモデルを高速化するためのライブラリです。 Hugging… — @dailygithubtrends.bsky.social1 likes and repost
- Sep 25, 20265. NVIDIA Model-Optimizer Library for Deployment LINK 6. World Action Agent for Robot Manipulation via VLMs LINK — @hackobar.bsky.social0 likes and reposts · 1 reply
In this repository33 other files it gives its agents.
- AGENTS.mdAGENTS.md
- tools/debugger/CLAUDE.mdCLAUDE.md
- tools/launcher/CLAUDE.mdCLAUDE.md
- accessing-mlflowSkill
- benchmark-model-kernelsSkill
- commonSkill
- compare-resultsSkill
- day0-releaseSkill
- debugSkill
- deploymentSkill
- evaluationSkill
- launching-evalsSkill
- modelopt-accessing-mlflowSkill
- modelopt-benchmark-model-kernelsSkill
- modelopt-compare-resultsSkill
- modelopt-day0-releaseSkill
- modelopt-debugSkill
- modelopt-deploymentSkill
- modelopt-evaluationSkill
- modelopt-launching-evalsSkill
- modelopt-monitorSkill
- modelopt-qadSkill
- modelopt-quant-recipe-searchSkill
- modelopt-release-cherry-pickSkill
- modelopt-run-agentxSkill
- modelopt-speculative-decodingSkill
- monitorSkill
- ptqSkill
- qadSkill
- quant-recipe-searchSkill
- release-cherry-pickSkill
- run-agentxSkill
- speculative-decodingSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
18 rules. About 0 are common, 5 are distinctive, and 13 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
13
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 16
Use modelopt-quant-recipe-search for multi-candidate recipe exploration or optimization.
- Very specific: line 21
Use the common skill's environment-setup.md and workspace-management.md.
- Distinctive: line 22
After completing them you should know:
- Very specific: line 32
Check the support table in examples/hf_ptq/README.md for verified HF models.
- Very specific: line 39
If the model uses trust_remote_code (check config.json for auto_map), inspect its custom Python files for imports not present in the …
- Distinctive: line 51
If extra deps are needed:
- Very specific: line 64
If a model-specific recipe exists, prefer --recipe <path> — but inspect its include/exclude patterns rather than assuming (e.g.
- Very specific: line 71
Use --qformat <name> (e.g., --qformat nvfp4).
- Very specific: line 90
Text-only LLM PTQ: Prefer the representative nemotron-post-training-v3 blend.
- Very specific: line 130
Run --help for all options.
- Very specific: line 137
Write a YAML config using common/hf/ptq.sh.
- Very specific: line 151
Follow references/unsupported-models.md.
- Distinctive: line 158
After job submission, register the job and set up monitoring per the modelopt-monitor skill.
- Very specific: line 173
Read references/checkpoint-validation.md and perform all four validation groups on the exact checkpoint path that will be …
- Distinctive: line 175
Check output size and estimated bits per weight against the baseline/source checkpoint.
- Very specific: line 176
Check quantized-weight coverage against the requested qformat/recipe/config.
- Distinctive: line 177
Check metadata consistency against the baseline/source model.
- Very specific: line 185
Call mto.enable_huggingface_checkpointing() before quantization
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
ModelOpt Post-Training Quantization
Produce a quantized checkpoint from a pretrained model. Read examples/hf_ptq/README.md first — it has the support matrix, CLI flags, and accuracy guidance.
Use modelopt-quant-recipe-search for multi-candidate recipe exploration or
optimization. Use this skill for each selected recipe's PTQ run.
Step 1 — Environment
Use the common skill's environment-setup.md and workspace-management.md.
After completing them you should know:
- ModelOpt source is available
- Local or remote (+ cluster config if remote)
- SLURM / Docker+GPU / bare GPU
- Launcher available?
- Which workspace to use
Step 2 — Is the model supported?
Check the support table in examples/hf_ptq/README.md for verified HF models.
- Listed → supported, use
hf_ptq.py(step 4A/4B) - Not listed → read
references/unsupported-models.mdto determine ifhf_ptq.pycan still work or if a custom script is needed (step 4C)
Step 2.5 — Check for model-specific dependencies
If the model uses trust_remote_code (check config.json for auto_map), inspect its custom Python files for imports not present in the container:
grep -h "^from \|^import " <model_path>/modeling_*.py | sort -uKnown dependency patterns:
| Import found | Packages to install |
from mamba_ssm / from causal_conv1d | mamba-ssm causal-conv1d (Mamba/hybrid models: NemotronH, Jamba) |
If extra deps are needed:
- Launcher (4B): set
EXTRA_PIP_DEPSin the task'senvironmentsection —ptq.shinstalls them automatically - Manual (4A):
unset PIP_CONSTRAINT && pip install <deps>before runninghf_ptq.py
Step 3 — Choose quantization format
First, check for a model-specific recipe:
ls modelopt_recipes/models/ 2>/dev/null
ls modelopt_recipes/model_type/<model_type>/ptq/ 2>/dev/null # per-arch; <model_type> from local config.json (Hub ID: AutoConfig.from_pretrained)If a model-specific recipe exists, prefer --recipe <path> — but inspect its include/exclude patterns rather than assuming (e.g. for VLMs, confirm the vision tower is actually excluded).
If no model-specific recipe, choose a format based on GPU (details in examples/hf_ptq/README.md):
- Blackwell (B100/B200/GB200):
nvfp4variants - Hopper (H100/H200) or older:
fp8orint4_awq
Use --qformat <name> (e.g., --qformat nvfp4). Format definitions: modelopt/torch/quantization/config.py. General PTQ recipes in modelopt_recipes/general/ptq/ correspond to the same formats — --qformat is the simpler way to use them.
Before running PTQ, sanity-check the selected qformat/recipe against the model structure. Inspect the recipe's include/exclude patterns and summarize which layer groups will be quantized and approximately how many modules/layers match (attention projections, MLP projections, experts, etc.). If the match count is 0, or far smaller than expected for the model, stop and fix the recipe or ask the user before launching calibration.
VLMs: generic *mlp*/*experts* recipes also match the vision tower (model.visual.*); quantizing the ViT silently breaks image benchmarks. Use the model_type/<model_type>/ptq/ recipe or add *visual*/*vision_tower* excludes, then verify in Step 5 — see references/checkpoint-validation.md.
If the source checkpoint is already quantized and the requested recipe/config reduces quantization coverage, confirm that intent with the user before running. For example, if an FP8 checkpoint is used as input and the recipe excludes some layers so they would fall back to BF16 instead of staying quantized, call out the affected layer groups and ask whether that FP8-to-BF16 fallback is intended.
NVFP4 can be calibrated on Hopper but requires Blackwell for inference.
Step 4 — Run PTQ
Goal: checkpoint on disk (.safetensors + config.json).
For listed models (4A/4B): run full calibration directly (--calib_size 512).
For unlisted models (4C): run a smoke test first (--calib_size 4), wait for success, then full calibration.
Recommended calibration datasets
Text-only LLM PTQ: Prefer the representative
nemotron-post-training-v3blend.modelopt/torch/utils/dataset_utils.pyexpands it to seven registered Nemotron SFT domains. Configure Hugging Face credentials where required.python examples/hf_ptq/hf_ptq.py ... \ --dataset nemotron-post-training-v3VLM PTQ: Include image-text calibration with
--calib_with_images. This path usesnemotron_vlm_dataset_v2with the current default subsetssparsetables,plotqa_cot, andwiki_en;examples/hf_ptq/hf_ptq.pyandmodelopt/torch/utils/vlm_dataset_utils.pyare the source of truth.python examples/hf_ptq/hf_ptq.py ... \ --calib_with_images
--dataset selects text-only calibration and cannot substitute for multimodal examples. Use --dataset cnn_dailymail only as a fallback when representative data is unavailable, such as without gated-data access or with only a local public cache.
Which path?
In README table? ─→ YES ──→ SLURM (local or remote)? ──→ LAUNCHER (4B)
│ Local Docker + GPU? ────────→ LAUNCHER (4B)
│ Remote Docker (no SLURM)? ──→ MANUAL (4A)
│ Bare GPU (local or remote)? → MANUAL (4A)
│
└→ NOT LISTED ──→ UNLISTED MODEL (4C)4A — Direct: supported model, manual execution
pip install --no-build-isolation "nvidia-modelopt[hf]"
pip install -r examples/hf_ptq/requirements.txt
python examples/hf_ptq/hf_ptq.py \
--pyt_ckpt_path <model> \
--qformat <format> \
--calib_size 512 \
--export_path <output>Run --help for all options.
For remote, use remote_run from the common skill's remote_exec.sh; see its
remote-execution.md.
4B — Launcher: supported model on SLURM or local Docker
Write a YAML config using common/hf/ptq.sh. See references/launcher-guide.md for the full template.
cd tools/launcher
# SLURM (remote or local):
SLURM_HOST=<host> SLURM_ACCOUNT=<acct> uv run launch.py --yaml <config.yaml> user=<ssh_user> identity=<ssh_key> --yes
# Local Docker:
uv run launch.py --yaml <config.yaml> hf_local=<hf_cache> --yesThe launcher blocks and tails logs until the job completes. If the launcher fails (missing deps, config errors), fall back to path 4A (manual execution).
4C — Unlisted model
Follow references/unsupported-models.md. It walks through investigating the model, patching ModelOpt if needed, and running hf_ptq.py. Run manually (like 4A) for easier monitoring and debugging.
For SLURM, see the common skill's slurm-setup.md and this skill's
references/slurm-setup-ptq.md.
Monitoring
After job submission, register the job and set up monitoring per the modelopt-monitor skill.
Step 5 — Verify output
ls -lh <output_path>/
# Expect: config.json, tokenizer files, model-*.safetensorsReport the path and size to the user.
Post-quantization validation
This is a required gate before any deployment or evaluation submission. Do not submit an eval, start a production serving job, or hand off the checkpoint as ready until the gate, including its serving canary, has passed.
Read references/checkpoint-validation.md and perform all four validation groups on the exact checkpoint path that will be deployed/evaluated:
- Check output size and estimated bits per weight against the baseline/source checkpoint.
- Check quantized-weight coverage against the requested qformat/recipe/config.
- Check metadata consistency against the baseline/source model.
- Complete the required downstream handoff and serving-readiness validation.
Report the gate result before moving on. Follow the canonical report format and all blocking conditions in references/checkpoint-validation.md; do not hand off a checkpoint unless every required check passes.
Key API Rules
mtq.register()classes must define_setup()and call it from__init__- Call
mto.enable_huggingface_checkpointing()before quantization - Wildcard
*gate*matches too broadly — use*mlp.gate*or*router* - VLMs:
hf_ptq.pyauto-extracts the language model viaextract_and_prepare_language_model_from_vl()— no manual VLM handling needed in most cases - FP8 checkpoints: prefer
_QuantFP8Linear(lazy dequant) overFineGrainedFP8Config(dequantize=True)which wastes ~2x memory. Seereferences/unsupported-models.mdfor details - Custom quantizer names must end with
_input_quantizeror_weight_quantizer
Common Pitfalls
- Model-specific dependencies: Models with
trust_remote_codemay import packages not in the container (e.g.,mamba-ssmfor hybrid Mamba models). See Step 2.5. UseEXTRA_PIP_DEPSenv var with the launcher, or install manually before runninghf_ptq.py - Linear-attention models (Qwen3-Next/3.5/3.8, GLM-5.x Flash, Kimi Linear, OLMo Hybrid) fall back to slow, memory-hungry PyTorch kernels without
pip install "fla-core>=0.5.2"; install it before calibrating on GPU (it breaks CPU runs of these models) - Transformers version: New models may need a newer version of transformers than what's installed. Check
config.jsonfortransformers_version. In containers, beware ofPIP_CONSTRAINTblocking upgrades — seereferences/slurm-setup-ptq.mdfor workarounds - Gated datasets: Some calibration datasets require HF authentication. Set
HF_TOKENin the job environment. Use--dataset cnn_dailymailonly as the constrained-environment fallback described in Step 4, not as the preferred calibration set - NFS root_squash + Docker: See the common skill's
slurm-setup.mdsection 5
References
| Reference | When to read |
common skill: environment-setup.md | Step 1: always |
common skill: workspace-management.md | Step 1: always |
references/launcher-guide.md | Step 4B only (launcher path) |
tools/launcher/CLAUDE.md | Step 4B only, if you need more launcher detail |
references/unsupported-models.md | Step 4C only (unlisted model) |
references/checkpoint-validation.md | Step 5: mandatory post-PTQ gate before deployment/evaluation |
common skill: remote-execution.md | Step 4A/4C only, if target is remote |
common skill: slurm-setup.md | Step 4A/4C only, if using SLURM manually (not launcher) |
references/slurm-setup-ptq.md | Step 4A/4C only, PTQ-specific SLURM (container, GPU sizing, FSDP2) |
examples/hf_ptq/README.md | Step 3: support matrix, CLI flags, accuracy |
modelopt/torch/quantization/config.py | Step 3: format definitions |
modelopt/torch/export/model_utils.py | Step 4C: TRT-LLM export type mapping |
modelopt_recipes/ | Step 3: pre-built recipes |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

