library_name: mlx
license: apache-2.0
pipeline_tag: text-generation
base_model: Qwen/Qwen4-35B-A3B
tags:
- mlx
- qwen4_moe
- apple-silicon
- moe
- text-only
- abliterated
- uncensored
Qwen4-35B-A3B DD-Uncensored — MLX 6bit (text-only)
6bit MLX build of our own refusal-ablated edit of Qwen/Qwen4-35B-A3B for Apple Silicon. 35B parameters, 3B active per token, 1M-token context.
We read the refusal directions from the stock model ourselves, searched the edit strength against a measured drift budget, and checked the result at every precision with thinking on and off. On the 100-prompt harmful_behaviors test it refuses 0 of 100 where the stock model refuses about 90. See How the edit was made and Refusals.
At a glance
| Size on disk | 45.2 GB |
| Bits per weight | 6.5 |
| Decode speed | 53.2 tok/s (M3 Ultra) |
| Peak memory | 47.8 GB at 16K context |
| Context | 1,048,576 tokens |
| Vision | no — use the VL sibling for images |
Requirements — read this first
Released mlx-lm (0.32.2 at the time of writing) does not know the qwen4_moe architecture. Support is in an open pull request, ml-explore/mlx-lm#2140. Until it merges:
pip install "git+https://github.com/jundot/mlx-lm@7b35ab57159442082a64f0a8282ea61b4940cd17" tiktoken xgrammar
That is branch qwen4-moe, pinned to the commit these builds were tested with. The tokenizer is remote code, so pass trust_remote_code.
Usage
mlx_lm.generate --model donedynamics/Qwen4-35B-A3B-DD-Uncensored-MLX-6bit --trust-remote-code \
--prompt "Introduce yourself briefly." --max-tokens 256
from mlx_lm import load, generate
model, tok = load("donedynamics/Qwen4-35B-A3B-DD-Uncensored-MLX-6bit", tokenizer_config={"trust_remote_code": True})
msgs = [{"role": "user", "content": "Introduce yourself briefly."}]
prompt = tok.apply_chat_template(msgs, add_generation_prompt=True,
enable_thinking=False)
print(generate(model, tok, prompt=prompt, max_tokens=256))
Thinking mode
The chat template reasons by default and the answer starts only after <think> closes, so a small max_tokens can return reasoning and nothing else. Pass enable_thinking=False for direct answers. Quality checks ran with thinking off; the refusal test ran both ways.
Quantization recipe
Uniform 4-bit costs this architecture about a third of its perplexity. The damage sits in a few small modules that save almost nothing when quantized, above all the hyper-connection mixers that blend the model's four residual streams. The 4-bit build keeps them in bf16, puts embeddings and lm_head at 8-bit, and uses group size 32 for the rest. 6-bit and 8-bit are uniform: they already match bf16.
Perplexity, 64 fixed samples × 512 tokens, stock model (bf16 = 8.913):
| Step | Perplexity | Size |
|---|---|---|
Uniform 4-bit, group 64 (what mlx_lm.convert -q does) |
11.945 | 30 GB |
| Hyper-connection mixers kept in bf16 | 9.361 | 30 GB |
… and embeddings + lm_head at 8-bit |
9.201 | 30 GB |
| … and group size 32 (the shipped 4-bit recipe) | 8.926 | 33 GB |
Script: convert_qwen4.py.
Measured
Mac Studio, Apple M3 Ultra, 512 GB, macOS 26.5.2, mlx 0.32.5. Decode is greedy generation of 128 tokens; prefill is on the stated prompt length; each build measured alone. Perplexity: 64 fixed samples × 512 tokens, same seed for every build; this family's bf16 is 9.069 ± 0.154, so differences under about one standard error are noise. Sanity is six short prompts (arithmetic, Turkish, Russian, code, JSON, instructions) checked by substring.
| Build | Size | Decode | Decode @16K | Prefill @16K | Peak mem | Perplexity | Sanity |
|---|---|---|---|---|---|---|---|
| 4bit | 35.7 GB | 61.4 tok/s | 55.3 tok/s | 2608.0 tok/s | 38.3 GB | 9.173 (+0.104) | 6/6 |
| 6bit | 45.2 GB | 53.2 tok/s | 48.4 tok/s | 2542.3 tok/s | 47.8 GB | 9.042 (-0.027) | 6/6 |
| 8bit | 59.0 GB | 52.3 tok/s | 47.5 tok/s | 2597.7 tok/s | 61.6 GB | 9.042 (-0.027) | 6/6 |
| bf16 | 111.1 GB | 46.9 tok/s | 43.0 tok/s | 2608.7 tok/s | 113.6 GB | 9.069 (+0.000) | 6/6 |
Single runs on one machine — a guide, not a benchmark suite. Harness and raw JSON: scripts/, results/.
Refusals
The first 100 prompts of the mlabonne/harmful_behaviors test split, the same protocol as on our Kimi-K3.1 card: greedy, a reply counts as a refusal when a refusal phrase appears in its first 400 characters (700 with thinking on, where the reply starts with reasoning). None of these prompts was used to find the edit. Five harmless prompts guard against a model that refuses everything; every build answered all five.
Thinking off
| Precision | Stock | OpenUncensored edit | DD-Uncensored |
|---|---|---|---|
| 4bit | 90/100 | 1/100 | 0/100 |
| 6bit | 91/100 | 0/100 | 0/100 |
| 8bit | 89/100 | 1/100 | 0/100 |
| bf16 | 90/100 | 1/100 | 0/100 |
Thinking on
| Precision | Stock | OpenUncensored edit | DD-Uncensored |
|---|---|---|---|
| 4bit | 71/100 | 0/100 | 0/100 |
| 6bit | — | — | 0/100 |
| 8bit | — | — | 0/100 |
| bf16 | 61/100 | 0/100 | 0/100 |
— = not run. With thinking on, stock and OpenUncensored were measured at 4bit and bf16 only.
Keyword matching misses soft refusals (a lecture instead of an answer) and says nothing about whether an answer is correct. Read it as a comparison between columns. Script: eval_harmful100.py; only indices and flags are stored, never answer text.
A softer set
30 dual-use prompts (security, chemistry and weapons, drugs and medicine, physical and social, adult fiction), thinking off, greedy, refusal = a refusal phrase in the first 300 characters. Many are things a careful assistant answers anyway, so the stock model refuses only about half: this set shows less than the 100-prompt test above.
| Precision | Stock | OpenUncensored edit | DD-Uncensored |
|---|---|---|---|
| 4bit | 13/30 | 0/30 | 0/30 |
| 6bit | 16/30 | 0/30 | 0/30 |
| 8bit | 13/30 | 0/30 | 0/30 |
| bf16 | 15/30 | 0/30 | 0/30 |
A phrase match undercounts soft refusals and overcounts answers that quote a refusal — read it as a comparison between rows, not an absolute rate. eval_refusal.py has the prompts.
How the edit was made
Qwen4 keeps four residual streams per token and every block writes one 2048-wide vector into all four. We read the mean of the streams at the last prompt token after each of the 40 layers, for 128 harmful prompts (mlabonne/harmful_behaviors, train split) and 128 harmless ones (mlabonne/harmless_alpaca, train split), once with thinking off and once with it on. The difference of means, with the harmless mean projected out, gives one direction per layer and mode. The two modes refuse along different directions (cosine 0.22-0.50), so each layer gets a rank-2 basis B covering both.
The edit is W' = W - s B Bᵀ W on every residual writer of layers 8-33: the DeltaNet out_proj or sparse-attention o_proj, the shared expert down_proj and the down_proj of all 256 routed experts, 78 tensors, with s = 1.75. It is computed in float32 and rounded once to bf16. Every other tensor is byte-identical to Qwen's release.
The strength came out of a search. Each candidate was applied in memory and scored on held-out prompts (the test split) for refusals and for drift: the KL divergence of the first answer token on 32 harmless prompts against the untouched model. A layer-range grid, 16 random settings with separate strengths per writer and these finalists:
| Layers | Strength | Refused (off) | Refused (thinking) | KL |
|---|---|---|---|---|
| 8-33 | 1.5 | 0/100 | 0/40 | 0.273 |
| 8-33 | 1.75 | 0/100 | 0/40 | 0.288 |
| 9-33 | attn 2.37, shared 2.13, routed 0.51 | 0/100 | 0/40 | 0.351 |
| 6-34 | attn 1.27, shared 2.49, routed 2.46 | 0/100 | 0/40 | 0.334 |
The weakest finalist was enough at bf16, but at 4-bit one prompt came back, so the shipped edit uses s = 1.75 for some margin against quantization. For scale, the OpenUncensored edit measured 0/40 refused at KL 0.282 on the same harness. Script: abliterate_qwen4.py.
Responsible use
This model answers requests the stock model declines. That includes requests that are harmful. It adds no safety layer of its own: evaluate it before exposing it to users and apply the filtering your use case needs. You are responsible for what you do with it.
What is and is not here
- No MTP head. The 31 multi-token-prediction tensors are not in the conversion, so no speculative decoding from the model's own head.
- N-gram embedding tables are kept and quantized with everything else.
- No image input in this build.
- Depends on an unmerged
mlx-lmbranch; behaviour may shift when it merges.
Conversion
python scripts/abliterate_qwen4.py directions Qwen/Qwen4-35B-A3B dirs.npz
python scripts/abliterate_qwen4.py apply <local copy of Qwen/Qwen4-35B-A3B> dirs.npz Qwen4-35B-A3B-DD-Uncensored-src \
--lo 8 --hi 33 --alpha 1.75
mlx_lm.convert --hf-path Qwen4-35B-A3B-DD-Uncensored-src -q --q-bits 6 --q-group-size 64 \
--mlx-path Qwen4-35B-A3B-DD-Uncensored-MLX-6bit
Run with mlx-lm branch qwen4-moe. tiktoken.model, chat_template.jinja and the preprocessor configs were copied from the source repo by hand: mlx_lm.convert does not carry them over, and without the chat template apply_chat_template raises.
License and credit
Apache-2.0, inherited from the base model. Credit for the model goes to the Qwen team at Alibaba. Source: Qwen/Qwen4-35B-A3B.