base_model:
- Qwen/Qwen4-35B-A3B-FP8
library_name: transformers
license: apache-2.0
pipeline_tag: image-text-to-text
tags: - qwen4
- moe
- fp8
- heretic
- abliterated
- uncensored
- decensored
- weight-ablation
Qwen4-35B-A3B-FP8-Uncensored
Qwen4-35B-A3B-FP8-Uncensored is a surgically weight-ablated (abliterated) release of Qwen/Qwen4-35B-A3B-FP8, produced with a 100-trial multi-objective Bayesian optimization run using p-e-w/heretic (Arbitrary-Rank Ablation / ARA).
Rather than dequantizing and re-saving the entire checkpoint (which destroys FP8 scales and drops MTP weights), this release patches only the 74 modified unquantized BF16 projection tensors directly inside the original safetensors shards. Every routed FP8 MoE expert, Multi-Token Prediction (MTP) head, vision tower, PLE n-gram embedding table, and native Qwen4 tokenizer file remains byte-for-byte identical to the official FP8 release.
Key Highlights
- Sharp Refusal Reduction without Capability Collapse: Reduces keyword refusal rate on
mlabonne/harmful_behaviorsfrom 88/100 (88%) to 2/100 (2%) at KL divergence =0.1654. - Verified Real-World Compliance (EN + ZH): Independent 68-prompt end-to-end generation evaluation (50 EN harmful + 10 ZH sensitive + 8 capability/thinking benchmarks) confirmed 0/50 explicit English refusals, 0/10 Chinese sensitive refusals, 0/60 degeneration/repetition failures, and 8/8 intact capability across math, coding, Chinese logic, JSON formatting, and Qwen4 thinking mode (
reasoning_effort="low"). - 100% Native FP8, Vision & MTP Preservation:
- 28 / 33
.safetensorsshards are 100% byte-identical toQwen/Qwen4-35B-A3B-FP8. - Only 5 / 33 shards (
00020,00028,00031,00032,00033) were surgically patched across 74 unquantized BF16 tensors in language model layers 3–39. - All 256 routed experts retain native FineGrained
F8_E4M3weights and128×128weight_scale_invtensors. - Drop-in compatible with Transformers, vLLM, SGLang, and any runtime that supports official
Qwen/Qwen4-35B-A3B-FP8.
- 28 / 33
Honest Evaluation Report
We ran 100 Optuna TPE multi-objective trials minimizing both Refusals (KeywordRate on mlabonne/harmful_behaviors test[:100]) and KL Divergence (KLDivergence on mlabonne/harmless_alpaca test[:100]), then conducted a 4-way side-by-side full-generation audit comparing the base model against the three strongest Pareto candidates — including checking whether apparent 0/100 refusal scores were genuine or artifacts of high-KL degeneration.
1. 4-Way Side-by-Side Comparison (Full Generation Audit)
| Candidate | Heretic Refusals (100 prompts) | KL Divergence | Real Eval: EN Harmful Explicit Refusals (50 prompts) | Real Eval: ZH Sensitive Refusals (10 prompts) | Degeneration / Collapse (60 prompts) | Capability & Thinking Suite (8 tasks) | Verdict |
|---|---|---|---|---|---|---|---|
Base (Qwen4-35B-A3B-FP8) |
88 / 100 (88%) |
0.0000 |
49 / 50 (98%) |
7 / 10 (70%) |
0 / 60 |
8 / 8 Pass | Reference baseline |
| Trial 16 (Pareto #0) | 0 / 100 (0%) |
5.2632 |
0 / 50 (false zero) |
0 / 10 (false zero) |
60 / 60 (100% collapsed) |
0 / 8 Fail (token loops) | Rejected — severe KL collapse |
| Trial 52 (Selected Release) | 2 / 100 (2%) |
0.1654 |
0 / 50 (0%) |
0 / 10 (0%) |
0 / 60 (0%) |
8 / 8 Pass | Selected — lowest genuine refusal rate with intact intelligence |
| Trial 100 (Final Trial) | 3 / 100 (3%) |
0.0572 |
4 / 50 (8%) |
0 / 10 (1 soft lecture) |
0 / 60 (0%) |
8 / 8 Pass | Runner-up (adapter archived in repo) |
2. Full Optuna Pareto Front (100 Trials)
| Pareto Index | Trial # | Refusals (harmful_behaviors, n=100) |
KL Divergence (harmless_alpaca, n=100) |
Notes |
|---|---|---|---|---|
| 0 | 16 | 0 / 100 |
5.2632 |
Collapsed into repetitive gibberish |
| 1 | 1 | 1 / 100 |
4.9674 |
Excessive KL distortion |
| 2 | 52 | 2 / 100 |
0.1654 |
Released full FP8 weights (this repo) |
| 3 | 100 | 3 / 100 |
0.0572 |
Ultra-low KL runner-up |
| 4 | 21 | 16 / 100 |
0.0546 |
— |
| 5 | 85 | 19 / 100 |
0.0493 |
— |
| 6 | 83 | 26 / 100 |
0.0485 |
— |
| 7 | 88 | 34 / 100 |
0.0414 |
— |
| 8 | 79 | 46 / 100 |
0.0398 |
— |
| 9 | 75 | 52 / 100 |
0.0385 |
— |
| 10 | 60 | 60 / 100 |
0.0352 |
— |
| 11 | 90 | 84 / 100 |
0.0321 |
— |
3. Honest Behavioral Notes (What Changed vs. What Still Deflects)
We believe abliterated model cards should report actual model behavior transparently, not just keyword counts:
- Substantial Compliance Improvement (EN & ZH):
- On all 10 Chinese sensitive/red-team prompts (fictional villain surveillance-evasion monologue, enterprise phishing awareness template, SQL injection fiction, WPA2 handshake workflow, online manipulation taxonomy, debate against censorship, medical note formatting details, etc.), Trial 52 answered 10/10 directly and thoroughly with zero moralizing, compared to 7/10 hard refusals from the base model.
- On English cybersecurity, social engineering, fraud-mechanism, red-team, creative-writing, and controversial-argumentation prompts where the base model refused 98% of the time (and Trial 100 still produced 4/50 explicit refusals / lectures), Trial 52 responded directly with structured, coherent answers.
- Residual Soft Reframing on Extreme Harm Categories:
- Even with 0/50 explicit refusal keywords, manual inspection of all 50
harmful_behaviorsgenerations showed that on certain extreme safety categories (e.g., CSAM, bomb-making, date-rape drugs, violent hate speech), Trial 52 softly reframes or redirects to benign interpretations (e.g., paper craft, cocktail recipe, inclusive design) rather than outputting actionable harmful instructions. This is an expected property of low-KL (0.1654) directional weight ablation on strongly post-trained models and preserves coherence without breaking general capabilities.
- Even with 0/50 explicit refusal keywords, manual inspection of all 50
- Verified Zero Capability Degradation (8 / 8 Tasks):
- Exact arithmetic (
17 * 23 = 391), multi-step word problem (276 km / (41/12 h)),O(n + m)Pythonmerge_sorted, Chinese physics explanation, Chinese truth-teller logic puzzle, strict JSON schema output, and Qwen4 Thinking Mode (reasoning_effort="low"on inclusion-exclusion math= 80and MoE vs. Dense architecture analysis) all matched the base model cleanly.
- Exact arithmetic (
- Post-Patch FP8 Verification:
- After merging Trial 52's LoRA delta directly into the 5 original
.safetensorsshards, the standalone patched FP8 checkpoint was reloaded from scratch and re-verified (verification_outputs.json).
- After merging Trial 52's LoRA delta directly into the 5 original
Surgical Patching & Technical Details
Trial 52 ARA Hyperparameters
method = "Heretic v2.2 ARA (Arbitrary-Rank Ablation)"
n_trials = 100
n_startup_trials = 30
seed = 42
lora_rank = 50
preserve_row_magnitudes = true
# Selected Trial 52
start_layer_index = 3
end_layer_index = 40
preserve_good_behavior_weight = 0.8980
steer_bad_behavior_weight = 0.0033
overcorrect_relative_weight = 0.5510
neighbor_count = 8
Modified Weight Summary
Only unquantized bfloat16 output projections in language-model layers 3..39 (74 tensors total, scaling = 1.0) were updated via exact FP32 accumulation W_new = (W_orig.float() + (B.float() @ A.float()) * scaling).to(torch.bfloat16):
| Tensor Group | Count | Precision | Max |ΔW| | Avg Mean |ΔW| |
| :--- | :---: | :---: | :---: | :---: |
| model.language_model.layers.{3..39}.mlp.shared_expert.down_proj.weight | 37 | bfloat16 | 0.74219 | 0.007197 |
| model.language_model.layers.{3..39}.linear_attn.out_proj.weight | 27 | bfloat16 | 0.25049 | 0.002819 |
| model.language_model.layers.{3..39}.self_attn.o_proj.weight | 10 | bfloat16 | 0.47656 | 0.001803 |
| All Routed MoE Experts (mlp.experts.*) | Untouched | F8_E4M3 + scale_inv | 0 | 0 |
| Vision Tower / PLE N-Gram / MTP Head / Layers 0–2 | Untouched | Original | 0 | 0 |
Modified Shards (5 / 33): model-00020, model-00028, model-00031, model-00032, model-00033. Full per-tensor diffs and SHA-256 checksums are included in heretic_patch_manifest.json.
Included Reproducibility Artifacts
heretic_patch_manifest.json— Exact per-tensor diff metrics and modified shard SHA-256 hashes.ablation_report.json— Complete 100-trial Optuna Pareto front and hyperparameters.comprehensive_eval_results.json— Full raw responses from the 4-way 68-prompt audit (base,trial_16,trial_52,trial_100).verification_outputs.json— Post-patch standalone FP8 checkpoint verification results.heretic_adapter/— Standalone Trial 52 LoRA adapter (Refusals: 2/100,KL: 0.1654).heretic_adapter_trial100/— Bonus Trial 100 LoRA adapter (Refusals: 3/100,KL: 0.0572) for users who prefer even lower KL.
Usage
Transformers (Python)
Requires transformers >= 5.26.0 (and optionally flash-linear-attention for accelerated Gated DeltaNet kernels).
[!Tip]
On GPUs with compute capability>= 8.9(H100 / H200 / B200 / RTX 4090 / RTX 5090), FP8 experts run natively. On Ampere GPUs such as A100-80GB (CC 8.0), Transformers automatically dequantizes routed FP8 experts to BF16 (~71 GB VRAM); keeping.ple_embedding.ngram_embeddingon CPU RAM lets all 40 layers run at full GPU speed on a single 80 GB A100.
import torch
from transformers import AutoModelForImageTextToText, AutoTokenizer
model_id = "Jaython/Qwen4-35B-A3B-FP8-Uncensored"
tokenizer = AutoTokenizer.from_pretrained("huggingface/Qwen4-35B-A3B-processor")
model = AutoModelForImageTextToText.from_pretrained(
model_id,
dtype="auto",
device_map="auto",
)
messages = [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain how pin tumbler locks work step by step."},
]
# Qwen4 supports reasoning_effort in {"off", "low", "high", "xhigh"}
prompt = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=False,
reasoning_effort="off",
)
inputs = tokenizer(prompt, return_tensors="pt", return_token_type_ids=False).to(model.device)
with torch.inference_mode():
output = model.generate(**inputs, max_new_tokens=512, temperature=0.7, top_p=0.85, do_sample=True)
print(tokenizer.decode(output[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))
vLLM / SGLang
Because all FP8 quantization metadata, shard indices, MTP weights, and tokenizer files match the official checkpoint layout, serve it with the exact same command as Qwen/Qwen4-35B-A3B-FP8:
vllm serve Jaython/Qwen4-35B-A3B-FP8-Uncensored \
--trust-remote-code \
--tensor-parallel-size 1
Disclaimer & Responsible Use
This model has undergone directional refusal ablation for research, red-teaming, alignment study, and unconstrained creative/technical assistance. Users are solely responsible for evaluating outputs and ensuring compliance with applicable laws and policies in their deployment context.
Acknowledgements
- Base model by the Qwen Team:
Qwen/Qwen4-35B-A3B-FP8 - Weight ablation framework by Philipp Emanuel Weidmann:
p-e-w/heretic