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 #278] Add support for Gemma4 (Gemma4ClippableLinear) #158

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

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

Currently, gemma4 does not work with the latest GitHub code.

The reason is the same as discussed in the peft issue: gemma4 uses Gemma4ClippableLinear instead of the nn.Linear layer.

https://github.com/huggingface/peft/issues/3129

The monkey patch at
https://github.com/huggingface/peft/issues/3130
works fine.

Thx.

Originally created by @tanreinama on GitHub (Apr 6, 2026). Original GitHub issue: https://github.com/p-e-w/heretic/issues/278 Currently, gemma4 does not work with the latest GitHub code. The reason is the same as discussed in the peft issue: gemma4 uses Gemma4ClippableLinear instead of the nn.Linear layer. https://github.com/huggingface/peft/issues/3129 The monkey patch at https://github.com/huggingface/peft/issues/3130 works fine. Thx.
Author
Owner

@tanreinama commented on GitHub (Apr 6, 2026):

Saving the model after running it using the monkey patch, above, and load results in the following warning. It seems to me that it doesn't support multimodal models.

Gemma4ForConditionalGeneration LOAD REPORT from: gemma-4-E2B-it-uncensor
Key                                                                       | Status     |
--------------------------------------------------------------------------+------------+-
model.vision_tower.encoder.layers.{0...15}.self_attn.v_proj.weight        | UNEXPECTED |
model.vision_tower.encoder.layers.{0...15}.self_attn.q_proj.weight        | UNEXPECTED |
model.audio_tower.layers.{0...11}.feed_forward1.ffw_layer_1.weight        | UNEXPECTED |
model.audio_tower.layers.{0...11}.self_attn.q_proj.weight                 | UNEXPECTED |
model.audio_tower.layers.{0...11}.lconv1d.linear_start.weight             | UNEXPECTED |
model.audio_tower.layers.{0...11}.feed_forward2.ffw_layer_1.weight        | UNEXPECTED |
model.vision_tower.encoder.layers.{0...15}.self_attn.o_proj.weight        | UNEXPECTED |
model.vision_tower.encoder.layers.{0...15}.self_attn.k_proj.weight        | UNEXPECTED |
model.vision_tower.encoder.layers.{0...15}.mlp.down_proj.weight           | UNEXPECTED |
model.vision_tower.encoder.layers.{0...15}.mlp.up_proj.weight             | UNEXPECTED |
model.audio_tower.layers.{0...11}.feed_forward2.ffw_layer_2.weight        | UNEXPECTED |
model.audio_tower.layers.{0...11}.lconv1d.linear_end.weight               | UNEXPECTED |
model.audio_tower.layers.{0...11}.feed_forward1.ffw_layer_2.weight        | UNEXPECTED |
model.audio_tower.layers.{0...11}.self_attn.post.weight                   | UNEXPECTED |
model.vision_tower.encoder.layers.{0...15}.mlp.gate_proj.weight           | UNEXPECTED |
model.audio_tower.layers.{0...11}.self_attn.v_proj.weight                 | UNEXPECTED |
model.audio_tower.layers.{0...11}.self_attn.k_proj.weight                 | UNEXPECTED |
model.audio_tower.layers.{0...11}.self_attn.q_proj.linear.weight          | MISSING    |
model.audio_tower.layers.{0...11}.feed_forward1.ffw_layer_2.linear.weight | MISSING    |
model.audio_tower.layers.{0...11}.feed_forward1.ffw_layer_1.linear.weight | MISSING    |
model.vision_tower.encoder.layers.{0...15}.mlp.up_proj.linear.weight      | MISSING    |
model.vision_tower.encoder.layers.{0...15}.mlp.down_proj.linear.weight    | MISSING    |
model.vision_tower.encoder.layers.{0...15}.mlp.gate_proj.linear.weight    | MISSING    |
model.vision_tower.encoder.layers.{0...15}.self_attn.q_proj.linear.weight | MISSING    |
model.audio_tower.layers.{0...11}.feed_forward2.ffw_layer_1.linear.weight | MISSING    |
model.audio_tower.layers.{0...11}.self_attn.v_proj.linear.weight          | MISSING    |
model.audio_tower.layers.{0...11}.lconv1d.linear_end.linear.weight        | MISSING    |
model.audio_tower.layers.{0...11}.self_attn.k_proj.linear.weight          | MISSING    |
model.vision_tower.encoder.layers.{0...15}.self_attn.k_proj.linear.weight | MISSING    |
model.vision_tower.encoder.layers.{0...15}.self_attn.v_proj.linear.weight | MISSING    |
model.audio_tower.layers.{0...11}.feed_forward2.ffw_layer_2.linear.weight | MISSING    |
model.audio_tower.layers.{0...11}.lconv1d.linear_start.linear.weight      | MISSING    |
model.vision_tower.encoder.layers.{0...15}.self_attn.o_proj.linear.weight | MISSING    |
model.audio_tower.layers.{0...11}.self_attn.post.linear.weight            | MISSING    |

