{"record":{"id":"8ecd464af437a727","repo":"hiyouga/LlamaFactory","slug":"chatglm-model-is-not-supported-yet","errorCode":null,"errorMessage":"ChatGLM model is not supported yet.","messagePattern":"ChatGLM model is not supported yet\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/llamafactory/model/model_utils/quantization.py","lineNumber":152,"sourceCode":"            check_version(\"autoawq\", mandatory=True)\n\n        if quant_method == QuantizationMethod.AQLM:\n            check_version(\"aqlm>=1.1.0\", mandatory=True)\n            quantization_config[\"bits\"] = 2\n\n        quant_bits = quantization_config.get(\"bits\", \"?\")\n        logger.info_rank0(f\"Loading {quant_bits}-bit {quant_method.upper()}-quantized model.\")\n\n    elif model_args.export_quantization_bit is not None:  # gptqmodel\n        if model_args.export_quantization_bit not in [8, 4, 3, 2]:\n            raise ValueError(\"AutoGPTQ only accepts 2/3/4/8-bit quantization.\")\n\n        check_version(\"optimum>=1.24.0\", mandatory=True)\n        check_version(\"gptqmodel>=2.0.0\", mandatory=True)\n        from accelerate.utils import get_max_memory\n\n        if getattr(config, \"model_type\", None) == \"chatglm\":\n            raise ValueError(\"ChatGLM model is not supported yet.\")\n\n        try:\n            from optimum.gptq import utils as gq_utils\n\n            if \"language_model.model.layers\" not in gq_utils.BLOCK_PATTERNS:\n                gq_utils.BLOCK_PATTERNS.insert(0, \"language_model.model.layers\")\n        except ImportError:\n            pass\n\n        block_name_to_quantize = None\n        if getattr(config, \"model_type\", None) in [\"gemma3\", \"paligemma\"]:\n            block_name_to_quantize = \"language_model.model.layers\"\n\n        init_kwargs[\"quantization_config\"] = GPTQConfig(\n            bits=model_args.export_quantization_bit,\n            tokenizer=tokenizer,\n            dataset=_get_quantization_dataset(tokenizer, model_args),\n            block_name_to_quantize=block_name_to_quantize,","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/hiyouga/LlamaFactory/blob/f28afaf6355af515454dfb16c97d728307c93897/src/llamafactory/model/model_utils/quantization.py#L134-L170","documentation":"In the export-time GPTQ branch, after version checks, LlamaFactory explicitly rejects chatglm architectures because optimum/gptqmodel block-pattern handling for ChatGLM is not wired up. The check reads config.model_type == 'chatglm' and raises ValueError.","triggerScenarios":"Running llamafactory-cli export with export_quantization_bit set on a ChatGLM checkpoint (THUDM/chatglm2-6b, chatglm3-6b, etc.).","commonSituations":"Attempting to produce GPTQ INT4 exports of ChatGLM2/3 for vLLM-style deployment; reusing a working export config from Llama with a ChatGLM base.","solutions":["Export ChatGLM unquantized (drop export_quantization_bit) and quantize with a ChatGLM-aware toolchain, if any supports it.","Switch to a supported architecture (llama-family, qwen, etc.) for GPTQ export.","Keep ChatGLM in AWQ/other PTQ form from upstream providers rather than quantizing locally via this path."],"exampleFix":"# before (export yaml, chatglm base)\nmodel_name_or_path: THUDM/chatglm3-6b\nexport_quantization_bit: 4\n\n# after\nmodel_name_or_path: THUDM/chatglm3-6b\n# export_quantization_bit removed (export unquantized)","handlingStrategy":"type-guard","validationCode":"if export_quantization_bit is not None:\n    assert getattr(config, \"model_type\", None) != \"chatglm\", \"GPTQ export does not support chatglm\"","typeGuard":"def gptq_export_supported(config) -> bool:\n    return getattr(config, \"model_type\", None) != \"chatglm\"","tryCatchPattern":null,"preventionTips":["Check the model-support matrix before planning GPTQ exports.","Prefer upstream-provided PTQ releases for architectures LlamaFactory does not quantize."],"tags":["gptq","export","chatglm","model-support"],"backgroundTag":null,"analyzedSha":"f28afaf6355af515454dfb16c97d728307c93897","analyzedAt":"2026-08-14T21:57:28.298Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}