quark-torch-quant-plan

SkillAI & models

Build a Quark Torch LLM PTQ quantization plan from model analysis and user intent. Use when the user needs quantization scheme recommendations, exclusion lists, algorithm selection, KV cache decisions, per-layer overrides, or a draft quant_plan. Trigger for "quantize with FP8", "what scheme should I use", "plan PTQ", "INT4 quantization", "choose quantization config", "quantization plan", or when the user has a model analysis and needs to decide how to quantize it.

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the quark-torch-quant-plan skill

What this skill tells your AI

The instructions your AI receives, as published by amd/quark in .claude/skills-impl/l1-atomic/torch/quark-torch-quant-plan/SKILL.md and read by ahel’s review.

Purpose

Convert a model analysis plus the user's intent into a confirmed quant_plan.json. This skill makes the quantization decisions — which scheme, which algorithm, what to exclude — without generating scripts or executing PTQ. The plan is the contract between the user's intent and the execution step.

Inputs

  • model_analysis.json from quark-torch-model-intake
  • env_context.json for accelerator-aware scheme recommendations
  • User preferences (target precision, accuracy goal)

Outputs: quant_plan.json

Records the chosen scheme, algorithm, layer overrides, calibration settings, and evaluation intent.

Schema: quant_plan.schema.json

{
  "model": {
    "model_type": "qwen3",
    "analysis_ref": "./model_analysis.json"
  },
  "global_scheme": "fp8",
  "kv_cache_scheme": "fp8",
  "exclude_layers": ["lm_head"],
  "layer_quant_config": {},
  "algorithm": null,
  "calibration": {
    "dataset": "pileval",
    "num_calib_data": 128,
    "seq_len": 512
  },
  "evaluation_intent": "smoke",
  "requires_confirmation": false
}

Available Quantization Schemes (21 total)

Weight-Only INT4 (best for deployment size reduction)

SchemeDescriptionUse Case
int4_wo_32INT4, group size 32Highest accuracy among INT4
int4_wo_64INT4, group size 64Good balance
int4_wo_128INT4, group size 128Smaller overhead
int4_wo_per_channelINT4, per-channelLeast overhead
uint4_wo_32/64/128/per_channelUnsigned INT4 variantsGGUF export compatibility

Weight+Activation INT8

SchemeDescriptionUse Case
int8INT8 per-tensor for both W and ACPU deployment, good accuracy

FP8 (best accuracy-size tradeoff for GPU inference)

SchemeDescriptionUse Case
fp8FP8 E4M3 per-tensorStandard GPU quantization
ptpc_fp8Per-Token-Per-Channel FP8Higher accuracy, dynamic activation quantization

OCP Microscaling Formats

SchemeDescriptionUse Case
mxfp4OCP MXFP4Aggressive compression
mxfp6_e3m2OCP MXFP6 (E3M2)Better range
mxfp6_e2m3OCP MXFP6 (E2M3)Better precision
mxfp4_mxfp6_e2m3MXFP4 weights + MXFP6 activationsMixed precision
mxfp4_fp8MXFP4 weights + FP8 activationsMixed precision

AMD-Specific

SchemeDescriptionUse Case
amdfp4amdfp4, group size 16AMD MI300X optimized
amdfp4_g32amdfp4, group size 32AMD MI300X, less overhead

Other

SchemeDescriptionUse Case
nvfp4NVFP4: FP4 group_size=16 with FP8 E4M3 scaleNVIDIA Blackwell/Hopper
mx6MX6 formatExperimental
bfp16Block Floating Point 16-bitExperimental
int4_wa_64INT4 weights + activations, group 64Research

Available Algorithms (7 primary)

AlgorithmCompatible SchemesDescription
awqINT4/UINT4 weight-onlyActivation-aware weight quantization — finds optimal per-channel scaling
gptqINT4/UINT4 weight-onlySecond-order weight optimization — often better than AWQ for small models
smoothquantINT8, FP8Migrates quantization difficulty from activations to weights
autosmoothquantINT8, FP8Automatic SmoothQuant with optimal alpha search
rotationVariousRotation-based optimization to equalize weight distribution
gptaqINT4/UINT4GPTAQ variant combining GPTQ with activation quantization
qronosVariousCustom algorithm for time-series-aware quantization

