1
0
Fork 0
mirror of https://github.com/p-e-w/heretic.git synced 2026-12-03 18:42:57 +07:00

[GH-ISSUE #265] Error when loading gemma-4-31b-it model #152

Closed
opened 2026-11-01 04:18:04 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @genevera on GitHub (Apr 3, 2026).
Original GitHub issue: https://github.com/p-e-w/heretic/issues/265

It looks like something with the peft library so idk if it's possible to work on it or around it but if there is a way to fix it via this program....

█░█░█▀▀░█▀▄░█▀▀░▀█▀░█░█▀▀  v1.2.0
█▀█░█▀▀░█▀▄░█▀▀░░█░░█░█░░
▀░▀░▀▀▀░▀░▀░▀▀▀░░▀░░▀░▀▀▀  https://github.com/p-e-w/heretic

Detected 2 CUDA device(s):
* GPU 0: NVIDIA RTX PRO 6000 Blackwell Workstation Edition
* GPU 1: NVIDIA GeForce RTX 5090

Loading model google/gemma-4-31B-it...
Loading weights:  30%|██████████████████████████████████████████████████▎                                                                                                                   | 360/1188 [00:18<01:36,  8.56it/s]Loading weights: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1188/1188 [01:07<00:00, 17.48it/s]
Some parameters are on the meta device because they were offloaded to the cpu.
Ok
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/genevera/.pyenv/versions/miniconda3-latest/envs/heretic/bin/heretic:7 in <module>              │
│                                                                                                  │
│   4 if __name__ == '__main__':                                                                   │
│   5 │   if sys.argv[0].endswith('.exe'):                                                         │
│   6 │   │   sys.argv[0] = sys.argv[0][:-4]                                                       │
│ ❱ 7 │   sys.exit(main())                                                                         │
│   8                                                                                              │
│                                                                                                  │
│ /home/genevera/.pyenv/versions/miniconda3-latest/envs/heretic/lib/python3.12/site-packages/heretic/m │
│ ain.py:891 in main                                                                               │
│                                                                                                  │
│   888 │   install()                                                                              │
│   889 │                                                                                          │
│   890 │   try:                                                                                   │
│ ❱ 891 │   │   run()                                                                              │
│   892 │   except BaseException as error:                                                         │
│   893 │   │   # Transformers appears to handle KeyboardInterrupt (or BaseException)              │
│   894 │   │   # internally in some places, which can re-raise a different error in the handler   │
│                                                                                                  │
│ /home/genevera/.pyenv/versions/miniconda3-latest/envs/heretic/lib/python3.12/site-packages/heretic/m │
│ ain.py:312 in run                                                                                │
│                                                                                                  │
│   309 │   │   elif choice is None or choice == "":                                               │
│   310 │   │   │   return                                                                         │
│   311 │                                                                                          │
│ ❱ 312 │   model = Model(settings)                                                                │
│   313 │   print()                                                                                │
│   314 │   print_memory_usage()                                                                   │
│   315                                                                                            │
│                                                                                                  │
│ /home/genevera/.pyenv/versions/miniconda3-latest/envs/heretic/lib/python3.12/site-packages/heretic/m │
│ odel.py:147 in __init__                                                                          │
│                                                                                                  │
│   144 │   │   if self.model is None:                                                             │
│   145 │   │   │   raise Exception("Failed to load model with all configured dtypes.")            │
│   146 │   │                                                                                      │
│ ❱ 147 │   │   self._apply_lora()                                                                 │
│   148 │   │                                                                                      │
│   149 │   │   # LoRA B matrices are initialized to zero by default in PEFT,                      │
│   150 │   │   # so we don't need to do anything manually.                                        │
│                                                                                                  │
│ /home/genevera/.pyenv/versions/miniconda3-latest/envs/heretic/lib/python3.12/site-packages/heretic/m │
│ odel.py:193 in _apply_lora                                                                       │
│                                                                                                  │
│   190 │   │                                                                                      │
│   191 │   │   # self.peft_config is a LoraConfig object rather than a dictionary,                │
│   192 │   │   # so the result is a PeftModel rather than a PeftMixedModel.                       │
│ ❱ 193 │   │   self.model = cast(PeftModel, get_peft_model(self.model, self.peft_config))         │
│   194 │   │                                                                                      │
│   195 │   │   print(f"* LoRA adapters initialized (targets: {', '.join(target_modules)})")       │
│   196                                                                                            │
│                                                                                                  │
│ /home/genevera/.pyenv/versions/miniconda3-latest/envs/heretic/lib/python3.12/site-packages/peft/mapp │
│ ing_func.py:122 in get_peft_model                                                                │
│                                                                                                  │
│   119 │   │   │   low_cpu_mem_usage=low_cpu_mem_usage,                                           │
│   120 │   │   )                                                                                  │
│   121 │                                                                                          │
│ ❱ 122 │   return MODEL_TYPE_TO_PEFT_MODEL_MAPPING[peft_config.task_type](                        │
│   123 │   │   model,                                                                             │
│   124 │   │   peft_config,                                                                       │
│   125 │   │   adapter_name=adapter_name,                                                         │
│                                                                                                  │
│ /home/genevera/.pyenv/versions/miniconda3-latest/envs/heretic/lib/python3.12/site-packages/peft/peft │
│ _model.py:1885 in __init__                                                                       │
│                                                                                                  │
│   1882 │   def __init__(                                                                         │
│   1883 │   │   self, model: torch.nn.Module, peft_config: PeftConfig, adapter_name: str = "defa  │
│   1884 │   ) -> None:                                                                            │
│ ❱ 1885 │   │   super().__init__(model, peft_config, adapter_name, **kwargs)                      │
│   1886 │   │   self.base_model_prepare_inputs_for_generation = self.base_model.prepare_inputs_f  │
│   1887 │                                                                                         │
│   1888 │   def forward(                                                                          │
│                                                                                                  │
│ /home/genevera/.pyenv/versions/miniconda3-latest/envs/heretic/lib/python3.12/site-packages/peft/peft │
│ _model.py:129 in __init__                                                                        │
│                                                                                                  │
│    126 │   │   │   cls = PEFT_TYPE_TO_TUNER_MAPPING[peft_config.peft_type]                       │
│    127 │   │   │   ctx = init_empty_weights if low_cpu_mem_usage else nullcontext                │
│    128 │   │   │   with ctx():                                                                   │
│ ❱  129 │   │   │   │   self.base_model = cls(model, {adapter_name: peft_config}, adapter_name)   │
│    130 │   │                                                                                     │
│    131 │   │   if hasattr(self.base_model, "_cast_adapter_dtype"):                               │
│    132 │   │   │   self.base_model._cast_adapter_dtype(                                          │
│                                                                                                  │
│ /home/genevera/.pyenv/versions/miniconda3-latest/envs/heretic/lib/python3.12/site-packages/peft/tune │
│ rs/tuners_utils.py:298 in __init__                                                               │
│                                                                                                  │
│    295 │   │   self.active_adapter: str | list[str] = adapter_name                               │
│    296 │   │   self._pre_injection_hook(self.model, self.peft_config[adapter_name], adapter_nam  │
│    297 │   │   if peft_config != PeftType.XLORA or peft_config[adapter_name] != PeftType.XLORA:  │
│ ❱  298 │   │   │   self.inject_adapter(self.model, adapter_name, low_cpu_mem_usage=low_cpu_mem_  │
│    299 │   │                                                                                     │
│    300 │   │   # Copy the peft_config in the injected model.                                     │
│    301 │   │   self.model.peft_config = self.peft_config                                         │
│                                                                                                  │
│ /home/genevera/.pyenv/versions/miniconda3-latest/envs/heretic/lib/python3.12/site-packages/peft/tune │
│ rs/tuners_utils.py:804 in inject_adapter                                                         │
│                                                                                                  │
│    801 │   │   │   │   │   self._check_target_module_compatiblity(peft_config, model, target_na  │
│    802 │   │   │   │   │   ctx = init_empty_weights if low_cpu_mem_usage else nullcontext        │
│    803 │   │   │   │   │   with ctx():                                                           │
│ ❱  804 │   │   │   │   │   │   self._create_and_replace(                                         │
│    805 │   │   │   │   │   │   │   peft_config, adapter_name, target, target_name, parent, curr  │
│    806 │   │   │   │   │   │   )                                                                 │
│    807 │   │   │   else:                                                                         │
│                                                                                                  │
│ /home/genevera/.pyenv/versions/miniconda3-latest/envs/heretic/lib/python3.12/site-packages/peft/tune │
│ rs/lora/model.py:250 in _create_and_replace                                                      │
│                                                                                                  │
│   247 │   │   │   │   │   "PEFT repo: https://github.com/huggingface/peft/issues"                │
│   248 │   │   │   │   )                                                                          │
│   249 │   │   │   device_map = self.model.hf_device_map if hasattr(self.model, "hf_device_map"   │
│ ❱ 250 │   │   │   new_module = self._create_new_module(lora_config, adapter_name, target, devi   │
│   251 │   │   │   if adapter_name not in self.active_adapters:                                   │
│   252 │   │   │   │   # adding an additional adapter: it is not automatically trainable          │
│   253 │   │   │   │   new_module.requires_grad_(False)                                           │
│                                                                                                  │
│ /home/genevera/.pyenv/versions/miniconda3-latest/envs/heretic/lib/python3.12/site-packages/peft/tune │
│ rs/lora/model.py:343 in _create_new_module                                                       │
│                                                                                                  │
│   340 │   │                                                                                      │
│   341 │   │   if new_module is None:                                                             │
│   342 │   │   │   # no module could be matched                                                   │
│ ❱ 343 │   │   │   raise ValueError(                                                              │
│   344 │   │   │   │   f"Target module {target} is not supported. Currently, only the following   │
│   345 │   │   │   │   "`torch.nn.Linear`, `torch.nn.Embedding`, `torch.nn.Conv1d`, `torch.nn.C   │
│   346 │   │   │   │   "`transformers.pytorch_utils.Conv1D`, `torch.nn.MultiheadAttention.`."     │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ValueError: Target module Gemma4ClippableLinear(
  (linear): Linear(in_features=1152, out_features=1152, bias=False)
) is not supported. Currently, only the following modules are supported: `torch.nn.Linear`, `torch.nn.Embedding`, `torch.nn.Conv1d`, `torch.nn.Conv2d`, `torch.nn.Conv3d`, `transformers.pytorch_utils.Conv1D`,
`torch.nn.MultiheadAttention.`.
Originally created by @genevera on GitHub (Apr 3, 2026). Original GitHub issue: https://github.com/p-e-w/heretic/issues/265 It looks like something with the peft library so idk if it's possible to work on it or around it but if there is a way to fix it via this program.... ``` █░█░█▀▀░█▀▄░█▀▀░▀█▀░█░█▀▀ v1.2.0 █▀█░█▀▀░█▀▄░█▀▀░░█░░█░█░░ ▀░▀░▀▀▀░▀░▀░▀▀▀░░▀░░▀░▀▀▀ https://github.com/p-e-w/heretic Detected 2 CUDA device(s): * GPU 0: NVIDIA RTX PRO 6000 Blackwell Workstation Edition * GPU 1: NVIDIA GeForce RTX 5090 Loading model google/gemma-4-31B-it... Loading weights: 30%|██████████████████████████████████████████████████▎ | 360/1188 [00:18<01:36, 8.56it/s]Loading weights: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1188/1188 [01:07<00:00, 17.48it/s] Some parameters are on the meta device because they were offloaded to the cpu. Ok ╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮ │ /home/genevera/.pyenv/versions/miniconda3-latest/envs/heretic/bin/heretic:7 in <module> │ │ │ │ 4 if __name__ == '__main__': │ │ 5 │ if sys.argv[0].endswith('.exe'): │ │ 6 │ │ sys.argv[0] = sys.argv[0][:-4] │ │ ❱ 7 │ sys.exit(main()) │ │ 8 │ │ │ │ /home/genevera/.pyenv/versions/miniconda3-latest/envs/heretic/lib/python3.12/site-packages/heretic/m │ │ ain.py:891 in main │ │ │ │ 888 │ install() │ │ 889 │ │ │ 890 │ try: │ │ ❱ 891 │ │ run() │ │ 892 │ except BaseException as error: │ │ 893 │ │ # Transformers appears to handle KeyboardInterrupt (or BaseException) │ │ 894 │ │ # internally in some places, which can re-raise a different error in the handler │ │ │ │ /home/genevera/.pyenv/versions/miniconda3-latest/envs/heretic/lib/python3.12/site-packages/heretic/m │ │ ain.py:312 in run │ │ │ │ 309 │ │ elif choice is None or choice == "": │ │ 310 │ │ │ return │ │ 311 │ │ │ ❱ 312 │ model = Model(settings) │ │ 313 │ print() │ │ 314 │ print_memory_usage() │ │ 315 │ │ │ │ /home/genevera/.pyenv/versions/miniconda3-latest/envs/heretic/lib/python3.12/site-packages/heretic/m │ │ odel.py:147 in __init__ │ │ │ │ 144 │ │ if self.model is None: │ │ 145 │ │ │ raise Exception("Failed to load model with all configured dtypes.") │ │ 146 │ │ │ │ ❱ 147 │ │ self._apply_lora() │ │ 148 │ │ │ │ 149 │ │ # LoRA B matrices are initialized to zero by default in PEFT, │ │ 150 │ │ # so we don't need to do anything manually. │ │ │ │ /home/genevera/.pyenv/versions/miniconda3-latest/envs/heretic/lib/python3.12/site-packages/heretic/m │ │ odel.py:193 in _apply_lora │ │ │ │ 190 │ │ │ │ 191 │ │ # self.peft_config is a LoraConfig object rather than a dictionary, │ │ 192 │ │ # so the result is a PeftModel rather than a PeftMixedModel. │ │ ❱ 193 │ │ self.model = cast(PeftModel, get_peft_model(self.model, self.peft_config)) │ │ 194 │ │ │ │ 195 │ │ print(f"* LoRA adapters initialized (targets: {', '.join(target_modules)})") │ │ 196 │ │ │ │ /home/genevera/.pyenv/versions/miniconda3-latest/envs/heretic/lib/python3.12/site-packages/peft/mapp │ │ ing_func.py:122 in get_peft_model │ │ │ │ 119 │ │ │ low_cpu_mem_usage=low_cpu_mem_usage, │ │ 120 │ │ ) │ │ 121 │ │ │ ❱ 122 │ return MODEL_TYPE_TO_PEFT_MODEL_MAPPING[peft_config.task_type]( │ │ 123 │ │ model, │ │ 124 │ │ peft_config, │ │ 125 │ │ adapter_name=adapter_name, │ │ │ │ /home/genevera/.pyenv/versions/miniconda3-latest/envs/heretic/lib/python3.12/site-packages/peft/peft │ │ _model.py:1885 in __init__ │ │ │ │ 1882 │ def __init__( │ │ 1883 │ │ self, model: torch.nn.Module, peft_config: PeftConfig, adapter_name: str = "defa │ │ 1884 │ ) -> None: │ │ ❱ 1885 │ │ super().__init__(model, peft_config, adapter_name, **kwargs) │ │ 1886 │ │ self.base_model_prepare_inputs_for_generation = self.base_model.prepare_inputs_f │ │ 1887 │ │ │ 1888 │ def forward( │ │ │ │ /home/genevera/.pyenv/versions/miniconda3-latest/envs/heretic/lib/python3.12/site-packages/peft/peft │ │ _model.py:129 in __init__ │ │ │ │ 126 │ │ │ cls = PEFT_TYPE_TO_TUNER_MAPPING[peft_config.peft_type] │ │ 127 │ │ │ ctx = init_empty_weights if low_cpu_mem_usage else nullcontext │ │ 128 │ │ │ with ctx(): │ │ ❱ 129 │ │ │ │ self.base_model = cls(model, {adapter_name: peft_config}, adapter_name) │ │ 130 │ │ │ │ 131 │ │ if hasattr(self.base_model, "_cast_adapter_dtype"): │ │ 132 │ │ │ self.base_model._cast_adapter_dtype( │ │ │ │ /home/genevera/.pyenv/versions/miniconda3-latest/envs/heretic/lib/python3.12/site-packages/peft/tune │ │ rs/tuners_utils.py:298 in __init__ │ │ │ │ 295 │ │ self.active_adapter: str | list[str] = adapter_name │ │ 296 │ │ self._pre_injection_hook(self.model, self.peft_config[adapter_name], adapter_nam │ │ 297 │ │ if peft_config != PeftType.XLORA or peft_config[adapter_name] != PeftType.XLORA: │ │ ❱ 298 │ │ │ self.inject_adapter(self.model, adapter_name, low_cpu_mem_usage=low_cpu_mem_ │ │ 299 │ │ │ │ 300 │ │ # Copy the peft_config in the injected model. │ │ 301 │ │ self.model.peft_config = self.peft_config │ │ │ │ /home/genevera/.pyenv/versions/miniconda3-latest/envs/heretic/lib/python3.12/site-packages/peft/tune │ │ rs/tuners_utils.py:804 in inject_adapter │ │ │ │ 801 │ │ │ │ │ self._check_target_module_compatiblity(peft_config, model, target_na │ │ 802 │ │ │ │ │ ctx = init_empty_weights if low_cpu_mem_usage else nullcontext │ │ 803 │ │ │ │ │ with ctx(): │ │ ❱ 804 │ │ │ │ │ │ self._create_and_replace( │ │ 805 │ │ │ │ │ │ │ peft_config, adapter_name, target, target_name, parent, curr │ │ 806 │ │ │ │ │ │ ) │ │ 807 │ │ │ else: │ │ │ │ /home/genevera/.pyenv/versions/miniconda3-latest/envs/heretic/lib/python3.12/site-packages/peft/tune │ │ rs/lora/model.py:250 in _create_and_replace │ │ │ │ 247 │ │ │ │ │ "PEFT repo: https://github.com/huggingface/peft/issues" │ │ 248 │ │ │ │ ) │ │ 249 │ │ │ device_map = self.model.hf_device_map if hasattr(self.model, "hf_device_map" │ │ ❱ 250 │ │ │ new_module = self._create_new_module(lora_config, adapter_name, target, devi │ │ 251 │ │ │ if adapter_name not in self.active_adapters: │ │ 252 │ │ │ │ # adding an additional adapter: it is not automatically trainable │ │ 253 │ │ │ │ new_module.requires_grad_(False) │ │ │ │ /home/genevera/.pyenv/versions/miniconda3-latest/envs/heretic/lib/python3.12/site-packages/peft/tune │ │ rs/lora/model.py:343 in _create_new_module │ │ │ │ 340 │ │ │ │ 341 │ │ if new_module is None: │ │ 342 │ │ │ # no module could be matched │ │ ❱ 343 │ │ │ raise ValueError( │ │ 344 │ │ │ │ f"Target module {target} is not supported. Currently, only the following │ │ 345 │ │ │ │ "`torch.nn.Linear`, `torch.nn.Embedding`, `torch.nn.Conv1d`, `torch.nn.C │ │ 346 │ │ │ │ "`transformers.pytorch_utils.Conv1D`, `torch.nn.MultiheadAttention.`." │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ ValueError: Target module Gemma4ClippableLinear( (linear): Linear(in_features=1152, out_features=1152, bias=False) ) is not supported. Currently, only the following modules are supported: `torch.nn.Linear`, `torch.nn.Embedding`, `torch.nn.Conv1d`, `torch.nn.Conv2d`, `torch.nn.Conv3d`, `transformers.pytorch_utils.Conv1D`, `torch.nn.MultiheadAttention.`.
Author
Owner

@KaruroChori commented on GitHub (Apr 3, 2026):

I encountered the same problem with gemma-4-e2b-it. Just my list of supported modules is a bit longer, but still it does not work. It must be the full family of models which are not supported.

<!-- gh-comment-id:4181498005 --> @KaruroChori commented on GitHub (Apr 3, 2026): I encountered the same problem with gemma-4-e2b-it. Just my list of supported modules is a bit longer, but still it does not work. It must be the full family of models which are not supported.
Author
Owner

@Vinay-Umrethe commented on GitHub (Apr 3, 2026):

@genevera the model you tried is already available https://huggingface.co/trohrbaugh/gemma-4-31b-it-heretic-ara

@KaruroChori your's too is available https://huggingface.co/p-e-w/gemma-4-E2B-it-heretic-ara

since this isn't patched yet, use ARA branch of the repo.

<!-- gh-comment-id:4184260956 --> @Vinay-Umrethe commented on GitHub (Apr 3, 2026): @genevera the model you tried is already available https://huggingface.co/trohrbaugh/gemma-4-31b-it-heretic-ara @KaruroChori your's too is available https://huggingface.co/p-e-w/gemma-4-E2B-it-heretic-ara since this isn't patched yet, use ARA branch of the repo.
Author
Owner

@p-e-w commented on GitHub (Apr 4, 2026):

See my Reddit post for how to process Gemma 4: https://www.reddit.com/r/LocalLLaMA/comments/1sanln7/pewgemma4e2bithereticara_gemma_4s_defenses/

<!-- gh-comment-id:4185957634 --> @p-e-w commented on GitHub (Apr 4, 2026): See my Reddit post for how to process Gemma 4: https://www.reddit.com/r/LocalLLaMA/comments/1sanln7/pewgemma4e2bithereticara_gemma_4s_defenses/
Author
Owner

@genevera commented on GitHub (Apr 4, 2026):

@genevera the model you tried is already available https://huggingface.co/trohrbaugh/gemma-4-31b-it-heretic-ara

@KaruroChori your's too is available https://huggingface.co/p-e-w/gemma-4-E2B-it-heretic-ara

since this isn't patched yet, use ARA branch of the repo.

Nice one; thank you!!

<!-- gh-comment-id:4186429378 --> @genevera commented on GitHub (Apr 4, 2026): > [@genevera](https://github.com/genevera) the model you tried is already available [https://huggingface.co/trohrbaugh/gemma-4-31b-it-heretic-ara ](https://huggingface.co/trohrbaugh/gemma-4-31b-it-heretic-ara) > > [@KaruroChori](https://github.com/KaruroChori) your's too is available [https://huggingface.co/p-e-w/gemma-4-E2B-it-heretic-ara ](https://huggingface.co/p-e-w/gemma-4-E2B-it-heretic-ara) > > since this isn't patched yet, use ARA branch of the repo. Nice one; thank you!!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
p-e-w/heretic#152
No description provided.