{"record":{"id":"90ab6575e84d066d","repo":"hiyouga/LlamaFactory","slug":"quantization-dataset-is-necessary-for-exporting","errorCode":null,"errorMessage":"Quantization dataset is necessary for exporting.","messagePattern":"Quantization dataset is necessary for exporting\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/llamafactory/hparams/model_args.py","lineNumber":397,"sourceCode":"        default=128,\n        metadata={\"help\": \"The number of samples used for quantization.\"},\n    )\n    export_quantization_maxlen: int = field(\n        default=1024,\n        metadata={\"help\": \"The maximum length of the model inputs used for quantization.\"},\n    )\n    export_legacy_format: bool = field(\n        default=False,\n        metadata={\"help\": \"Whether or not to save the `.bin` files instead of `.safetensors`.\"},\n    )\n    export_hub_model_id: str | None = field(\n        default=None,\n        metadata={\"help\": \"The name of the repository if push the model to the Hugging Face hub.\"},\n    )\n\n    def __post_init__(self):\n        if self.export_quantization_bit is not None and self.export_quantization_dataset is None:\n            raise ValueError(\"Quantization dataset is necessary for exporting.\")\n\n\n@dataclass\nclass VllmArguments:\n    r\"\"\"Arguments pertaining to the vLLM worker.\"\"\"\n\n    vllm_maxlen: int = field(\n        default=4096,\n        metadata={\"help\": \"Maximum sequence (prompt + response) length of the vLLM engine.\"},\n    )\n    vllm_gpu_util: float = field(\n        default=0.7,\n        metadata={\"help\": \"The fraction of GPU memory in (0,1) to be used for the vLLM engine.\"},\n    )\n    vllm_enforce_eager: bool = field(\n        default=False,\n        metadata={\"help\": \"Whether or not to disable CUDA graph in the vLLM engine.\"},\n    )","sourceCodeStart":379,"sourceCodeEnd":415,"githubUrl":"https://github.com/hiyouga/LlamaFactory/blob/f28afaf6355af515454dfb16c97d728307c93897/src/llamafactory/hparams/model_args.py#L379-L415","documentation":"Raised in ExportArguments.__post_init__ (model_args.py:397) when export_quantization_bit is set but export_quantization_dataset is None. Post-training quantization (e.g. GPTQ/AWQ-style export) requires calibration data to collect activation statistics, so exporting a quantized model without a dataset is impossible. Checked at export-argument construction time.","triggerScenarios":"Running export with export_quantization_bit: 8 but no export_quantization_dataset; a template export YAML where the dataset line is commented out; using a JSON config that includes the bit but not the dataset key.","commonSituations":"First-time quantized exports copied from a full example with the dataset section trimmed; users assuming quantization needs no data (weight-only rounding intuition); renaming the dataset key (it is export_quantization_dataset, a dataset name from data/dataset_info.json, not a file path).","solutions":["Add export_quantization_dataset with a dataset name registered in data/dataset_info.json (e.g. 'wikitext')","Verify the dataset name exists in dataset_info.json","If you actually want an unquantized export, remove export_quantization_bit"],"exampleFix":"# before\nexport_dir: saves/exported\nexport_quantization_bit: 8\n\n# after\nexport_dir: saves/exported\nexport_quantization_bit: 8\nexport_quantization_dataset: wikitext","handlingStrategy":"validation","validationCode":"if cfg.get('export_quantization_bit') is not None:\n    assert cfg.get('export_quantization_dataset'), 'calibration dataset required for quantized export'","typeGuard":"def quantized_export_ready(cfg: dict) -> bool:\n    return cfg.get('export_quantization_bit') is None or bool(cfg.get('export_quantization_dataset'))","tryCatchPattern":null,"preventionTips":["Treat export_quantization_bit and export_quantization_dataset as an inseparable pair","Register the calibration dataset in data/dataset_info.json before export"],"tags":["export","quantization","hparams","required-field"],"backgroundTag":null,"analyzedSha":"f28afaf6355af515454dfb16c97d728307c93897","analyzedAt":"2026-08-14T21:57:28.298Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}