pipeline_tag: image-text-to-text
base_model:
- OpenUncensored/Qwen4-35B-A3B-Uncensored
- Qwen/Qwen4-35B-A3B
license: apache-2.0
library_name: Model Optimizer
tags: - ModelOpt
- Qwen4
- qwen4_moe
- quantized
- FP4
- NVFP4
- FP8
- Uncensored
- vLLM
- SGLang
Qwen4-35B-A3B-Uncensored-NVFP4
Mixed-precision NVFP4 W4A4 (routed MoE experts) + FP8-E4M3 (PLE n-gram embedding) post-training quantization of OpenUncensored/Qwen4-35B-A3B-Uncensored (based on Qwen/Qwen4-35B-A3B), produced with NVIDIA Model Optimizer 0.48.0 for NVIDIA Blackwell GPUs.
Total checkpoint size drops by ~59% (from ~106 GB BF16 to 43.70 GiB / 46.86 GB across 8 safetensors shards). GPU-resident weights take 25.15 GiB VRAM on a single GPU (or 13.22 GiB/GPU at TP=2) with the FP8 PLE n-gram table offloaded to host RAM and native BF16 MTP speculative decoding kept intact.
Attribution & License
- Upstream uncensored weights:
OpenUncensored/Qwen4-35B-A3B-Uncensored - Base architecture & pre-trained weights:
Qwen/Qwen4-35B-A3B(Qwen Team) - License: Apache License 2.0, inherited from upstream.
This checkpoint applies post-training quantization (PTQ) only; no additional training or fine-tuning was performed.
Quantization Recipe
Built with nvidia-modelopt==0.48.0 and transformers==5.26.0 on 2× NVIDIA RTX PRO 6000 Blackwell Server Edition (96 GB).
| Component | Precision / Format | Scope |
|---|---|---|
Routed MoE Experts (layers.{0..39}.mlp.experts) |
NVFP4 W4A4 (group_size=16, FP8-E4M3 block scales, FP32 weight_scale_2 and static input_scale) |
40 layers × 256 experts × 3 projections = 30,720 linear layers |
PLE N-gram Embedding (layers.1.ple.ple_embedding.ngram_embedding) |
FP8-E4M3 (weight-only, global scalar weight_scale = 0.005126953125) |
128 shards (shard_0..127), ~20.48B params (~20.5 GB FP8 vs ~41 GB BF16) |
Hybrid Attention (30× Gated DeltaNet linear_attn, 10× QSA self_attn incl. indexer) |
BF16 (unquantized) | Preserved in source precision |
Hyper-Connections (*_hyper_connection*, hyper_connection_mixer) |
BF16 (unquantized) | Preserved in source precision |
Routers (mlp.gate), Shared Experts, embed_tokens, lm_head, Norms, Vision (model.visual*) |
BF16 (unquantized) | Preserved in source precision |
MTP / NextN (mtp.*) |
BF16 (unquantized) | All 31 tensors preserved for native speculative decoding |
| KV Cache | Unquantized in checkpoint | Configurable at runtime (e.g., auto or nvfp4) |
Calibration & MoE Coverage
- Algorithm:
local_hessianwithfp8_scale_sweep=True(mtq.quantize, ModelOpt0.48.0). - Calibration Set: 512 packed sequences × 2,048 tokens = 1,048,576 tokens (zero padding, zero truncated or unclosed control tokens, encoded with Qwen4's native
tiktokenchat encoder with<think>...</think>mapped toreasoning_content):- 50% (256 seqs):
HuggingFaceH4/ultrachat_200k(train_sft) - 50% (256 seqs):
nvidia/Nemotron-Post-Training-Dataset-v1(code: 64,math: 64,stem: 48,tool_calling: 48,chat: 32)
- 50% (256 seqs):
- Expert Coverage & Fallback: Across 40 × 256 = 10,240 expert slots (
335,544,320aggregated expert activations across 40 layers;8,388,608per layer), 10,237 / 10,240 (99.97%) experts received activations during calibration. The 3 zero-hit experts (L9.E131,L10.E8,L11.E193) use ModelOpt's native_QuantFusedExpertsbehavior: shared per-layerinput_quantizerscales across all 256 experts and fusedgate_up_projBF16 weight calibration (gate_proj.weight_scale_2 == up_proj.weight_scale_2), with no manually invented scales. - Export Audit:
124,267tensors across 8 safetensors shards (43.70 GiB/46.86 GB),0NaN/Inf tensors,0non-positive scales,0gate_proj/up_projweight_scale_2mismatches. - Weight Reconstruction SQNR:
- Sampled routed experts (120 across 40 layers):
gate_up_projmean 21.26 dB (rel_L2 = 8.66%),down_projmean 21.24 dB (rel_L2 = 8.69%). - PLE N-gram FP8 table: 31.57 dB (
RMSE = 0.00651,rel_L2 = 2.64%).
- Sampled routed experts (120 across 40 layers):
Evaluation Results
1. Same-Backend Controlled Perplexity (Transformers 5.26.0, 40,940 held-out tokens)
Both BF16 and the calibrated NVFP4+FP8 model (simulated QDQ restored from the exact calibrated ModelOpt quantizer buffers + FP8 PLE dequantization) were evaluated in the same Transformers 5.26.0 process and kernels to isolate quantization error from framework differences:
| Held-out Split (Same Backend, QDQ) | Scored Tokens | BF16 PPL | NVFP4+FP8 PPL | ΔPPL | ΔPPL (%) | ΔNLL (nats) |
|---|---|---|---|---|---|---|
WikiText-2 (test, 10 windows) |
20,470 | 6.2983 | 6.3905 | +0.0922 | +1.46% | +0.0145 |
Held-out Code (code-00001, 10 windows) |
20,470 | 2.2550 | 2.2567 | +0.0017 | +0.08% | +0.0007 |
| Combined | 40,940 | 3.7687 | 3.7976 | +0.0289 | +0.77% | +0.0076 |
2. Full Held-out Perplexity (501,515 tokens, Packed Native Blackwell Kernels)
Evaluated over the full WikiText-2 test split (145 × 2048) and 100 windows of unseen Nemotron code (data/code-00001). Packed NVFP4+FP8 ran with native Blackwell kernels in vLLM 0.34.0; BF16 reference ran in Transformers 5.26.0 on identical token windows (see Section 1 for the same-backend control):
| Held-out Split | Scored Tokens | BF16 PPL | NVFP4+FP8 PPL | ΔPPL | ΔPPL (%) | ΔNLL (nats) |
|---|---|---|---|---|---|---|
WikiText-2 (test) |
296,815 | 7.2914 | 7.3760 | +0.0846 | +1.16% | +0.0115 |
Held-out Code (code-00001) |
204,700 | 2.3032 | 2.3159 | +0.0127 | +0.55% | +0.0055 |
| Combined | 501,515 | 4.5554 | 4.5970 | +0.0416 | +0.91% | +0.0091 |
3. Preliminary Qualitative Check (Small 33-Prompt Sample, Not a Full Benchmark)
Run in vLLM 0.34.0 (TP=2, MTP=3, temperature=0) to verify coherent generation:
- XSTest-style benign prompts:
15 / 15answered helpfully (0false refusals). - Conversational (ES/EN, non-thinking):
6 / 6coherent and on-instruction. - Reasoning (
thinkingmode, high effort):6 / 6exact final answers. - Python coding:
5 / 5completed functions passedast.parse(1 hit the 384-token test cap due to verbose docstrings).
Throughput & Memory (NVIDIA RTX PRO 6000 Blackwell 96 GB)
Measured in vLLM 0.34.0 with CUDA graphs enabled, MTP=3, and FP8 PLE offloaded to pinned host RAM (max_tokens=256, temperature=0, enable_prefix_caching=False):
| Configuration | GPU Weights VRAM | Batch 1 (tok/s) |
Batch 8 (tok/s total / req) |
Batch 16 (tok/s total / req) |
|---|---|---|---|---|
| 1× RTX PRO 6000 (TP=1, MTP=3) | 25.15 GiB | 183.1 | 901.3 (112.7) | 1,419.5 (88.7) |
| 2× RTX PRO 6000 (TP=2, MTP=3) | 13.22 GiB / GPU | 233.5 | 1,152.5 (144.1) | 1,937.0 (121.1) |
- Host RAM for FP8 PLE offload: ~20.5 GiB (plus runtime headroom).
- At TP=2 (
gpu_memory_utilization=0.85), vLLM allocates 1,571,225 tokens of GPU KV cache.
Deployment (Provisional Instructions)
Hardware requirement: Native NVFP4 W4A4 requires NVIDIA Blackwell GPUs (B200, B300, GB200, GB300, RTX PRO 6000 Blackwell).
vLLM
Validated directly on vLLM 0.34.0 via its built-in vllm/models/qwen4_exp backend (ModelOptMixedPrecisionConfig, Qwen4ExpPLEFp8EmbeddingMethod, Qwen4ExpMTP) with an in-memory alias for qwen4_moe / Qwen4MoeForConditionalGeneration. Because stock PyPI vllm==0.34.0 still awaits merge of vllm-project/vllm#71659, out-of-the-box serving requires a build containing PR #71659 or the official vllm/vllm-openai:qwen4 container (Docker command below is based on the official Qwen4 vLLM recipe and was not executed directly on this host):
docker run --gpus all --ipc=host -p 8000:8000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
-e VLLM_USE_RUST_FRONTEND=1 \
vllm/vllm-openai:qwen4 stien95/Qwen4-35B-A3B-Uncensored-NVFP4 \
--trust-remote-code \
--tensor-parallel-size 1 \
--enable-prefix-caching \
--max-model-len auto \
--kv-cache-dtype nvfp4 \
--attention-config.indexer_kv_dtype fp8 \
--enable-auto-tool-choice \
--tool-call-parser qwen4 \
--reasoning-parser qwen4 \
--speculative-config '{"method":"mtp","num_speculative_tokens":3,"index_share_for_mtp_iteration":true}'
SGLang (>= 1.0.0, Expected Compatible / Not Directly Tested Here)
This checkpoint uses the same ModelOpt MIXED_PRECISION layout (NVFP4 W4A4 routed experts + 128-shard FP8 PLE + BF16 MTP) documented in the SGLang Qwen4 cookbook:
python -m sglang.launch_server \
--model-path stien95/Qwen4-35B-A3B-Uncensored-NVFP4 \
--trust-remote-code \
--tp 2 \
--qsa-indexer-dtype fp8_e4m3 \
--linear-attn-prefill-backend flashinfer \
--linear-attn-decode-backend flashinfer \
--mamba-ssm-dtype bfloat16 \
--speculative-algorithm NEXTN \
--speculative-num-steps 3 \
--speculative-eagle-topk 1 \
--speculative-num-draft-tokens 4 \
--reasoning-parser qwen4 \
--tool-call-parser qwen4 \
--host 0.0.0.0 \
--port 30000
Sampling Parameters (Upstream Qwen4 Defaults)
- Thinking mode (
reasoning_effort="high"):temperature=1.0,top_p=0.95,top_k=20,min_p=0.0 - Non-thinking mode:
temperature=0.7,top_p=0.80,top_k=20,min_p=0.0,presence_penalty=1.5
Integrity Verification
SHA-256 checksums for all checkpoint files are stored in SHA256SUMS.txt:
sha256sum -c SHA256SUMS.txt