Notes:
- UNEXPECTED:   can be ignored when loading from different task/architecture; not ok if you expect identical arch.
- MISSING:      those params were newly initialized because missing from the checkpoint. Consider training on your downstream task.
<!-- gh-comment-id:4190470279 --> @tanreinama commented on GitHub (Apr 6, 2026): Saving the model after running it using the monkey patch, above, and load results in the following warning. It seems to me that it doesn't support multimodal models. ``` Gemma4ForConditionalGeneration LOAD REPORT from: gemma-4-E2B-it-uncensor Key | Status | --------------------------------------------------------------------------+------------+- model.vision_tower.encoder.layers.{0...15}.self_attn.v_proj.weight | UNEXPECTED | model.vision_tower.encoder.layers.{0...15}.self_attn.q_proj.weight | UNEXPECTED | model.audio_tower.layers.{0...11}.feed_forward1.ffw_layer_1.weight | UNEXPECTED | model.audio_tower.layers.{0...11}.self_attn.q_proj.weight | UNEXPECTED | model.audio_tower.layers.{0...11}.lconv1d.linear_start.weight | UNEXPECTED | model.audio_tower.layers.{0...11}.feed_forward2.ffw_layer_1.weight | UNEXPECTED | model.vision_tower.encoder.layers.{0...15}.self_attn.o_proj.weight | UNEXPECTED | model.vision_tower.encoder.layers.{0...15}.self_attn.k_proj.weight | UNEXPECTED | model.vision_tower.encoder.layers.{0...15}.mlp.down_proj.weight | UNEXPECTED | model.vision_tower.encoder.layers.{0...15}.mlp.up_proj.weight | UNEXPECTED | model.audio_tower.layers.{0...11}.feed_forward2.ffw_layer_2.weight | UNEXPECTED | model.audio_tower.layers.{0...11}.lconv1d.linear_end.weight | UNEXPECTED | model.audio_tower.layers.{0...11}.feed_forward1.ffw_layer_2.weight | UNEXPECTED | model.audio_tower.layers.{0...11}.self_attn.post.weight | UNEXPECTED | model.vision_tower.encoder.layers.{0...15}.mlp.gate_proj.weight | UNEXPECTED | model.audio_tower.layers.{0...11}.self_attn.v_proj.weight | UNEXPECTED | model.audio_tower.layers.{0...11}.self_attn.k_proj.weight | UNEXPECTED | model.audio_tower.layers.{0...11}.self_attn.q_proj.linear.weight | MISSING | model.audio_tower.layers.{0...11}.feed_forward1.ffw_layer_2.linear.weight | MISSING | model.audio_tower.layers.{0...11}.feed_forward1.ffw_layer_1.linear.weight | MISSING | model.vision_tower.encoder.layers.{0...15}.mlp.up_proj.linear.weight | MISSING | model.vision_tower.encoder.layers.{0...15}.mlp.down_proj.linear.weight | MISSING | model.vision_tower.encoder.layers.{0...15}.mlp.gate_proj.linear.weight | MISSING | model.vision_tower.encoder.layers.{0...15}.self_attn.q_proj.linear.weight | MISSING | model.audio_tower.layers.{0...11}.feed_forward2.ffw_layer_1.linear.weight | MISSING | model.audio_tower.layers.{0...11}.self_attn.v_proj.linear.weight | MISSING | model.audio_tower.layers.{0...11}.lconv1d.linear_end.linear.weight | MISSING | model.audio_tower.layers.{0...11}.self_attn.k_proj.linear.weight | MISSING | model.vision_tower.encoder.layers.{0...15}.self_attn.k_proj.linear.weight | MISSING | model.vision_tower.encoder.layers.{0...15}.self_attn.v_proj.linear.weight | MISSING | model.audio_tower.layers.{0...11}.feed_forward2.ffw_layer_2.linear.weight | MISSING | model.audio_tower.layers.{0...11}.lconv1d.linear_start.linear.weight | MISSING | model.vision_tower.encoder.layers.{0...15}.self_attn.o_proj.linear.weight | MISSING | model.audio_tower.layers.{0...11}.self_attn.post.linear.weight | MISSING | Notes: - UNEXPECTED: can be ignored when loading from different task/architecture; not ok if you expect identical arch. - MISSING: those params were newly initialized because missing from the checkpoint. Consider training on your downstream task. ```
Author
Owner

@MoonRide303 commented on GitHub (Apr 6, 2026):

Same here - I tried single run with default settings vs smallest gemma 4, fails at peft:

