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
Labels
No labels
bug
enhancement
enhancement
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
p-e-w/heretic#158
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.
@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.
@MoonRide303 commented on GitHub (Apr 6, 2026):
Same here - I tried single run with default settings vs smallest gemma 4, fails at peft:
Tested using heretic-llm 1.2.0, torch 2.11, transformers 5.5.0, peft 0.18.1.
@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.@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
@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 🙏
@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.
@Heliumrich commented on GitHub (Apr 12, 2026):
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
@tanreinama commented on GitHub (Apr 13, 2026):
@MoonRide303
I've tested it and it seems to be working well. Thank you.
@p-e-w commented on GitHub (Apr 14, 2026):
Fixed on master.