From 93b59311bff44c2fd603334cd9af14d197ec251e Mon Sep 17 00:00:00 2001 From: ZX-ModelCloud Date: Mon, 29 Sep 2025 22:35:24 +0800 Subject: [PATCH 1/2] fix argument error of BaseQwen2VLGPTQ.prepare_dataset() Signed-off-by: ZX-ModelCloud --- gptqmodel/models/definitions/base_qwen2_vl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gptqmodel/models/definitions/base_qwen2_vl.py b/gptqmodel/models/definitions/base_qwen2_vl.py index b036fdde9..9b1d39b61 100644 --- a/gptqmodel/models/definitions/base_qwen2_vl.py +++ b/gptqmodel/models/definitions/base_qwen2_vl.py @@ -65,7 +65,7 @@ def preprocess_dataset(self, sample: Dict) -> Dict: def load_processor(self) -> ProcessorMixin: return AutoProcessor.from_pretrained(self.model_local_path) - def prepare_dataset(self, calibration_dataset, calibration_dataset_concat_size=None, batch_size: int = 1): + def prepare_dataset(self, calibration_dataset, batch_size: int = 1, **kwargs): processor = self.load_processor() calib_data = [] for batch in batched(calibration_dataset, batch_size, process_func=self.preprocess_dataset): From 6a049457085106293fd9293f4a57ddbdd6c17881 Mon Sep 17 00:00:00 2001 From: ZX-ModelCloud Date: Tue, 30 Sep 2025 12:18:09 +0800 Subject: [PATCH 2/2] fix get_base_modules() with qwen2_5_VL model Signed-off-by: ZX-ModelCloud --- gptqmodel/models/base.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/gptqmodel/models/base.py b/gptqmodel/models/base.py index 1e503b253..01ad93ec1 100644 --- a/gptqmodel/models/base.py +++ b/gptqmodel/models/base.py @@ -1244,14 +1244,30 @@ def get_base_modules(cls, model): """ Return list of base modules directly under 'model' but not 'model.layers'. """ - root = cls.module_tree[0] # "model" - exclude = cls.module_tree[1] # "layers" + # Find the index of "#" + tree = cls.module_tree + try: + sharp_idx = tree.index("#") + except ValueError: + raise ValueError("module_tree must contain '#' to separate hierarchy") + + assert sharp_idx > 0, "failed to get_base_modules" + # root_path = ["model"] or ["model", "language_model"] + root_path = tree[:sharp_idx-1] - base = getattr(model, root) out = [] - for name, _ in base.named_children(): - if name != exclude: # skip second node which is parallel in scope - out.append(f"{root}.{name}") + # Traverse each layer in root_path + for i in range(len(root_path)): + path = root_path[:i + 1] + base = model + exclude = tree[len(path)] + + for node in path: + base = getattr(base, node) + + for name, _ in base.named_children(): + if name != exclude: + out.append(".".join(path + [name])) # print(f"Base Modules: {out}") return out