Quark torch export

From amd/Quark · View interactive version

Quark torch export is an AI agent skill from the GitHub repository amd/Quark. Prepare export and downstream evaluation handoff for a planned or completed Quark PTQ run. Use when the user wants to export a quantized model to HuggingFace SafeTensors, ONNX, or GGUF format, package for deployment, or set up post-quantization evaluation. Trigger for "export model", "save quantized

How to use this skill

Skill file

quark-torch-export

Purpose

Translate a confirmed quantization plan into export expectations and downstream evaluation requirements. Export is a post-quantization step — the model must be quantized first (or have a plan to be quantized) before export decisions make sense. This skill ensures the right export format is chosen and evaluation is properly configured.

Inputs

Outputs: run_manifest.yaml

Export does not own this artifact — it updates the workflow's manifest with export and evaluation config.

Schema: CODE0

(Export updates the workflow's run_manifest.yaml with export and evaluation fields rather than producing a new artifact.)

export:
  formats:
    - hf_format
  output_dir: ./output/qwen3-8b-fp8
  weight_format: real_quantized
  custom_mode: quark

evaluation:
  skip: false
  metrics:
    - ppl
  dataset: wikitext
  tasks: null
  batch_size: auto

Supported Export Formats

1. HuggingFace SafeTensors (`hf_format`) — Default

2. ONNX (`onnx`)

3. GGUF (`gguf`)

Multiple formats can be exported simultaneously: --model_export hf_format --model_export gguf

Export CLI Arguments

python quantize_quark.py \
  --model_dir /path/to/model \
  --output_dir /path/to/output \
  --quant_scheme fp8 \
  --model_export hf_format \                    # Export format(s)
  --export_weight_format real_quantized \        # Compression mode
  --custom_mode quark \                          # Export mode: quark|awq|fp8
  --pack_method reorder                          # Weight packing: order|reorder

Evaluation Options

Post-quantization evaluation can be configured as part of the export step:

Perplexity (PPL)

Task-Based Evaluation (via lm-eval harness)

--tasks hellaswag,winogrande,arc_easy
--eval_batch_size auto
--num_fewshot 0

ROUGE/METEOR (for generation models)

# Evaluated on cnn_dailymail by default
--use_mlperf_rouge  # For MLPerf-compatible ROUGE scoring

KV Cache Evaluation

--use_ppl_eval_for_kv_cache
--ppl_eval_for_kv_cache_context_size 1024
--ppl_eval_for_kv_cache_sample_size 512

Skip Evaluation

--skip_evaluation  # Skip all post-quantization evaluation

Model Reload for Separate Evaluation

If quantization and evaluation are done in separate steps:

# Step 1: Quantize and export
python quantize_quark.py --model_dir MODEL --quant_scheme fp8 \
  --model_export hf_format --output_dir output/ --skip_evaluation

# Step 2: Reload and evaluate
python quantize_quark.py --model_dir MODEL --model_reload \
  --output_dir output/ --skip_quantization

Rules

Interaction Flow

  1. Check prerequisites: Is there a quant_plan.json? Has quantization been run or is this plan-only?
  2. Choose format: Ask where the model will be deployed and recommend the right export format.
  3. Configure evaluation: Ask if the user wants post-quantization evaluation and which metrics.
  4. Emit: Update run_manifest.yaml with export and evaluation configuration.

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.