heretic --n-trials 1 --model google/gemma-4-E2B-it
█░█░█▀▀░█▀▄░█▀▀░▀█▀░█░█▀▀  v1.2.0
█▀█░█▀▀░█▀▄░█▀▀░░█░░█░█░░
▀░▀░▀▀▀░▀░▀░▀▀▀░░▀░░▀░▀▀▀  https://github.com/p-e-w/heretic

Detected 1 CUDA device(s):
* GPU 0: NVIDIA RTX PRO 6000 Blackwell Server Edition

Loading model google/gemma-4-E2B-it...
Loading weights: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2011/2011 [00:00<00:00, 2167.76it/s]
Ok
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /usr/local/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                                                                                              │
│                                                                                                  │
│ /usr/local/lib/python3.12/dist-packages/heretic/main.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   │
│                                                                                                  │
│ /usr/local/lib/python3.12/dist-packages/heretic/main.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                                                                                            │
│                                                                                                  │
│ /usr/local/lib/python3.12/dist-packages/heretic/model.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.                                        │
│                                                                                                  │
│ /usr/local/lib/python3.12/dist-packages/heretic/model.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                                                                                            │
│                                                                                                  │
│ /usr/local/lib/python3.12/dist-packages/peft/mapping_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,                                                         │
│                                                                                                  │
│ /usr/local/lib/python3.12/dist-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(                                                                          │
│                                                                                                  │
│ /usr/local/lib/python3.12/dist-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(                                          │
│                                                                                                  │
│ /usr/local/lib/python3.12/dist-packages/peft/tuners/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                                         │
│                                                                                                  │
│ /usr/local/lib/python3.12/dist-packages/peft/tuners/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:                                                                         │
│                                                                                                  │
│ /usr/local/lib/python3.12/dist-packages/peft/tuners/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)                                           │
│                                                                                                  │
│ /usr/local/lib/python3.12/dist-packages/peft/tuners/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=768, out_features=768, 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.`.

Tested using heretic-llm 1.2.0, torch 2.11, transformers 5.5.0, peft 0.18.1.

<!-- gh-comment-id:4192035815 --> @MoonRide303 commented on GitHub (Apr 6, 2026): Same here - I tried single run with default settings vs smallest gemma 4, fails at peft: <details> ``` heretic --n-trials 1 --model google/gemma-4-E2B-it █░█░█▀▀░█▀▄░█▀▀░▀█▀░█░█▀▀ v1.2.0 █▀█░█▀▀░█▀▄░█▀▀░░█░░█░█░░ ▀░▀░▀▀▀░▀░▀░▀▀▀░░▀░░▀░▀▀▀ https://github.com/p-e-w/heretic Detected 1 CUDA device(s): * GPU 0: NVIDIA RTX PRO 6000 Blackwell Server Edition Loading model google/gemma-4-E2B-it... Loading weights: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2011/2011 [00:00<00:00, 2167.76it/s] Ok ╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮ │ /usr/local/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 │ │ │ │ /usr/local/lib/python3.12/dist-packages/heretic/main.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 │ │ │ │ /usr/local/lib/python3.12/dist-packages/heretic/main.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 │ │ │ │ /usr/local/lib/python3.12/dist-packages/heretic/model.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. │ │ │ │ /usr/local/lib/python3.12/dist-packages/heretic/model.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 │ │ │ │ /usr/local/lib/python3.12/dist-packages/peft/mapping_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, │ │ │ │ /usr/local/lib/python3.12/dist-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( │ │ │ │ /usr/local/lib/python3.12/dist-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( │ │ │ │ /usr/local/lib/python3.12/dist-packages/peft/tuners/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 │ │ │ │ /usr/local/lib/python3.12/dist-packages/peft/tuners/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: │ │ │ │ /usr/local/lib/python3.12/dist-packages/peft/tuners/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) │ │ │ │ /usr/local/lib/python3.12/dist-packages/peft/tuners/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=768, out_features=768, 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.`. ``` </details> Tested using heretic-llm 1.2.0, torch 2.11, transformers 5.5.0, peft 0.18.1.
Author
Owner

@BenjaminBossan commented on GitHub (Apr 7, 2026):

To the folks reading, there is no need to monkey patch anything, just specify the right layers to target with target_modules. Follow the discussion in the linked issue for details.

<!-- gh-comment-id:4197595988 --> @BenjaminBossan commented on GitHub (Apr 7, 2026): To the folks reading, there is no need to monkey patch anything, just specify the right layers to target with `target_modules`. Follow the [discussion in the linked issue](https://github.com/huggingface/peft/issues/3129) for details.
Author
Owner

@MoonRide303 commented on GitHub (Apr 7, 2026):

@p-e-w could you take a look at PR #287? I tried to make clean fix vs current master, and tested it locally vs gemma-4-E2B-it and Llama-3.2-3B-Instruct - seems to be working

<!-- gh-comment-id:4200926148 --> @MoonRide303 commented on GitHub (Apr 7, 2026): @p-e-w could you take a look at PR #287? I tried to make clean fix vs current master, and tested it locally vs gemma-4-E2B-it and Llama-3.2-3B-Instruct - seems to be working
Author
Owner

@Heliumrich commented on GitHub (Apr 9, 2026):

Once this is fixed, can someone please convert the abliterated model to LiteRT-LM, for android support ?

For the Edge Gallery app
https://github.com/google-ai-edge/gallery

By following this doc, afaik
https://github.com/google-ai-edge/litert-torch?tab=readme-ov-file#pytorch-converter

I imagine it won't be accepted on HF to be available in the app directly, but we can still import manually a file ourself in the app anyway

E4B and E2B please 🙏

<!-- gh-comment-id:4210604150 --> @Heliumrich commented on GitHub (Apr 9, 2026): Once this is fixed, can someone please convert the abliterated model to LiteRT-LM, for android support ? For the Edge Gallery app https://github.com/google-ai-edge/gallery By following this doc, afaik https://github.com/google-ai-edge/litert-torch?tab=readme-ov-file#pytorch-converter I imagine it won't be accepted on HF to be available in the app directly, but we can still import manually a file ourself in the app anyway E4B and E2B please 🙏
Author
Owner

@MoonRide303 commented on GitHub (Apr 12, 2026):

@tanreinama It should work now on master (PR merged) - could you pull current sources, and verify if it work work you? (just make sure you also have transformers 5.5.0 or newer)

@Heliumrich conversion to LiteRT-LM shouldn't really be in scope of this issue. If you want to have some E2B or E4B input weights for experiments, you can try these: gemma-4-E2B-it-heretic-ara, gemma-4-E4B-it-heretic-ara.

<!-- gh-comment-id:4231871060 --> @MoonRide303 commented on GitHub (Apr 12, 2026): @tanreinama It should work now on master (PR merged) - could you pull current sources, and verify if it work work you? (just make sure you also have transformers 5.5.0 or newer) @Heliumrich conversion to LiteRT-LM shouldn't really be in scope of this issue. If you want to have some E2B or E4B input weights for experiments, you can try these: [gemma-4-E2B-it-heretic-ara](https://huggingface.co/MoonRide/gemma-4-E2B-it-heretic-ara), [gemma-4-E4B-it-heretic-ara](https://huggingface.co/MoonRide/gemma-4-E4B-it-heretic-ara).
Author
Owner

@Heliumrich commented on GitHub (Apr 12, 2026):

@tanreinama It should work now on master (PR merged) - could you pull current sources, and verify if it work work you? (just make sure you also have transformers 5.5.0 or newer)

@Heliumrich conversion to LiteRT-LM shouldn't really be in scope of this issue. If you want to have some E2B or E4B input weights for experiments, you can try these: gemma-4-E2B-it-heretic-ara, gemma-4-E4B-it-heretic-ara.

Thank you !
Yeah I know, it's just that the documentation seems more complex than I thought
LiteRT doesn't seem to have a config for gemma4, only gemma3 etc, and not sure how to properly make one for it

I was just hoping someone smarter would be interested in doing it, not knowing where to ask

<!-- gh-comment-id:4232198016 --> @Heliumrich commented on GitHub (Apr 12, 2026): > [@tanreinama](https://github.com/tanreinama) It should work now on master (PR merged) - could you pull current sources, and verify if it work work you? (just make sure you also have transformers 5.5.0 or newer) > > [@Heliumrich](https://github.com/Heliumrich) conversion to LiteRT-LM shouldn't really be in scope of this issue. If you want to have some E2B or E4B input weights for experiments, you can try these: [gemma-4-E2B-it-heretic-ara](https://huggingface.co/MoonRide/gemma-4-E2B-it-heretic-ara), [gemma-4-E4B-it-heretic-ara](https://huggingface.co/MoonRide/gemma-4-E4B-it-heretic-ara). Thank you ! Yeah I know, it's just that the documentation seems more complex than I thought [LiteRT doesn't seem to have a config for gemma4, only gemma3 etc](https://github.com/google-ai-edge/litert-torch/tree/main/litert_torch/generative/examples), and not sure how to properly make one for it I was just hoping someone smarter would be interested in doing it, not knowing where to ask
Author
Owner

@tanreinama commented on GitHub (Apr 13, 2026):

@MoonRide303
I've tested it and it seems to be working well. Thank you.

<!-- gh-comment-id:4233171785 --> @tanreinama commented on GitHub (Apr 13, 2026): @MoonRide303 I've tested it and it seems to be working well. Thank you.
Author
Owner

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

Fixed on master.

<!-- gh-comment-id:4244483809 --> @p-e-w commented on GitHub (Apr 14, 2026): Fixed on master.
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#158
No description provided.