Algorithms can be combined: --quant_algo awq,smoothquant

KV Cache Quantization

  • Only fp8 is supported for KV cache (--kv_cache_dtype fp8)
  • Adds --min_kv_scale option (default 0.0) to prevent extreme scale values
  • --kv_cache_post_rope quantizes KV cache after RoPE (inside cache) instead of at k_proj/v_proj outputs — can improve accuracy for some models

Decision Guide

Help the user choose based on their priorities:

"I want the best accuracy"fp8 or ptpc_fp8, optionally with smoothquant "I want the smallest model"int4_wo_32 with awq or gptq "I need CPU deployment"int8 (the only scheme that works well on CPU) "I need GGUF format"uint4_wo_32 with awq, export as GGUF "I'm on AMD MI300X"amdfp4 for best hardware utilization "I'm on NVIDIA H100/Blackwell"fp8 or nvfp4 "I want to experiment"mxfp4 for aggressive compression research

Decision Table (MUST show to user)

ALWAYS present this table to the user and WAIT for confirmation before finalizing. Do not skip this step.

Fill in the "Value" column based on the user's request and model analysis, then show:

DecisionValueReason
global_scheme(fill)(why this scheme)
kv_cache_scheme(fill: fp8 or null)(explain)
exclude_layers["lm_head"]Standard — lm_head stays full precision
layer_quant_config(fill: dict of pattern -> scheme, or {} if none)(explain which patterns and why)
algorithm(fill: algorithm or null)(explain)
calibration_datasetpilevalFast default
num_calib_data128Standard default
seq_len512Standard default
evaluation_intentsmokeQuick PPL check post-quantization

After showing the table, ask: "Confirm this plan? Any changes?"

Do NOT proceed until the user confirms.

Layer-Specific Overrides via layer_quant_config

The layer_quant_config plan field is a dict of pattern -> scheme pairs. It is the single mechanism for any "quantize layer/module X with scheme Y" intent — including attention modules, MoE experts, lm_head, etc. Each entry emits one --layer_quant_scheme PATTERN SCHEME CLI argument.

"layer_quant_config": {
  "*self_attn*": "fp8",
  "lm_head": "int8",
  "*experts*": "fp8"
}

translates to:

--quant_scheme <global_scheme> \
--layer_quant_scheme '*self_attn*' fp8 \
--layer_quant_scheme lm_head int8 \
--layer_quant_scheme '*experts*' fp8

When a user asks for attention-module quantization (e.g. "self_attn in fp8"), populate this field with the appropriate pattern (commonly *self_attn* for LLaMA-style models; adjust for models whose attention submodule has a different name). Do NOT introduce a dedicated attention field — keep all per-pattern overrides in layer_quant_config.

Rules

  • Keep scope to plan creation only. Do not generate scripts, do not run quantization, do not export. Those are separate skills.
  • Require a model analysis first. Without knowing the model architecture and layer count, you cannot make informed scheme recommendations. If model_analysis.json is missing, route back to quark-torch-model-intake.
  • Always present the decision table before finalizing. The user should explicitly confirm the scheme, algorithm, and exclusions.
  • If a risky scheme is chosen (e.g., mxfp4 on a model where accuracy loss may be significant), keep the user's choice but record the risk in the plan.

Interaction Flow

  1. Check prerequisites: Is model_analysis.json available? If not, route to quark-torch-model-intake first.
  2. Gather intent: What does the user care about most — accuracy, size, speed? What hardware will run inference?
  3. Present the decision table: Show defaults, explain the tradeoffs, and let the user adjust.
  4. Confirm: Always required. Show the final plan summary before writing it.
  5. Emit: Write quant_plan.json.

Recovery

  • If the model analysis is incomplete, produce a draft plan with requires_confirmation: true and note what facts are missing.
  • If the user picks an unusual combination (e.g., awq with fp8 — AWQ is designed for INT4), explain why it might not work well and suggest alternatives, but respect the user's choice if they insist.
  • If calibration dataset preferences are unclear, default to pileval with 128 samples — it is the fastest option and works for most models.

Signals

GitHub stars
166
Forks
33
Last commit
Aug 2026
Advanced
Catalog kind
skill
Gateway key
quark-torch-quant-plan
Source
github.com/amd/quark