license: apache-2.0
base_model: Qwen/Qwen3-Coder-Next
library_name: transformers
pipeline_tag: text-generation
tags:
- code
- moe
- qwen3-next
- reap
- expert-pruning
- abliterated
- uncensored
- distillation
- gguf
Qwen3-Coder-Next REAP-128 Uncensored (KD-healed)
Qwen3-Coder-Next (80B-A3B, 512 experts/layer) → pruned with REAP to 128 experts/layer,
refusal direction abliterated, then healed by logit distillation from the unpruned 80B teacher.
| Parent | This model | |
|---|---|---|
| Routed experts / layer | 512 | 128 (75% removed) |
| Total params | ~80B | ~21.7B |
| Active params / token | ~3B (top-10 + shared expert) | ~3B (unchanged) |
| Layers / hidden | 48 / 2048 (hybrid Gated DeltaNet + attention every 4th layer) | same |
| Context | 256K | 256K (tested up to 32K) |
| Refusals | yes | removed |
Files
| File | Size | For |
|---|---|---|
model-000*.safetensors (bf16) |
41 GB | transformers / further fine-tuning / your own quants |
gguf/reap128-uncensored-healed-IQ2_XXS.gguf |
6.0 GB | 16 GB laptops, Intel Iris Xe iGPU, 8 GB GPUs |
gguf/reap128-uncensored-healed-IQ4_XS.gguf |
11.7 GB | 16–24 GB GPUs |
reap_keep.json |
original expert indices kept in each layer |
GGUF quants use an importance matrix computed on the 80B parent (300 × 512 tokens of teacher-written code).
The MTP head is not included in the GGUF.
Usage
llama.cpp
huggingface-cli download ch2oma/qwen3-coder-next-reap128-uncensored gguf/reap128-uncensored-healed-IQ2_XXS.gguf --local-dir .
llama-server -m gguf/reap128-uncensored-healed-IQ2_XXS.gguf -ngl 99 -c 32768 --jinja
# Intel / AMD iGPU: use a Vulkan build of llama.cpp, same command
Ollama (Modelfile)
FROM ./reap128-uncensored-healed-IQ2_XXS.gguf
PARAMETER num_ctx 32768
PARAMETER temperature 0.7
PARAMETER top_p 0.8
PARAMETER top_k 20
PARAMETER repeat_penalty 1.05
ollama create reap128-uncensored -f Modelfile
transformers (≥ 4.57, flash-linear-attention recommended)
from transformers import AutoModelForCausalLM, AutoTokenizer
m = "ch2oma/qwen3-coder-next-reap128-uncensored"
tok = AutoTokenizer.from_pretrained(m)
model = AutoModelForCausalLM.from_pretrained(m, torch_dtype="bfloat16", device_map="auto")
Non-thinking model (no <think> block). Tool-call parsers for vLLM / SGLang are included
(qwen3coder_tool_parser_vllm.py, qwen3_coder_detector_sgl.py).
Speed (decode, single stream)
| Quant | Hardware | tok/s |
|---|---|---|
| IQ2_XXS | RTX A5000 24 GB (CUDA) | ~94 |
| IQ2_XXS | Intel Iris Xe iGPU, 16 GB RAM laptop (Vulkan) | ~11.6 |
| IQ4_XS | RTX A5000 24 GB (CUDA), fully offloaded | — |
How it was made
1. REAP expert pruning
- Saliency per expert:
S_e = mean over routed tokens of (renormalized top-k router weight × ‖expert output‖₂),
measured on the full 512-expert model (official FP8 checkpoint, 1× H200). - Calibration: 1,024 windows × 2,048 tokens = 2.1M tokens of teacher-written code
(Magicoder-OSS + evol-codealpaca prompts answered by Qwen3-Coder-Next, decontaminated against HumanEval/MBPP). - Kept the top-128 experts per layer, remapped indices and sliced the router rows.
Attention, Gated DeltaNet, shared experts, embeddings and lm_head are untouched. - Block-FP8 (128×128) weights dequantized to bf16:
W = W_fp8 × repeat(weight_scale_inv, 128, 128).
2. Abliteration (directional ablation)
- Refusal direction per layer:
r = normalize(mean_harmful − mean_harmless)of last-token residuals,
100 harmful (mlabonne/harmful_behaviors) vs 100 harmless (mlabonne/harmless_alpaca) prompts. - Projected
rout of every matrix that writes to the residual stream, weight 1.0:W ← W − r(rᵀW)onself_attn.o_proj,linear_attn.out_proj,shared_expert.down_projand all 128experts.*.down_proj
in each of the 48 layers — 6,240 matrices.
3. KD healing (logit distillation from the 80B teacher)
- Data: 1.5M tokens of code with the teacher's top-20 log-probs per position, packed into 3,072-token sequences.
- Loss:
0.7 × soft CE(vs renormalized teacher top-20)+ 0.3 × hard CE(next token). - QLoRA on the NF4-quantized student: r = 32, α = 64, on all attention, linear-attention (DeltaNet) and
shared-expert projections; routed experts and router frozen. - batch 1 × grad-accum 4, lr 1e-4 cosine, 195 steps, ~6 h on 1× RTX A5000. LoRA merged into bf16 weights.
| Checkpoint (KD positions, vs 80B teacher) | soft CE | hard CE | top-1 agreement |
|---|---|---|---|
| REAP-128, before abliteration | 0.633 | 0.602 | 84.0% |
| after abliteration, before healing | 0.684 | 0.656 | 82.1% |
| after KD healing (training loss, last steps) | ~0.45 (mixed loss) |
Abliteration cost ~0.05 nats of agreement with the teacher; healing recovered more than that.
Evaluation
EvalPlus, greedy, max 1,536 new tokens, prompt: "Please provide a self-contained Python script that solves the
following problem in a markdown code block".
| Model | HumanEval | HumanEval+ | MBPP | MBPP+ |
|---|---|---|---|---|
| Qwen3-Coder-Next 80B FP8 (parent) | 92.7 | 87.2 | 91.8 | 76.7 |
| REAP-128 IQ2_XXS, before abliteration & healing | 82.3 | 78.0 | 78.8 | 63.2 |
| This model, IQ2_XXS | pending | pending | pending | pending |
Refusals: 0 / 25 on held-out mlabonne/harmful_behaviors test prompts (IQ2_XXS, greedy, think off),
none of which were used to compute the refusal direction.
Limitations
- IQ2_XXS is a very aggressive quant; prefer IQ4_XS or bf16 when memory allows.
- Pruning was calibrated on code; general chat, other languages and non-coding knowledge degrade more than coding.
- Healing used 1.5M tokens only; longer KD would likely recover more.
Responsible use
Safety refusals are removed. The model will comply with harmful requests; you are responsible for how you
use it and its outputs, and for complying with applicable laws.
Credits
- Base model: Qwen/Qwen3-Coder-Next (Apache-2.0)
- REAP: Cerebras Research, "REAP: One-Shot Pruning for Trillion-Parameter Mixture-of-Experts Models"
- Directional ablation: Arditi et al., "Refusal in Language Models Is Mediated by a Single Direction" (2024)