Repository navigation
Description
Summary
Quantizing Qwen/Qwen2.5-VL-3B-Instruct with AWQConfig keeps the vision tower dense, which is correct. The checkpoint stores model.visual.*.weight in BF16. But the saved quantization_config does not mention the tower:
{'bits': 4, 'group_size': 128, 'desc_act': False, 'format': 'gemm', 'method': 'awq', 'quant_method': 'awq',
'version': 'gemm', 'zero_point': True, 'pack_dtype': 'int32', 'checkpoint_format': 'gemm', 'lm_head': False, ...}
For AWQ, modules_to_not_convert is the only way an external loader learns that a module stayed dense. The official AutoAWQ-format checkpoint of the same model (Qwen/Qwen2.5-VL-3B-Instruct-AWQ) writes 'modules_to_not_convert': ['visual']. Without that key:
- Transformers (
from_pretrained, support matrix: AWQ ✅):replace_with_awq_linearturns every visionnn.Linearinto an AWQ layer, and the load crashes on the first vision MLP:NotImplementedError: AWQ Marlin out_features must be divisible by pack_factor=8; got N=3420.If the shapes had happened to fit, those layers would be left uninitialized instead. - SGLang 0.5.23 (AWQ GEMM listed as supported): it builds AWQ layers for
visual.blocks.*and fails at load withValueError: The input size is not aligned with the quantized weight shape. - vLLM 0.34 works only because
AutoAWQConfig.maybe_update_configderives the unquantized set from the safetensors dtypes when the key is absent (PPL 18.539 vs GPT-QModel 18.514).
GPTQ is not affected: Optimum and vLLM/SGLang limit GPTQ to the decoder blocks (block_name_to_quantize / dynamic / metadata), and the GPTQ checkpoint of the same model loads in vLLM (PPL 17.773 vs 17.753). The same gap applies to every AWQ-capable definition whose non-text towers stay dense. Qwen2.5-VL is the one I ran.
Introduced by
Pre-existing. AWQConfig._update_output_payload / excluded_module_patterns() (added in 85f18c0, #4034) publish only -: dynamic rules and declared exclusions. Modules that stay dense because the model definition never quantizes them (vision tower, projector) are never added. The Gemma 3 definition handles this for vLLM by hand (prepare_quantize_config_for_save adds -:vision_tower\..* / -:multi_modal_projector\..*), but the Qwen2-VL / Qwen2.5-VL definitions do not. Still present at HEAD 9123364.
Location
gptqmodel/quantization/config.py:8946-8952 (HEAD 9123364):
def _update_output_payload(self, out: Dict[str, Any]) -> None:
...
excluded = self.excluded_module_patterns()
if excluded:
out["modules_to_not_convert"] = excludedgptqmodel/models/definitions/gemma3.py:94-100 shows the per-model workaround that the Qwen VL definitions lack:
dynamic.setdefault(r"-:vision_tower\..*", {})
dynamic.setdefault(r"-:multi_modal_projector\..*", {})Reproduction (ran it: RTX 4090, GPT-QModel HEAD 9123364, transformers 5.23, vLLM 0.34.0, SGLang 0.5.23)
from datasets import load_dataset
from gptqmodel import GPTQModel, AWQConfig, CalibrationConfig
ds = load_dataset("allenai/c4", data_files="en/c4-train.00001-of-01024.json.gz", split="train")
calib = [r["text"] for r in ds.select(range(512)) if len(r["text"]) > 300][:128]
m = GPTQModel.load("Qwen/Qwen2.5-VL-3B-Instruct", AWQConfig(bits=4, group_size=128, sym=False))
m.quantize(CalibrationConfig(dataset=calib, batch_size=4))
m.save("qwen25vl-awq")
from transformers import Qwen2_5_VLForConditionalGeneration
Qwen2_5_VLForConditionalGeneration.from_pretrained("qwen25vl-awq", device_map="cuda:0") File "transformers/quantizers/quantizer_awq.py", line 71, in _process_model_before_weight_loading
File "transformers/integrations/awq.py", line 97, in replace_with_awq_linear
File "gptqmodel/nn_modules/qlinear/marlin_awq.py", line 123, in __init__
...
NotImplementedError: AWQ Marlin out_features must be divisible by pack_factor=8; got N=3420.
GPTQModel.load("qwen25vl-awq") works (wikitext-2 PPL 18.514).
Same tensors, only modules_to_not_convert added to config.json / quantize_config.json:
modules_to_not_convert |
transformers from_pretrained |
SGLang |
|---|---|---|
| absent (as saved) | crash (N=3420) |
crash (input size is not aligned) |
["model.visual"] |
loads, vision stays nn.Linear, PPL 18.681 |
- |
["visual"] (official AutoAWQ spelling) |
same crash (HF 5.x matches it only as a start-anchored prefix or suffix of model.visual...) |
loads, PPL 18.522 vs GPT-QModel 18.514* |
* SGLang 0.5.23's Qwen2.5-VL loader also needs the legacy key layout (model.layers.* / visual.*), so this row used the same tensors renamed to it. Transformers' own save_pretrained writes that layout for Qwen2.5-VL (checked with 5.23). GPT-QModel writes the runtime layout (model.language_model.* / model.visual.*) because the Qwen VL definitions have no checkpoint_key_for_save, unlike Gemma 3 / Omni.
Expected vs actual
Expected: an AWQ checkpoint names the modules it left dense, as AutoAWQ/Qwen checkpoints do, so Transformers and SGLang leave the vision tower alone. Actual: the key is omitted. Transformers and SGLang try to load the dense vision tower as AWQ and fail.
Suggested fix
When writing an AWQ checkpoint, add every nn.Linear (or its top-level container) that was not quantized to modules_to_not_convert. Example: ["model.visual", "visual"] for Qwen2-VL/2.5-VL, or the concrete module names that the writer can enumerate from the saved state (modules with dense .weight and no qweight). Emitting both the runtime and the legacy/hub spelling covers HF 5.x (prefix match) and SGLang/vLLM (substring match). Do not use the Gemma 3 regex spelling for AWQ. A regex exclusion is exported verbatim into modules_to_not_convert, and vLLM/SGLang match that list as plain substrings (#6190). Optionally, save Qwen VL checkpoints in the hub key layout through checkpoint_key_for_save, as Transformers does.
Activity
fix(writer): HF/vLLM interop for dense towers, excluded linears and d…
test(writer): match the AWQ vision-tower tensors by suffix, not by pr…
fix(writer): HF/vLLM interop for dense towers, excluded linears and d…