mirror of
https://github.com/p-e-w/heretic.git
synced 2026-12-03 18:42:57 +07:00
[GH-ISSUE #219] Qwen3.5 compatability #125
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#125
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 @asuscat on GitHub (Mar 10, 2026).
Original GitHub issue: https://github.com/p-e-w/heretic/issues/219
[1]user@secureblue:/var/home/user$ heretic --model "Qwen/Qwen3.5-35B-A3B" --trust-remote-code true --quantization none --device-map auto
█░█░█▀▀░█▀▄░█▀▀░▀█▀░█░█▀▀ v1.2.0
█▀█░█▀▀░█▀▄░█▀▀░░█░░█░█░░
▀░▀░▀▀▀░▀░▀░▀▀▀░░▀░░▀░▀▀▀ https://github.com/p-e-w/heretic
Detected 1 CUDA device(s):
Loading model Qwen/Qwen3.5-35B-A3B...
Loading weights: 100%|████████████████████████████████████████| 1026/1026 [00:03<00:00, 320.15it/s]
Some parameters are on the meta device because they were offloaded to the cpu and disk.
Ok
╭─────────────────────────────── Traceback (most recent call last) ───────────────────────────────╮
│ /home/user/.local/bin/heretic:6 in │
│ │
│ 3 from heretic.main import main │
│ 4 if name == 'main': │
│ 5 │ sys.argv[0] = sys.argv[0].removesuffix('.exe') │
│ ❱ 6 │ sys.exit(main()) │
│ 7 │
│ │
│ /home/user/.local/lib/python3.11/site-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 │
│ │
│ /home/user/.local/lib/python3.11/site-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 │
│ │
│ /home/user/.local/lib/python3.11/site-packages/heretic/model.py:148 in init │
│ │
│ 145 │ │ if self.model is None: │
│ 146 │ │ │ raise Exception("Failed to load model with all configured dtypes.") │
│ 147 │ │ │
│ ❱ 148 │ │ self._apply_lora() │
│ 149 │ │ │
│ 150 │ │ # LoRA B matrices are initialized to zero by default in PEFT, │
│ 151 │ │ # so we don't need to do anything manually. │
│ │
│ /home/user/.local/lib/python3.11/site-packages/heretic/model.py:171 in _apply_lora │
│ │
│ 168 │ │ # leaving the others at their default (identity) state. │
│ 169 │ │ # NOTE: This will need to be updated when hybrid layer support (#43) is merged. │
│ 170 │ │ target_modules = [ │
│ ❱ 171 │ │ │ comp.split(".")[-1] for comp in self.get_abliterable_components() │
│ 172 │ │ ] │
│ 173 │ │ │
│ 174 │ │ if self.settings.row_normalization != RowNormalization.FULL: │
│ │
│ /home/user/.local/lib/python3.11/site-packages/heretic/model.py:378 in │
│ get_abliterable_components │
│ │
│ 375 │ │ return modules │
│ 376 │ │
│ 377 │ def get_abliterable_components(self) -> list[str]: │
│ ❱ 378 │ │ return list(self.get_layer_modules(0).keys()) │
│ 379 │ │
│ 380 │ def abliterate( │
│ 381 │ │ self, │
│ │
│ /home/user/.local/lib/python3.11/site-packages/heretic/model.py:346 in get_layer_modules │
│ │
│ 343 │ │ │
│ 344 │ │ # Exceptions aren't suppressed here, because there is currently │
│ 345 │ │ # no alternative location for the attention out-projection. │
│ ❱ 346 │ │ try_add("attn.o_proj", layer.self_attn.o_proj) # ty:ignore[possibly-missing-att │
│ 347 │ │ │
│ 348 │ │ # Most dense models. │
│ 349 │ │ with suppress(Exception): │
│ │
│ /home/user/.local/lib/python3.11/site-packages/torch/nn/modules/module.py:1965 in getattr │
│ │
│ 1962 │ │ │ modules = self.dict["_modules"] │
│ 1963 │ │ │ if name in modules: │
│ 1964 │ │ │ │ return modules[name] │
│ ❱ 1965 │ │ raise AttributeError( │
│ 1966 │ │ │ f"'{type(self).name}' object has no attribute '{name}'" │
│ 1967 │ │ ) │
│ 1968 │
╰─────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'Qwen3_5MoeDecoderLayer' object has no attribute 'self_attn'
@p-e-w commented on GitHub (Mar 10, 2026):
This is already fixed in master.
@MasterX1582 commented on GitHub (Mar 20, 2026):
The self_attn AttributeError is fixed in master, but running Heretic on Qwen3.5 still crashes during abliteration with:
AttributeError: 'Linear' object has no attribute 'base_layer'
This happens because linear_attn.out_proj uses the same component key "attn.o_proj" as self_attn.o_proj. LoRA derives target module names from the component key suffix (o_proj), so out_proj modules never get LoRA wrapping. During abliteration, module.base_layer.weight fails on the unwrapped Linear.
PR #241 fixes this by using "attn.out_proj" as a separate component key. Tested on Qwen3.5-0.8B: 4/100 refusals (from 96/100), KL 0.2181.
@p-e-w commented on GitHub (Mar 20, 2026):
No it doesn't. This has been fixed a while ago. Please see my comment on #241.
The component name is a Heretic-internal construct, and is only used for abliteration parameter grouping. Are you sure you are using the latest master?