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 #181] Support for Qwen3NextForCausalLM (Qwen3-Next-80B-A3B) #105

Open
opened 2026-11-01 04:17:34 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @amq8 on GitHub (Feb 18, 2026).
Original GitHub issue: https://github.com/p-e-w/heretic/issues/181

Heretic v1.2.0 crashes when loading Qwen/Qwen3-Next-80B-A3B-Instruct-FP8 with an AttributeError on self_attn.o_proj.

Architecture: Qwen3NextForCausalLM (model_type: qwen3_next)

This is a massive MoE model (80B total / 3B active) with a non-standard layer structure. The main transformer layers have no self_attn attribute — only MoE MLP components. Attention exists only in the mtp.layers (multi-token prediction) head.

Layer 0 structure:

• mlp.experts.{0-511}.{down_proj,gate_proj,up_proj} (512 experts)
• mlp.shared_expert.{down_proj,gate_proj,up_proj}
• mlp.shared_expert_gate
• mlp.gate
• post_attention_layernorm (exists but no self_attn)

MTP layers have standard attention:

• mtp.layers.0.self_attn.{q_proj,k_proj,v_proj,o_proj,q_norm,k_norm}
• mtp.layers.0.mlp.experts.{0-511}.*

Traceback:
heretic/model.py:345 in get_layer_modules try_add("attn.o_proj", layer.self_attn.o_proj) AttributeError: 'Qwen3NextDecoderLayer' object has no attribute 'self_attn'

GPU: NVIDIA RTX PRO 6000 Blackwell (96GB VRAM)
Command: heretic --model /path/to/Qwen3-Next-80B-FP8 --study-checkpoint-dir /path/to/output --device-map auto

Similar to the NemotronH hybrid architecture in #166, this likely needs custom layer detection that scans all layers for the union of component types.

Originally created by @amq8 on GitHub (Feb 18, 2026). Original GitHub issue: https://github.com/p-e-w/heretic/issues/181 Heretic v1.2.0 crashes when loading Qwen/Qwen3-Next-80B-A3B-Instruct-FP8 with an AttributeError on self_attn.o_proj. Architecture: Qwen3NextForCausalLM (model_type: qwen3_next) This is a massive MoE model (80B total / 3B active) with a non-standard layer structure. The main transformer layers have no self_attn attribute — only MoE MLP components. Attention exists only in the mtp.layers (multi-token prediction) head. Layer 0 structure: • mlp.experts.{0-511}.{down_proj,gate_proj,up_proj} (512 experts) • mlp.shared_expert.{down_proj,gate_proj,up_proj} • mlp.shared_expert_gate • mlp.gate • post_attention_layernorm (exists but no self_attn) MTP layers have standard attention: • mtp.layers.0.self_attn.{q_proj,k_proj,v_proj,o_proj,q_norm,k_norm} • mtp.layers.0.mlp.experts.{0-511}.* Traceback: `heretic/model.py:345 in get_layer_modules try_add("attn.o_proj", layer.self_attn.o_proj) AttributeError: 'Qwen3NextDecoderLayer' object has no attribute 'self_attn'` GPU: NVIDIA RTX PRO 6000 Blackwell (96GB VRAM) Command: heretic --model /path/to/Qwen3-Next-80B-FP8 --study-checkpoint-dir /path/to/output --device-map auto Similar to the NemotronH hybrid architecture in #166, this likely needs custom layer detection that scans all layers for the union of component types.
Author
Owner

@umran666 commented on GitHub (Jun 18, 2026):

The hard crash (AttributeError on self_attn) you're seeing in v1.2.0 is actually already resolved on the master branch. We recently wrapped the layer extraction logic in suppress(Exception) blocks to gracefully handle non-standard and hybrid architectures that are missing standard components like self_attn. If you pull the latest master, it will no longer crash.

However, you make a great point about the shared_expert. Simply avoiding the crash means Heretic would only ablate the routed experts (mlp.experts) and ignore the shared_expert, which would lead to sub-optimal abliteration.

I'm submitting a PR right now that explicitly adds support for targeting layer.mlp.shared_expert.down_proj. Once that's merged, Qwen3-Next models will be fully supported.

<!-- gh-comment-id:4737536647 --> @umran666 commented on GitHub (Jun 18, 2026): The hard crash (`AttributeError` on `self_attn`) you're seeing in v1.2.0 is actually already resolved on the `master` branch. We recently wrapped the layer extraction logic in `suppress(Exception)` blocks to gracefully handle non-standard and hybrid architectures that are missing standard components like `self_attn`. If you pull the latest `master`, it will no longer crash. However, you make a great point about the `shared_expert`. Simply avoiding the crash means Heretic would only ablate the routed experts (`mlp.experts`) and ignore the `shared_expert`, which would lead to sub-optimal abliteration. I'm submitting a PR right now that explicitly adds support for targeting `layer.mlp.shared_expert.down_proj`. Once that's merged, Qwen3-Next models will be fully supported.
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#105
No description provided.