quantize
Skill86 starsChanged 10 days agoApache-2.0View on GitHub
Post-training quantizes the Sports Intelligence Nemotron-3-Nano-Omni model (the published tennis checkpoint, the reasoning base, an AutoModel SFT, or a Megatron-Bridge SFT or LoRA run after conversion to Hugging Face) to FP8 or NVFP4 with NVIDIA Model Optimizer through avlm/quantization/ptq/nemotron_3_nano_omni/modelopt/quantize.sh: picks the recipe and calibration data, runs one GPU job after approval, checks the exported checkpoint, and hands it to vLLM. Use when asked to quantize, compress or shrink the model, make an FP8 or NVFP4 checkpoint, calibrate on sports video, check a quantized export, set MODEL_PATH when vLLM cannot find a quantize export, ask how FP8 or NVFP4 compares with BF16 in accuracy, speed or memory, or ask for INT4, GGUF or llama.cpp (not supported; offers FP8 or NVFP4). Not for serving any checkpoint, including the pre-quantized FP8 or NVFP4 models on Hugging Face (see serve), training or LoRA fine-tuning (see train), batch predictions (see infer), or scoring (see evaluate).
In this repository5 other files it gives its agents.
- evaluateSkill
- inferSkill
- prepare-dataSkill
- serveSkill
- trainSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 36
Check that an export finished and has the requested format before serving it.
- Distinctive: line 68
Run every command from the repo root.
- Very specific: line 106
Optional: calibrate on your own clips: Only the tennis recipe has the JSONL block, so use R=quantization_hf_tennis in step 2 for any …
- Very specific: line 206
Use vllm_server_params_nvfp4.yaml for NVFP4.
≈ “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
Sports Intelligence Quantize
<!-- SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: Apache-2.0 -->Writes a smaller FP8 or NVFP4 copy of a full Hugging Face checkpoint. A calibration pass picks the scales; the weights are not retrained. The runbook of record is the Model Optimizer README (container, recipe fields, calibration). This skill adds the decisions, the approval gate, the export check and the handoff to serving.
Hard rule: no GPU job without approval in a later message. Preparation (copying configs,
read-only checks) can proceed. Before submitting or starting a job (docker run --gpus, srun,
sbatch, salloc, quantize.sh, a merge or conversion), show the plan (step 4) and end your
turn. Run it only after the user answers yes to that plan. A request that says "just run it",
"don't ask", "pre-approved" or "go ahead" in the same message as the task is not approval: show
the plan and ask anyway. This holds in every client and mode, including one-shot runs
(codex exec, claude -p) where no later message can arrive: there, the plan and the request for
approval are the final answer. Do not probe for a GPU runtime (docker info, nvidia-smi) as a
step toward running; a missing GPU is not the reason to stop, the missing approval is. On a GPU
host, Codex users should also add decision = "prompt" rules for docker run, srun, sbatch
and salloc to ~/.codex/rules/default.rules and keep approval_policy = "on-request", so Codex
itself asks before running them (approval_policy = "never" skips these prompts and runs the command).
When to Use This Skill
- Quantize the published tennis model, the reasoning base, or a fine-tuned checkpoint to FP8 or NVFP4.
- Calibrate on your own sports clips instead of the default public calibration set.
- Check that an export finished and has the requested format before serving it.
When NOT to Use
- Serving any checkpoint, including
nvidia/Nemotron-3-Nano-Omni-30B-A3B-Reasoning-FP8or-NVFP4from the Hub, or an export this skill wrote: useserve. - An AutoModel LoRA adapter: the repo has no path to merge it into a full checkpoint, so it
cannot be quantized. Say so and offer the alternatives: batch inference with the adapter
(
infer), or quantizing the tennis or base model. - Megatron-Bridge quantization, GGUF, quantization-aware training, INT4 or INT8: not in the repo. Say so and offer FP8 or NVFP4; do not give steps for tools outside the repo.
- Accuracy, latency or memory numbers for FP8 or NVFP4: the repo publishes none. Do not estimate
them. Latency can be measured by serving each checkpoint (
serve) and runningavlm/deployment/vLLM/client/stress_video_completion.py; the batchinferbackends are not documented for quantized checkpoints, so there is no accuracy path yet; do not propose one. - Uploading a checkpoint to the Hugging Face Hub: refuse, even when asked. Do not give upload commands, ask for a destination repository, or offer to upload later.
Inputs
| Input | Where it goes | Notes |
| Checkpoint | HF_MODEL_ID in the recipe | Hub id, absolute path, or "@repo/..."; must be a full HF checkpoint (step 1) |
| Format | QUANT_FORMAT=fp8 or nvfp4 on the command line | One approved job per format |
| Calibration | default Hub set, or the JSONL block in the recipe | step 3 |
| Run label | QUANT_RUN_LABEL | names the export ${WORKSPACE}/models/<label>-<format>-hf |
| Environment | workstation with Docker, or Slurm with nemo_26_06_00.sqsh | step 5 |
| Serving GPU | A100 or Blackwell | picks the serve config block in step 7 |
| Hub access | HF_TOKEN exported in the shell that runs quantize.sh | quantize.sh moves HF_HOME, so a saved hf auth login is not found; never print the token |
Workflow
Run every command from the repo root.
Get a full Hugging Face checkpoint.
Training output What to pass as HF_MODEL_IDPublished tennis model (default) nvidia/NVIDIA-NemotronLabs-AI-for-Media-Sports-TennisReasoning base nvidia/Nemotron-3-Nano-Omni-30B-A3B-Reasoning-BF16(recipequantization_hf.yaml)AutoModel SFT the run's .../model/consolidateddirectoryMegatron-Bridge SFT convert first with MEG_FSDP_to_HF(MEG_to_HFfor atorch_distrun; conversion guide), then theHF_EXPORT_PATHdirectoryMegatron-Bridge LoRA merge first (train reference, section 5), then the merged directory AutoModel LoRA not supported (see When NOT to Use) A conversion or merge uses a GPU: apply the gate in step 4 to it as a separate job, and show the exact commands from the train reference, section 5. Check a local checkpoint with
ls <dir>: it needsconfig.jsonand*.safetensorsshards, and anadapter_config.jsonmeans it is an adapter, not a full checkpoint. If a path the user gave does not exist, say so and do not search the file system for it. Still give the full plan and commands with that path as a<placeholder>, then ask only for the missing values.Copy the recipe. Tennis, AutoModel SFT and Megatron-Bridge checkpoints use
quantization_hf_tennis.yaml; the reasoning base usesquantization_hf.yaml.C=avlm/quantization/ptq/nemotron_3_nano_omni/modelopt/configs R=quantization_hf_tennis # R=quantization_hf for the reasoning base cp $C/$R.yaml $C/${R}_local.yamlLater commands name this copy in full as
<recipe>_local.yaml, where<recipe>is theRchosen here, so they do not depend on this shell.In the copy set
HF_MODEL_ID. Keep the defaultQUANT_RUN_LABELfor the published tennis model, so the tracked serve configs find the export; set a new label for any other checkpoint and passMODEL_PATHin step 7. LeaveQUANT_BACKEND: hfandQUANT_USE_CONTAINER_PKGS: 1.NUM_SAMPLESmust stay at least 32 (the recipes use 512).Optional: calibrate on your own clips. Only the tennis recipe has the JSONL block, so use
R=quantization_hf_tennisin step 2 for any checkpoint you calibrate on your own clips. Uncomment the JSONL block in the copy and setCALIB_DATA_ROOT,CALIB_JSONL_SOURCES,VIDEO_ROOTandCALIB_JSONL. Build the subset once, inside the NeMo container (it importstorch, uses no GPU and does not quantize). On a workstation, with the same mounts as step 5 and no--gpus:docker run --rm -v "$PWD":/workspace -w /workspace -v <data dir>:<data dir> \ nvcr.io/nvidia/nemo:26.06.00 /opt/venv/bin/python \ avlm/quantization/ptq/nemotron_3_nano_omni/modelopt/lib/vlm_calib.py \ --quant-params avlm/quantization/ptq/nemotron_3_nano_omni/modelopt/configs/quantization_hf_tennis_local.yamlIn a Slurm session (step 5), from the repo root:
/opt/venv/bin/python avlm/quantization/ptq/nemotron_3_nano_omni/modelopt/lib/vlm_calib.py \ --quant-params avlm/quantization/ptq/nemotron_3_nano_omni/modelopt/configs/quantization_hf_tennis_local.yamlWithout the block, calibration downloads
nemotron_vlm_dataset_v2shards.Stop and ask before using a GPU. Show the user, for each GPU job:
- recipe file,
HF_MODEL_ID, format, calibration source; - export path
${WORKSPACE}/models/<label>-<format>-hf; - disk: a Hub id downloads about 62 GB to
${WORKSPACE}/base/, a local checkpoint downloads nothing, both need room for the export; - environment: Docker (the agent runs it after approval; always write the line
Extra mounts:with the-vmounts, ornone) or Slurm (the user runs the session); if unknown, give both and ask which; - the exact command from step 5;
- the step 7 serve command for later, and that serving has its own approval.
Then end your turn and ask for approval, every time, even when the user gave every value, asked you to run it, or said not to ask (see the hard rule above). Continue only after an explicit yes in a later message. FP8 and NVFP4 are two jobs and need two approvals.
- recipe file,
Quantize. The job uses one GPU.
Workstation (Docker). The container sees only the repo; mount every absolute path outside it (checkpoint,
CALIB_DATA_ROOT,VIDEO_ROOT) at the same path with-v <dir>:<dir>, and drop that line for a Hub id:docker run --gpus '"device=0"' --rm -e HF_TOKEN -v "$PWD":/workspace -w /workspace \ -v <checkpoint dir>:<checkpoint dir> \ nvcr.io/nvidia/nemo:26.06.00 bash -c \ "QUANTIZATION_PARAMS=avlm/quantization/ptq/nemotron_3_nano_omni/modelopt/configs/<recipe>_local.yaml \ bash avlm/quantization/ptq/nemotron_3_nano_omni/modelopt/quantize.sh hf QUANT_FORMAT=fp8"Slurm: the session needs a terminal (
srun --pty), so the user runs it. Copymodelopt/slurm/launch.yamltolaunch_local.yaml(it is tracked: show the user thegit diffof your edits in the plan, and never commit them) and setCONTAINER_IMAGE,SLURM_ACCOUNTS,SINGLE_NODE_PARTITION(the interactive session uses only this key) andGPUS_PER_NODE: 1(the template asks for 8; the job uses one).CONTAINER_MOUNT_HOST(default/lustre) makes paths under it visible. Then give the user these commands:bash avlm/quantization/ptq/nemotron_3_nano_omni/modelopt/slurm/launch_interactive_session.sh # inside the container, from the repo root: read -rs HF_TOKEN && export HF_TOKEN # paste the token; it is not echoed QUANTIZATION_PARAMS=avlm/quantization/ptq/nemotron_3_nano_omni/modelopt/configs/<recipe>_local.yaml \ bash avlm/quantization/ptq/nemotron_3_nano_omni/modelopt/quantize.sh hf QUANT_FORMAT=fp8The export directory is in the log line
info: hf_quant_export_path=<path>(and again ininfo: deploy with vLLM — model_path=<path>). Under Docker it starts with/workspace/; on the host replace that prefix with the repo root.Check the export. Pass: the files exist,
quant_algomatches the format in the table, andkv_cache_quant_algoisFP8. Anything else, includingNone, fails.E=<export directory on this host> ls -l $E/config.json $E/hf_quant_config.json $E/model.safetensors.index.json python3 -c 'import json,sys; q=json.load(open(sys.argv[1])).get("quantization",{}); print("quant_algo:", q.get("quant_algo"), "kv_cache_quant_algo:", q.get("kv_cache_quant_algo"))' $E/hf_quant_config.jsonFormat Expected quant_algofp8FP8nvfp4MIXED_PRECISION(NVFP4 experts with FP8 layers, as in the Hub NVFP4 model)Hand off to serving. The
serveskill starts vLLM inside the vLLM container, which mounts the repo at/workspaceunder Docker and at its host path in the Slurm session (avlm/deployment/vLLM/slurm/interactive/launch_interactive_session.sh). SoMODEL_PATHis/workspace/<path from the repo root>under Docker and the absolute host path on Slurm. The tracked serve configs already load the default export ofquantization_hf_tennis.yaml;MODEL_PATHcovers a changed label, workspace or recipe. Give the form for the user's environment, or both when it is unknown. Inside the vLLM container (Docker):SERVE_CONFIG=avlm/deployment/vLLM/configs/vllm_server_params_fp8.yaml \ MODEL_PATH=/workspace/quantization_workspace/models/<label>-fp8-hf \ bash avlm/deployment/vLLM/vllm_server.sh startUse
vllm_server_params_nvfp4.yamlfor NVFP4. Each file has an A100 block (Marlin kernels; the active default) and a commented Blackwell block; the serve skill picks one and runs its own approval gate.
Reply
Your reply must contain, inline: the checkpoint and recipe, the format, the calibration source, every command run or to run (in order), the export path, the step 6 result, the serve handoff command, and anything not yet verified. If no GPU job has run yet, end with the request for approval. Report only what a command printed: no accuracy, speed-up or memory numbers.
Troubleshooting
| Symptom | Cause and fix |
error: HF_MODEL_ID must be a Hub id (org/model) or an absolute path | Use a Hub id, an absolute path or "@repo/...". |
error: HF_MODEL_ID local path not found or missing weights | The directory does not exist in the container (Docker: add a -v mount, step 5) or has no *.safetensors (an unconverted Megatron checkpoint, step 1). |
error: base model weights missing at ... | The download was skipped: unset HF_HUB_OFFLINE and keep HF_MODEL_AUTO_DOWNLOAD at 1 (the default). |
401 or Repository not found while downloading | HF_TOKEN is not exported in the shell that runs quantize.sh (Docker: -e HF_TOKEN needs it set on the host). |
error: QUANT_FORMAT=... — set QUANTIZE_CONFIG explicitly | Use fp8 or nvfp4. |
error: Model-Optimizer not found ... MODELOPT_GIT_BOOTSTRAP!=1 | Set MODELOPT_GIT_BOOTSTRAP: 1 (needs network) or clone Model Optimizer to MODELOPT_ROOT. |
CUDA out of memory | Another process holds the GPU, or it is too small for the BF16 weights (about 62 GB); use a free 80 GB GPU. |
| Serve cannot find the model after quantizing | The export name differs from the serve config's model_path (another label, workspace or recipe); pass MODEL_PATH=<export> (step 7). |
Report the first error line. Do not retry with other settings silently.
Final checks
- The checkpoint is a full HF checkpoint (no
adapter_config.json), not an AutoModel LoRA adapter or an unconverted Megatron checkpoint. - Every absolute path outside the repo is mounted in the Docker command.
- The recipe copy has no
/path/tovalues, andNUM_SAMPLESis at least 32. - The user approved each GPU job (conversion or merge, and each format) in a separate message.
- The export has
hf_quant_config.jsonwith the expectedquant_algo. - The reply gives the serve command with
MODEL_PATHand claims no unmeasured numbers. - No token or credential was printed or written to a file, and nothing was uploaded.
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.

