Quark torch llm ptq eval

From amd/Quark · View interactive version

Quark torch llm ptq eval is an AI agent skill from the GitHub repository amd/Quark. L3 recipe that runs a Torch LLM PTQ end-to-end for AMD Quark — for PyTorch / HuggingFace transformers models (safetensors input): quantize → validate → evaluate. Phase 1 delegates the full PTQ path (model intake → quantization planning → manifest generation → confirmed execution) to the `quark-torch

How to use this skill

Skill file

quark-torch-llm-ptq-eval

Purpose

Run the complete PTQ lifecycle for a Torch LLM in one recipe: quantize → validate → evaluate.

This recipe composes existing skills rather than re-implementing them — Phase 1 hands off to the

quark-torch-ptq workflow (L2) for the PTQ steps, then Phases 2 and 3 chain the atomic validation

and evaluation skills (L1). The end result is identical to running the PTQ workflow and then the

validator and eval skills by hand; this recipe just drives the whole chain so the user does not have

to invoke them separately.

Use this recipe when the user wants quantization plus a correctness and/or accuracy check in a

single flow. If they only want the quantized model (no validation, no eval), route to quark-torch-ptq

instead — do not run this recipe and then skip its later phases.

Inputs

Outputs

CRITICAL RULES

  1. Compose, do not re-implement. Phase 1 is the quark-torch-ptq workflow run verbatim, with all

its checkpoints. Do not inline or re-derive the intake/plan/manifest/execute steps here.

  1. STOP at every checkpoint surfaced by the delegated workflow and at this recipe's eval checkpoint.
  2. Validation (Phase 2) is mandatory and automatic. Evaluation (Phase 3) requires explicit user opt-in.
  3. NEVER modify Quark's own source code or examples. The Quark repo (quark/, examples/, tools/,

docs/, tests/) is read-only. See the same rule in the quark-torch-ptq workflow.

Required Artifact Flow

Phase 1 (PTQ via quark-torch-ptq)
  Step 1 (Intake)   ──► model_analysis.json
  Step 2 (Plan)     ──► quant_plan.json
  Step 3 (Manifest) ──► run_manifest.yaml      (contains the exact command)
  Step 4 (Execute)  ──► quantized model output (only after user says yes)
Phase 2 (Validate)  ──► validation_report.md   (auto, mandatory)
Phase 3 (Eval)      ──► eval_report.md         (optional, requires user opt-in + ROCm for Tier 3)

Phase 1: Quantize (delegate to `quark-torch-ptq`)

Goal: Produce the quantized model plus model_analysis.json, quant_plan.json, and run_manifest.yaml.

Run the quark-torch-ptq workflow end-to-end (its Steps 1–4, including CHECKPOINT 1/2/3 and the

Step 3 "shall I run this?" confirmation). Carry forward, for the later phases:

Do not proceed to Phase 2 until Phase 1 has produced a quantized model in <OUTPUT_DIR>. If the PTQ

workflow stops at a checkpoint or fails, stop here too — there is nothing to validate or evaluate.


Phase 2: Validate Output

Goal: Verify the quantized model is structurally sound. Runs automatically after Phase 1.

Actions

Call quark-torch-result-validator with:

The validator runs four checks (fuzzy header → aux files → config.json → MD5) and emits validation_report.md.

Result handling

No checkpoint — validation is mandatory and automatic.


Phase 3: Optional Accuracy Evaluation

Goal: Measure post-quantization accuracy and judge whether quantization hurt the model. Opt-in only.

Actions

Ask the user which evaluation tier to run (or skip):

| Tier | Method | Speed | Notes |

|------|--------|-------|-------|

| 1. Quick — PPL | perplexity (e.g. wikitext) | fast, ~minutes | sanity check; runs on the quant device, no serving |

| 2. Medium — lm_eval | Python lm-eval library, direct generation | slow — warn the user it can take a very long time (no high-throughput serving) | task benchmark, e.g. gsm8k |

| 3. Full — accelerated | hand off to quark-torch-llm-eval: vLLM in docker + lm_eval over the OpenAI endpoint | fast + comprehensive | ROCm only |

| Skip | "no" | — | finalize the recipe |

>>> CHECKPOINT: User must explicitly pick a tier (or skip) before eval runs

  1. Estimate the runtime before launching, based on tier, model size, benchmark size, and hardware. Confirm before a long run. Rough guide:

Tier 3 requires ROCm. If the host is not ROCm, only tiers 1-2 are available — note this and offer the deferred command:

```text

Full accelerated eval requires AMD ROCm. To run later on a ROCm host:

/quark-torch-llm-eval model_path=<OUTPUT_DIR> benchmark=gsm8k

```

  1. Run the chosen tier:

Then hand off to quark-torch-llm-eval with model_path=<OUTPUT_DIR>, benchmark=<choice>, backend=vLLM. It runs its own flow and produces eval_report.md.

Known eval gotchas (apply while driving the eval skill / lm_eval):

  1. Report scores, then assess impact (impact assessment is opt-in).
  1. If skip → finalize, report all artifacts, recipe complete.

Complete Example

For an end-to-end walkthrough (FP8 quantization of Qwen3-8B, then validate + eval), see

CODE0 alongside this file.

Recovery

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.