agentleFS
intelintel/neural-compressor/.claude/skills/add-llm-example/SKILL.md

add-llm-example

Skill2.7k starsChanged 13 days agoApache-2.0View on GitHub

Add a new LLM quantization example under examples/pytorch/llm (quantize.py, run_quant.sh, run_benchmark.sh, README). Use when onboarding a new model family such as Qwen, DeepSeek, Llama, MiniMax, Kimi or GLM, or when an existing example's scripts need to follow the shared CLI conventions.

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Every example under examples/pytorch/llm/<model>/ exposes the same CLI so that users and CI can drive any model the same way.

    line 8
  2. Very specific:

    All shell scripts accept only --key=value form.

    line 22
  3. Very specific:

    Do not re-implement argument parsing, tensor-parallel detection, server lifecycle, or the --scheme environment matrix — the shared driver …

    line 117

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Add a new LLM quantization example

Every example under examples/pytorch/llm/<model>/ exposes the same CLI so that users and CI can drive any model the same way. Follow the layout below.

examples/pytorch/llm/<model>/
├── quantize.py        # AutoRoundConfig presets + prepare/convert
├── run_quant.sh       # quantization entry point
├── run_benchmark.sh   # thin wrapper over the shared lm-eval driver
├── requirements.txt
└── README.md

CLI conventions

All shell scripts accept only --key=value form. Do not add --key value variants. Unknown flags must print usage and exit non-zero.

run_quant.sh

FlagDefaultNotes
--dtype=requiredpreset key, e.g. mxfp4, mxfp8, nvfp4
--input_model=requiredHF model ID or local path
--output_model=requiredoutput directory
--export_format=llm_compressorauto_round or llm_compressor
--static_kv_dtype=autofp8 enables static KV quantization
--static_attention_dtype=autofp8 enables static attention quantization

auto means "not set" — only forward the flag to quantize.py when the value differs from auto. Collect optional flags in a bash array, never a string:

EXTRA_ARGS=()
if [[ "$STATIC_KV_DTYPE" != "auto" ]]; then
  EXTRA_ARGS+=(--static_kv_dtype "$STATIC_KV_DTYPE")
fi
python quantize.py ... "${EXTRA_ARGS[@]}"

Under set -e, do not use [[ cond ]] && CMD as the last statement of a block — a false condition exits the script. Use if.

Variable naming: DTYPE, INPUT_MODEL, OUTPUT_MODEL, EXPORT_FORMAT, STATIC_KV_DTYPE, STATIC_ATTENTION_DTYPE.

quantize.py

Argument names mirror the rest of the repo, not the shell flag names:

Shell flagquantize.py argument
--input_model=--model_name_or_path
--output_model=--export_path
--dtype=--dtype
--export_format=--export_format

Static quantization dtypes use choices=["fp8", "float8_e4m3fn"] and default=None.

Structure: a module-level preset dict keyed by --dtype, a build_config(args) returning AutoRoundConfig, then prepare / convert.

_PRESET_CONFIG = {
    "mxfp4": {"scheme": "MXFP4", "layer_config": None},
    "mxfp8": {"scheme": "MXFP8", "layer_config": None},
}

Notes:

  • llm_compressor export does not support _RCEIL schemes — strip the suffix when export_format != "auto_round".
  • Set iters=0 for model-free / RTN-style presets.
  • Static KV or attention quantization needs the real model, so model_free must be False when either is set.

run_benchmark.sh

This is a thin wrapper (20–40 lines) over benchmark/lm_eval/run_lm_eval.sh. It must not parse user arguments — pass "$@" straight through. It only exports model-family specific settings:

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
REPO_ROOT=$(cd -- "${SCRIPT_DIR}/../../../.." && pwd)

export DEFAULT_SCHEME="mxfp8"
export ATTENTION_BACKEND_FP8KV="FLASHINFER"

bash "${REPO_ROOT}/benchmark/lm_eval/run_lm_eval.sh" "$@"

Hooks understood by the shared driver:

VariablePurpose
DEFAULT_SCHEMEdefault value for --scheme
ATTENTION_BACKEND_FP8KVbackend when --static_kv_dtype=fp8 (MLA models use FLASHINFER_MLA)
ATTENTION_BACKEND_FP8ATTNbackend when --static_attention_dtype=fp8 (TRITON_ATTN takes a different code path)
FLASHINFER_WORKSPACE_SIZEVLLM_AR_FLASHINFER_WORKSPACE_BUFFER_SIZE
EXTRA_SERVE_ARGSextra flags for vllm serve
EXTRA_LM_EVAL_MODEL_ARGSextra ,key=value pairs for --model_args
ROPE_SCALING_JSONenables rope scaling on vllm serve
SKIP_ROPE_SCALING_PATTERNmodel name substring that disables rope scaling

Anything task-driven (new benchmark suite, chat-template task, long-context routing) belongs in the shared driver, not in the wrapper. Anything that depends on the model architecture belongs in the wrapper.

Do not re-implement argument parsing, tensor-parallel detection, server lifecycle, or the --scheme environment matrix — the shared driver owns them. Tensor parallel size is always inferred from CUDA_VISIBLE_DEVICES.

README

Mirror the structure of examples/pytorch/llm/qwen/README.md: quantization commands per dtype, then evaluation commands. Use --key=value in every example command, and prefix eval commands with CUDA_VISIBLE_DEVICES=....

Validation

bash -n examples/pytorch/llm/<model>/run_quant.sh
bash -n examples/pytorch/llm/<model>/run_benchmark.sh
python -c "import ast; ast.parse(open('examples/pytorch/llm/<model>/quantize.py').read())"

Smoke-test argument routing without a GPU by putting a stub lm_eval on PATH:

mkdir -p /tmp/fakebin && printf '#!/bin/bash\necho "[lm_eval] $*"\n' > /tmp/fakebin/lm_eval
chmod +x /tmp/fakebin/lm_eval
PATH=/tmp/fakebin:$PATH CUDA_VISIBLE_DEVICES=0,1 bash run_benchmark.sh --model_path=<dir>

New files under neural_compressor/ need the Apache 2.0 header; example files follow the same convention. Run pre-commit run --files <changed files> before committing.

Download now (ZIP)

Trending

Quiet since July.about the whole repository

Dec 2025: 3 mentionsJan 2026: 1 mentionFeb 2026: 0 mentionsMar 2026: 2 mentionsApr 2026: 1 mentionMay 2026: 3 mentionsJun 2026: 2 mentionsJul 2026: 1 mentionAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the intel/neural-compressor repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about intel/neural-compressor

The biggest 5 of 45 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 45

Talked about on GitHub and Stack Overflow (45 times).

On GitHub · 44

39 more on GitHub

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

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.