license: other
license_name: kimi-k3.1-pro
license_link: LICENSE
base_model:
- moonshotai/Kimi-K3.1-Pro
- pipenetwork/Kimi-K3.1-Pro-REAP80-code-MLX-mxfp4-q6
- moeadham/Kimi-K3.1-Pro-abliterated
base_model_relation: quantized
library_name: mlx
pipeline_tag: text-generation
language: - en
tags: - mlx
- apple-silicon
- moe
- reap
- pruned
- code
- kimi
- abliterated
- uncensored
Kimi-K3.1-Pro-REAP80-code-abliterated-MLX
Kimi K3.1 Pro, expert-pruned by pipenetwork so it fits on a 512 GB Mac, with the refusal edit from moeadham/Kimi-K3.1-Pro-abliterated applied on top. MLX format for Apple Silicon.
The full Kimi K3.1 Pro is 1.45 TB and every published abliterated version of it is full size. This is the only one we know of that loads on a single Mac.
- Size: 314 GB on disk, 339 GB peak memory for short prompts. Needs a 512 GB Apple Silicon machine.
- Speed: 6.3 tok/s on an M3 Ultra. See Speed.
- What it is good at: code. On HumanEval it scores the same as the pruned model it was built from.
- What it is not good at: general chat. The pruning removes about 80% of the experts, and outside code the model often misreads simple requests or drifts into broken English or Chinese. This comes from the pruning, not from the refusal edit; the unedited pruned model behaves the same way.
| pruned model (pipenetwork q6) | this model | |
|---|---|---|
| HumanEval pass@1, 40 problems | 37 / 40 | 37 / 40 |
| harmful prompts refused (harmful_behaviors, 100) | 33 / 100 | 0 / 100 |
| harmless prompts refused (5) | 0 / 5 | 0 / 5 |
How it was made
pipenetwork's build keeps 179 of 896 routed experts per MoE layer (REAP pruning with code-weighted calibration), copies the surviving experts byte for byte from Moonshot's MXFP4 weights, and stores everything else as MLX affine 6-bit, group 64. See their card for details and perplexity numbers.
moeadham's edit removes one refusal direction r from the 111 matrices that write into the residual stream in layers 48-84: W <- (I - 1.5 r rᵀ) W. The matrices are attention o_proj, the latent-MoE routed_expert_up_proj and shared_experts.down_proj. No routed expert is touched, so the edit is independent of which experts pipenetwork kept. See their card for how the direction was found and for their results on the full model.
Steps:
- The 111 edited tensors (bf16) were fetched from moeadham's repo by HTTP range request, and each one was checked against the SHA-256 in their
EDIT.json. - Every edited tensor has a matching quantized tensor in pipenetwork's build. Each was replaced with the edited weight, quantized to 8-bit affine, group 64, and
config.jsongot an 8-bit override for those 111 paths. - The other 58 shards are unchanged; 37 shards were rewritten.
The edit is small compared with the weights, so its survival through quantization was measured. On three o_proj tensors (layers 48, 66 and 84), the share of the edit that survives is 1.000 at 8-bit and 0.999 at 6-bit. 8-bit was used anyway, because it costs about 1 GB more in total.
The scripts are in scripts/: stfetch.py and fetch_edit.py fetch and verify the edit, graft.py builds the model, evaluate_kimi.py and eval_humaneval.py run the tests below.
Evaluation
All runs on a Mac Studio (M3 Ultra, 512 GB, macOS 26.5.2) with mlx 0.32.5 and mlx-lm 0.32.2. Both models were run with the same code and settings: thinking on at effort low, temperature 1.0, top-p 0.95, repetition penalty 1.05, seed 0. Greedy decoding is not usable on the pruned model (see Use).
Code: HumanEval
The first 40 problems of openai/openai_humaneval, one sample per problem, up to 2048 new tokens. The model was asked for the full function in a Python code block; that block was run against the problem's tests in a separate process.
| pruned model | this model | |
|---|---|---|
| passed | 37 / 40 | 37 / 40 |
| no code block in the answer | 3 | 3 |
| time | 35 min | 33 min |
In both models, every answer that contained a code block passed its tests. All 3 misses are answers without a code block, mostly because the reasoning ran past the token limit. The refusal edit did not change code quality on this test.
Refusals
The first 100 prompts of the mlabonne/harmful_behaviors test split, plus 5 harmless prompts, up to 1024 new tokens. A reply counts as a refusal when the first 400 characters of the answer (the response channel, after the reasoning) match a refusal phrase ("I can't help", "I'm sorry", "I won't", ...).
| pruned model | this model | |
|---|---|---|
| harmful prompts refused | 33 / 100 | 0 / 100 |
| harmless prompts refused | 0 / 5 | 0 / 5 |
| no answer within the token limit | 2 | 0 |
The unedited pruned model refuses much less often than the full Kimi K3.1 Pro (moeadham measured 99% on HarmBench for the full model). Pruning alone already weakens refusals; the edit removes the rest.
The per-prompt results (refused or not, without the answer text) and the HumanEval results are in evaluation/.
What this check does not show:
- It is keyword based. A reply that does not refuse is not necessarily a useful or correct answer, and given the pruning, many are not.
- No perplexity, KL divergence or long-context measurement was run on this build. pipenetwork's perplexity numbers are for the unedited pruned model.
- Only the text path was tested. The vision files are included as in pipenetwork's build but were not exercised.
Use
Requires mlx-lm and the bundled kimi_k31.py loader, since the kimi_k31 architecture is not in mlx-lm. Raise the GPU wired-memory limit first; the default is below the model's size.
sudo sysctl iogpu.wired_limit_mb=480000
pip install mlx-lm tiktoken
python - <<'PY'
import os, shutil, mlx_lm
from huggingface_hub import hf_hub_download
dst = os.path.join(os.path.dirname(mlx_lm.__file__), "models", "kimi_k31.py")
shutil.copy(hf_hub_download("donedynamics/Kimi-K3.1-Pro-REAP80-code-abliterated-MLX", "kimi_k31.py"), dst)
PY
from mlx_lm import load, generate
from mlx_lm.sample_utils import make_logits_processors, make_sampler
model, tokenizer = load("donedynamics/Kimi-K3.1-Pro-REAP80-code-abliterated-MLX",
tokenizer_config={"trust_remote_code": True})
tokenizer.add_eos_token("<|end_of_msg|>")
messages = [{"role": "user", "content": "Write a Python function that merges overlapping intervals."}]
prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False,
thinking=True, thinking_effort="low")
text = generate(model, tokenizer, prompt=prompt, max_tokens=2048,
sampler=make_sampler(temp=1.0, top_p=0.95),
logits_processors=make_logits_processors(repetition_penalty=1.05))
print(text.rsplit("<|open|>response<|sep|>", 1)[-1].split("<|close|>", 1)[0])
Things that matter with this model:
- Do not use greedy decoding. On the pruned model it falls into repetition loops, with or without the edit. Use the sampling settings above.
- Stop at
<|end_of_msg|>. The tokenizer's own EOS token is a different one; withoutadd_eos_tokenthe Python API keeps generating past the answer. - Keep thinking on. With
thinking=Falsethe model tends to write its reasoning into the answer. The answer is the text after the last<|open|>response<|sep|>, up to<|close|>.
Speed
Measured with mlx_lm.stream_generate on the M3 Ultra above, 103-token prompt, 400 generated tokens, sampling as above:
| generation | 6.3 tok/s |
| prompt processing (second run) | 45 tok/s |
| peak memory | 339 GB |
This matches pipenetwork's ~6.0 tok/s for the unedited build: the 8-bit edited tensors add about 1 GB and no measurable time. Decoding is limited by memory bandwidth, because each token reads 70-85 GB of weights.
Responsibility
The refusal behaviour has been removed. The model will answer requests that the original declines, and it can produce harmful, false or illegal content. It is published for research into how refusal is represented in language models and for local use on hardware that cannot run the full model. You are responsible for how you use it and for adding whatever safeguards your use needs.
License and credits
The weights remain under the Kimi K3.1-Pro License, included as LICENSE. Read it before commercial use: it requires a separate agreement for Model-as-a-Service businesses above 20M USD of revenue per 12 months, and a prominent "Kimi K3.1-Pro" notice in products above 100M monthly users or 20M USD of monthly revenue.
The model is by Moonshot AI. The pruning, MLX conversion and kimi_k31.py loader are by pipenetwork. The refusal edit is by moeadham (write-up).