Quark torch model intake

From amd/Quark · View interactive version

Quark torch model intake is an AI agent skill from the GitHub repository amd/Quark. Inspect a target model and prepare metadata for Quark PTQ planning. Use when the user needs model path validation, architecture detection, quantization target discovery, layer counting, risk assessment, or transformer compatibility checks before planning PTQ. Trigger for "analyze my model", "check t

How to use this skill

Skill file

quark-torch-model-intake

Purpose

Validate the target model and extract the structural facts that quark-torch-quant-plan needs to make correct quantization decisions. This step exists because different model architectures have different quantization requirements — MoE models need expert module replacement, some models require trust_remote_code, and certain architectures have known compatibility issues with specific transformers versions.

Inputs

Outputs: model_analysis.json

Captures architecture facts, quantizable layer count, transformer compatibility, and risks.

Schema: CODE0

{
  "analysis_status": "complete",
  "model": {
    "model_path": "Qwen/Qwen3-8B",
    "model_type": "qwen3",
    "trust_remote_code": false,
    "transformers_version_required": ">=4.48.0,<5.3",
    "loading_class": "AutoModelForCausalLM",
    "is_moe": false,
    "num_hidden_layers": 36,
    "hidden_size": 4096,
    "estimated_size_gb": 16.0
  },
  "quantization_targets": {
    "linear_layer_count": 224,
    "has_non_linear_experts": false,
    "exclude_defaults": ["lm_head"],
    "needs_moe_preparation": false
  },
  "risks": [
    {
      "severity": "low",
      "message": "Model size fits in single GPU with 24GB+ VRAM for FP8/INT8 schemes.",
      "recovery_hint": "Use --multi_gpu for INT4 with large calibration datasets if OOM occurs."
    }
  ]
}

Supported Model Architectures

Quark has built-in templates for 36 model families:

| Category | Models |

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

| Standard LLMs | llama, mistral, opt, phi, phi3, qwen, qwen2, gptj, cohere, olmo |

| Advanced LLMs | qwen3, qwen3_next, deepseek, deepseek_v2, deepseek_v3, deepseek_v32 |

| MoE Models | mixtral, dbrx, llama4, qwen2_moe, qwen3_moe, qwen3_5_moe, gpt_oss, granitemoehybrid, glm4_moe |

| Vision-Language | mllama, deepseek_vl_v2, qwen3_vl_moe |

| Other | chatglm, gemma2, gemma3, gemma3_text, grok-1, instella, kimi_k25, minimax_m2 |

Models not in this list may still work if they follow standard HuggingFace AutoModelForCausalLM patterns, but need extra attention.

What to Extract

From config.json

Quantization Targets

Transformer Compatibility

Some models require specific minimum transformers versions:

Special Loading Requirements

Risks

Flag anything that could cause failures downstream:

Concrete Actions

Action 1: Read model config (NEVER load full weights)

python3 -c "
from transformers import AutoConfig
import json
config = AutoConfig.from_pretrained('<MODEL_PATH>', trust_remote_code=True)
info = {
    'model_type': config.model_type,
    'num_hidden_layers': config.num_hidden_layers,
    'hidden_size': config.hidden_size,
    'intermediate_size': getattr(config, 'intermediate_size', None),
    'num_attention_heads': config.num_attention_heads,
    'num_key_value_heads': getattr(config, 'num_key_value_heads', None),
    'vocab_size': config.vocab_size,
    'num_experts': getattr(config, 'num_local_experts', getattr(config, 'num_experts', None)),
    'torch_dtype': str(getattr(config, 'torch_dtype', 'unknown')),
}
print(json.dumps(info, indent=2))
"

Action 2: Check model size (for local models)

du -sh /path/to/model/
ls -lh /path/to/model/*.safetensors

Action 3: Present summary table to user

After running the above, format the results as:

Model Analysis:
  Model path:       <path or HuggingFace ID>
  Model type:       <model_type from config>
  Hidden layers:    <num_hidden_layers>
  Linear layers:    ~<estimated count>
  MoE:              Yes/No
  Exclude defaults: [lm_head]
  Risks:            <list or "None">
  Compatibility:    OK / <version constraints>

This table is what the user sees at Checkpoint 1 of quark-torch-llm-ptq-workflow.

Rules

Interaction Flow

  1. Confirm model source: Is it a local directory or a HuggingFace ID? Check if quark-workspace-validate already confirmed the path.
  2. Read config: Extract architecture facts from config.json. Present a summary table to the user.
  3. Assess compatibility: Check model type against Quark's template list. Flag any transformer version requirements.
  4. Identify risks: Note anything that could affect downstream PTQ planning.
  5. Emit: Write model_analysis.json. Surface any new constraints back to quark-torch-router so they land in session_context.json.

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.