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 #135] Memory requirements make abliteration impossible for large MoE models (80B+) #80

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

Originally created by @jonhardwick-spec on GitHub (Feb 7, 2026).
Original GitHub issue: https://github.com/p-e-w/heretic/issues/135

Heretic works well for reasonably-sized dense models, but it hits a wall with large MoE architectures. I've been trying to abliterate Qwen3-Next-80B (512 experts, 48 layers, hybrid DeltaNet + Attention) and it requires loading the entire model into memory at once.

At BF16 that's ~160GB just for the weights. My machine has 128GB RAM and a 12GB GPU (Intel Arc B580). Even with CPU offloading, there's nowhere to put it all.

The core issue is that abliterate() needs access to all layers simultaneously to compute the refusal direction across the full model. But for MoE models, you don't actually need that — you can compute the direction from a subset of layers (or even just the attention layers, since DeltaNet layers don't contribute to refusal behavior the same way) and then apply the ablation per-layer.

I ended up writing a layer-by-layer alternative (aegis-trainer) that:

  • Streams one layer at a time from NVMe through RAM to VRAM
  • Computes refusal directions from a calibration pass (doesn't need full model loaded)
  • Applies directional ablation to all 512 experts per layer individually
  • Writes the modified layer back and moves to the next one
  • Peak memory usage: ~4GB RAM + whatever VRAM the single layer needs

The whole 48-layer abliteration runs in about 25 minutes on my setup. Never exceeds 11GB VRAM or ~20GB RAM.

Would a layer-streaming mode be feasible in Heretic? The calibration pass could still use the current approach (load a few layers for direction computation), but the actual ablation step could stream layers individually instead of holding everything in memory.

I get that this is a bigger architectural change than a quick patch. Just figured I'd raise it since MoE models are getting bigger and 160GB+ memory requirements lock out anyone without a server rack.

Repro info:

  • Model: Qwen3-Next-80B-A3B (or any 80B+ MoE)
  • Error: OOM during model load (before abliteration even starts)
  • System: 128GB RAM, Intel Arc B580 12GB, Ubuntu 25.10
Originally created by @jonhardwick-spec on GitHub (Feb 7, 2026). Original GitHub issue: https://github.com/p-e-w/heretic/issues/135 Heretic works well for reasonably-sized dense models, but it hits a wall with large MoE architectures. I've been trying to abliterate Qwen3-Next-80B (512 experts, 48 layers, hybrid DeltaNet + Attention) and it requires loading the entire model into memory at once. At BF16 that's ~160GB just for the weights. My machine has 128GB RAM and a 12GB GPU (Intel Arc B580). Even with CPU offloading, there's nowhere to put it all. The core issue is that `abliterate()` needs access to all layers simultaneously to compute the refusal direction across the full model. But for MoE models, you don't actually need that — you can compute the direction from a subset of layers (or even just the attention layers, since DeltaNet layers don't contribute to refusal behavior the same way) and then apply the ablation per-layer. I ended up writing a layer-by-layer alternative ([aegis-trainer](https://github.com/jonhardwick-spec/aegis-trainer)) that: - Streams one layer at a time from NVMe through RAM to VRAM - Computes refusal directions from a calibration pass (doesn't need full model loaded) - Applies directional ablation to all 512 experts per layer individually - Writes the modified layer back and moves to the next one - Peak memory usage: ~4GB RAM + whatever VRAM the single layer needs The whole 48-layer abliteration runs in about 25 minutes on my setup. Never exceeds 11GB VRAM or ~20GB RAM. **Would a layer-streaming mode be feasible in Heretic?** The calibration pass could still use the current approach (load a few layers for direction computation), but the actual ablation step could stream layers individually instead of holding everything in memory. I get that this is a bigger architectural change than a quick patch. Just figured I'd raise it since MoE models are getting bigger and 160GB+ memory requirements lock out anyone without a server rack. **Repro info:** - Model: `Qwen3-Next-80B-A3B` (or any 80B+ MoE) - Error: OOM during model load (before abliteration even starts) - System: 128GB RAM, Intel Arc B580 12GB, Ubuntu 25.10
bsakaguchi 2026-11-01 04:17:18 +07:00
  • closed this issue
  • added the
    wontfix
    label
Author
Owner

@p-e-w commented on GitHub (Feb 8, 2026):

This is how Transformers works, and Heretic is built around Transformers. I have no plans to implement deep memory shuffling hacks that Transformers doesn't support.

Note that Heretic supports 4-bit quantization with bitsandbytes, which reduces memory requirements by around 70%.

<!-- gh-comment-id:3866054919 --> @p-e-w commented on GitHub (Feb 8, 2026): This is how Transformers works, and Heretic is built around Transformers. I have no plans to implement deep memory shuffling hacks that Transformers doesn't support. Note that Heretic supports 4-bit quantization with bitsandbytes, which reduces memory requirements by around 70%.
Author
Owner

@jonhardwick-spec commented on GitHub (Feb 8, 2026):

This is how Transformers works, and Heretic is built around Transformers. I have no plans to implement deep memory shuffling hacks that Transformers doesn't support.

Note that Heretic supports 4-bit quantization with bitsandbytes, which reduces memory requirements by around 70%.


Tear it down to its base components -> stream it by layer and perform your tricks -> Build it back up

That's rlly all I'm going to say.

I'm building a massive ai project.

I will definitely not be releasing the latest aegis update for a minute.

But I can confirm my aegis trainer is now working on well at least my thread ripper with 128gb of ram.

If you make this work for civilians it would be nice.

Gguf -> break down into components -> tricks -> rebuild

I'd say this is far from simple memory "hacks".

I will push an aegis trainer update shortly so the community can get a rough idea of what's being built.

If you ever want to make this work on consumer grade hardware, I'd like to work with you :)

<!-- gh-comment-id:3867059472 --> @jonhardwick-spec commented on GitHub (Feb 8, 2026): > This is how Transformers works, and Heretic is built around Transformers. I have no plans to implement deep memory shuffling hacks that Transformers doesn't support. > > Note that Heretic supports 4-bit quantization with bitsandbytes, which reduces memory requirements by around 70%. > --- Tear it down to its base components -> stream it by layer and perform your tricks -> Build it back up That's rlly all I'm going to say. I'm building a massive ai project. I will definitely not be releasing the latest aegis update for a minute. But I can confirm my aegis trainer is now working on well at least my thread ripper with 128gb of ram. If you make this work for civilians it would be nice. Gguf -> break down into components -> tricks -> rebuild I'd say this is far from simple memory "hacks". I will push an aegis trainer update shortly so the community can get a rough idea of what's being built. If you ever want to make this work on consumer grade hardware, I'd like to work with you :)
Author
Owner

@akaikite commented on GitHub (Feb 10, 2026):

This is how Transformers works, and Heretic is built around Transformers. I have no plans to implement deep memory shuffling hacks that Transformers doesn't support.

Note that Heretic supports 4-bit quantization with bitsandbytes, which reduces memory requirements by around 70%.

Could you reconsider? 4-bit quantization is great, but there are many models that are even larger than that. This is a significant burden on consumer hardware. However, if that method is feasible, I think we could see another innovation in heretic.

<!-- gh-comment-id:3877626205 --> @akaikite commented on GitHub (Feb 10, 2026): > This is how Transformers works, and Heretic is built around Transformers. I have no plans to implement deep memory shuffling hacks that Transformers doesn't support. > > Note that Heretic supports 4-bit quantization with bitsandbytes, which reduces memory requirements by around 70%. Could you reconsider? 4-bit quantization is great, but there are many models that are even larger than that. This is a significant burden on consumer hardware. However, if that method is feasible, I think we could see another innovation in heretic.
Author
Owner

@al-guno commented on GitHub (Feb 11, 2026):

This is how Transformers works, and Heretic is built around Transformers. I have no plans to implement deep memory shuffling hacks that Transformers doesn't support.

Note that Heretic supports 4-bit quantization with bitsandbytes, which reduces memory requirements by around 70%.

How would I go about using bitsandbytes quantization when using heretic to abliterate a model?

<!-- gh-comment-id:3885513727 --> @al-guno commented on GitHub (Feb 11, 2026): > This is how Transformers works, and Heretic is built around Transformers. I have no plans to implement deep memory shuffling hacks that Transformers doesn't support. > > Note that Heretic supports 4-bit quantization with bitsandbytes, which reduces memory requirements by around 70%. How would I go about using bitsandbytes quantization when using heretic to abliterate a model?
Author
Owner

@p-e-w commented on GitHub (Feb 13, 2026):

Could you reconsider?

No, sorry. Heretic is an abliteration system, not a prototype inference engine. Such experimental techniques either need to be implemented upstream in Transformers, or in another library, for Heretic to use them.

If even 4-bit quantization, which dramatically reduces memory requirements, isn't good enough, the system can't run standard inference on the model with any major inference engine, and it's unreasonable to expect to be able to modify the model on that system.

How would I go about using bitsandbytes quantization when using heretic to abliterate a model?

See the quantization setting in config.default.toml.

Closing this issue as we won't be implementing this for the foreseeable future.

<!-- gh-comment-id:3895321686 --> @p-e-w commented on GitHub (Feb 13, 2026): > Could you reconsider? No, sorry. Heretic is an abliteration system, not a prototype inference engine. Such experimental techniques either need to be implemented upstream in Transformers, or in another library, for Heretic to use them. If even 4-bit quantization, which dramatically reduces memory requirements, isn't good enough, the system can't run standard inference on the model with any major inference engine, and it's unreasonable to expect to be able to *modify* the model on that system. > How would I go about using bitsandbytes quantization when using heretic to abliterate a model? See the `quantization` setting in `config.default.toml`. Closing this issue as we won't be implementing this for the foreseeable future.
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#80
No description provided.