qwen3.6-35b-a3b-phi-lattice-v2
4-bit phi-lattice v2 build of Qwen/Qwen3.6-35B-A3B (35.11B parameters in Qwen3_5MoeForConditionalGeneration, 40 hybrid Gated-DeltaNet / Gated-Attention layers, 256 routed experts + 1 shared expert per layer, 8 active routed experts per token).
- Archive:
qwen36_35b_a3b_phi_v2_packed_4bit.pt(20,381,446,102bytes /19,437.26 MiB/18.98 GiB,sha256: 734dd1816e785189b5481b4b5c0057d52a739ada5f2759e44055d4414f09262e) - Weight SQNR vs upstream
BF16:19.631 dBacross33,929,148,416quantized parameters - Exact Zero Weights:
4,446,973,763(13.11%exact sparsity) - Verified 24 GB GPU Footprint (
NVIDIA L4,low_vram_4bit):19,437.9 MiB(18.98 GiB) resident,19,793.7 MiB(19.33 GiB) peak during 512-token generation (verification job6af5b0ab37daa033b6281d61)
1. Memory Footprint (65.39 GiB BF16 -> 18.98 GiB 4-bit Resident)
All 80 3D routed expert banks (*.mlp.experts.gate_up_proj [256, 1024, 2048] and *.mlp.experts.down_proj [256, 2048, 512], 32.21B weights) and 2D linear projections (1.72B weights, K % 64 == 0) are packed into 4-bit uint8 nibbles plus fp16 group scales (group_size = 64).
Token embeddings (embed_tokens), lm_head, all MoE routers (mlp.gate.weight and shared_expert_gate.weight), norms, and 1D convolutions stay in original BF16 / FP32 inside protected_tensors.
| Checkpoint Variant | Disk Size | Resident GPU VRAM | Peak Generation VRAM (512 tokens) | Quantized Weights (33.93B) | Exact Sparsity |
|---|---|---|---|---|---|
Upstream Qwen/Qwen3.6-35B-A3B (BF16) | 66.97 GiB (71.90 GB) | 65.39 GiB | > 66 GiB (requires 80 GB GPU) | 1.00x | 0.00% |
qwen36_35b_a3b_phi_v2_packed_4bit.pt (low_vram_4bit / triton_4bit) | 18.98 GiB (19,437.3 MiB) | 18.98 GiB (19,437.9 MiB) | 19.33 GiB (19,793.7 MiB) | 3.76x (19.631 dB SQNR) | 13.11% (4.45B zeros) |
Fits comfortably on a single 24 GB GPU (RTX 3090 / RTX 4090 / L4) with ~4.6 GiB headroom. During forward, PhiPacked4BitMoeExperts unpacks or executes the fused Triton LUT-GEMM kernel only for the 8 active routed experts (expert_hit), leaving the other 248 experts untouched in 4-bit storage.
Takeaway (Memory & Hardware Fit): The upstream
65.39 GiBBF16model requires an 80 GB server GPU (A100/H100), where even a single long-context batch can triggerCUDA out of memory. Compressing the 3D expert banks (32.21Bweights) and 2D projections (1.72Bweights) onto the 4-bitphi-lattice v2reduces the resident footprint by3.45x(18.98 GiB) while keeping all MoE routers and token tables in exactBF16— shifting a 35B MoE model onto a single consumer 24 GB GPU with over4.6 GiBof free VRAM for KV cache and activations.
2. WikiText-2 Test Perplexity (296,815 tokens, 145 chunks × 2048)
Evaluated directly from the 4-bit archive in mode="low_vram_4bit" on the full Salesforce/wikitext (wikitext-2-raw-v1, test split, 145 chunks of seq_len=2048, 296,815 scored tokens, raw JSONs in evals/ppl_wikitext2_shared_bf16.json and evals/ppl_wikitext2.json, jobs 6af5c43797c30a21be6d5392 and 6af5b91b37daa033b6282a32):
| Quantization Variant | Calibration | Quantized Scope | Exact Zero Sparsity | Resident VRAM | WikiText-2 Perplexity (seq_len=2048) |
|---|---|---|---|---|---|
phi-lattice v2 (shared_expert_bf16=True, this repo) | None (data-free) | All 256 routed experts + Attention + Vision (33.80B params; 240 MiB shared_expert in BF16) | 13.11% (4.43B zeros) | 19.15 GiB (19,614 MiB) | 6.9519 (beats INT4 RTN!) |
phi-lattice v2 (shared_expert_bf16=False, this repo) | None (data-free) | All 256 routed experts + Shared Expert + Attention + Vision (33.93B params) | 13.11% (4.45B zeros) | 18.98 GiB (19,438 MiB) | 7.0117 |
INT4 RTN W4A16 (hongweimeng, group_size=128) | None (data-free) | Routed experts + Attention only (Shared Expert & Vision kept in FP16) | 0.00% | ~20.5 GiB | 6.9900 |
UINT4 RTN W4A16 (hongweimeng, asymmetric) | None (data-free) | Routed experts + Attention only (Shared Expert & Vision kept in FP16) | 0.00% | ~20.5 GiB | 6.9260 |
GGUF Q4_K_M (Infatoshi, mixed 4/5/6-bit, 4.88 bpw) | Importance matrix / K-quants | Text trunk (65 GB BF16 -> 20 GB GGUF) | 0.00% | ~20.0 GiB | 6.676 ± 0.043 (ctx=512) |
Why this comparison matters:
- Direct 4-bit apple-to-apple (
seq_len=2048): Inhongweimeng/Qwen3.6-35B-A3B-RTN-INT4-W4A16, both the always-activeshared_expertand the vision tower were kept in 16-bit (FP16) with0.00%sparsity (6.9900PPL). When our loader enables the optional240.0 MiBshared_expert_bf16=Truesidecar (shared_expert_bf16.pt),phi-lattice v2beats symmetricINT4 RTN(6.9519vs6.9900) while still quantizing the vision tower to 4-bit, dissolving4.43 billionweights (13.11%) to exact0.0, and using19.15 GiBVRAM (vs~20.5 GiB).- Note on
GGUF Q4_K_M(6.676):Q4_K_Mis a mixed 4/5/6-bit K-quant averaging4.88 bits/weight(not pure 4-bit) and was scored byllama-perplexityat a shorter context window (ctx=512), whereas all6.92–7.01numbers above are pure 4-bit weights evaluated overseq_len=2048(296,815tokens).
3. Open LLM Leaderboard v2: MuSR (Multistep Soft Reasoning, Subtext & Theory of Mind)
Evaluated with EleutherAI/lm-evaluation-harness (leaderboard_musr, raw JSON in evals/leaderboard_musr.json, job 6af5d83637daa033b628717a):
| Method / Checkpoint | Calibration | Sparsity | Resident VRAM | leaderboard_musr (acc_norm) | vs BF16 Base |
|---|---|---|---|---|---|
Upstream BF16 (Base) | — | 0.00% | 65.39 GiB | 0.4339 | Reference |
UINT4 RTN W4A16 (hongweimeng) | None | 0.00% | ~20.5 GiB | 0.4206 | -1.33% |
INT4 RTN W4A16 (hongweimeng) | None | 0.00% | ~20.5 GiB | 0.4630 | +2.91% |
phi-lattice v2 (shared_expert_bf16=True) | None | 13.11% | 19.15 GiB | 0.4481 | +1.42% |
Per-subtask breakdown (phi-lattice v2):
| MuSR Subtask | Items | Domain | acc_norm | stderr |
|---|---|---|---|---|
musr_murder_mysteries | 250 | Long-context detective deduction & hidden motives | 0.5320 | ±0.0316 |
musr_team_allocation | 250 | Soft social reasoning & role constraints | 0.4960 | ±0.0317 |
musr_object_placements | 256 | Theory of Mind (tracking unstated belief states) | 0.3164 | ±0.0291 |
Macro Average (leaderboard_musr) | 756 | All 3 subtasks | 0.4481 | — |
Takeaway (Abstract & Multi-Step Reasoning): Unlike arithmetic or surface-level trivia,
MuSRtests long-context narrative deduction (murder_mysteries), unstated belief tracking / Theory of Mind (object_placements), and soft social constraints (team_allocation). Dissolving4.43 billionsub-threshold weights (13.11%) to exact0.0while snapping the remaining expert weights tophi-lattice v2does not degrade abstract reasoning — it outperforms the unquantizedBF16baseline by+1.42%(0.4481vs0.4339) and asymmetricUINT4 RTNby+2.75%(0.4481vs0.4206), while running in19.15 GiBinstead of65.39 GiB.
4. Japanese Homophone Verification (「きく」 Sense, Kanji & English Split on 24 GB GPU)
Evaluated directly from the 4-bit archive in mode="low_vram_4bit" on a single 24 GB NVIDIA L4 (greedy, enable_thinking=False, raw output in pack_summary.json):
Prompt:
以下の各文に含まれる「きく」の意味を説明し、それぞれ漢字で書き分けてください。
また、各文を英語に翻訳し、日本語の「きく」が英語ではどう訳し分けられるかも示してください。
1. 薬がよくきく。
2. 音楽をきく。
3. 先生に質問をきく。
Model Output (low_vram_4bit, 19,437.9 MiB resident VRAM):
ご提示いただいた3つの文に含まれる「きく」は、すべて異なる漢字で書き分けられ、意味も異なります。それぞれの意味、漢字表記、英語訳、および英語での訳し分けについて解説します。
1. 薬がよくきく。
- 意味: 薬の効き目が期待通りであること。効果がある。
- 漢字: 効く
- 英語訳: The medicine works well.
- 英語での訳し分け: work
2. 音楽をきく。
- 意味: 音や音楽を耳で受け取る。聴覚によって認識する。
- 漢字: 聴く(※文脈では「聴く」がより適切、現代日本語では「聞く」も広く使われますが厳密には「聴く」が推奨されます)
- 英語訳: I listen to music.
- 英語での訳し分け: listen (to)
3. 先生に質問をきく。
- 意味: 他人から情報を得るために、口頭で尋ねる。
- 漢字: 聞く
- 英語訳: I ask the teacher a question.
- 英語での訳し分け: ask
Takeaway (Fine-Grained Multilingual Nuance): On smaller 4B checkpoints, 4-bit quantization typically preserves general meaning on
「きく」but loses the precision required to separate all three kanji (効く/聴く/聞く) and their English counterparts (work/listen to/ask). Inqwen3.6-35b-a3b-phi-lattice-v2(low_vram_4biton a single 24 GB GPU), keeping the MoE router inBF16preserves expert specialization: the model cleanly separates all three senses, selects the exact kanji, and even notes the stylistic distinction between everyday聞くand attentive聴くfor music.
5. Quick Start & Fast Gated-DeltaNet Kernels
Throughput note (
flash-linear-attention&causal-conv1d):Qwen3.6-35B-A3Buses hybridGated-DeltaNetlinear attention in 30 of its 40 layers. Withoutflash-linear-attentionandcausal-conv1dinstalled, Hugging Facetransformersfalls back to a sequential Python loop over sequence length (~2.4 tok/sin the minimal verification container). Install the native Gated-DeltaNet kernels alongsidetritonfor full GPU throughput:pip install triton flash-linear-attention causal-conv1d
import importlib.util
import torch
from huggingface_hub import hf_hub_download
from transformers import AutoTokenizer
repo_id = "ununununununununununununununununununun/qwen3.6-35b-a3b-phi-lattice-v2"
loader_path = hf_hub_download(repo_id=repo_id, filename="phi_loader.py")
spec = importlib.util.spec_from_file_location("phi_loader", loader_path)
phi_loader = importlib.util.module_from_spec(spec)
spec.loader.exec_module(phi_loader)
# Modes:
# - "low_vram_4bit": 18.98 GiB VRAM (unpacks only the 8 active experts per token)
# - "triton_4bit" : 18.98 GiB VRAM (fused Triton 4-bit LUT-GEMM on active experts)
# - "unrolled_bf16": 65.39 GiB VRAM (unpacks all tensors into BF16 parameters)
model = phi_loader.load_qwen36_moe_from_packed_4bit(
repo_id=repo_id,
mode="low_vram_4bit",
device="cuda",
dtype=torch.bfloat16,
shared_expert_bf16=False, # set True (+240 MiB VRAM) for 6.9519 WikiText-2 PPL
)
tokenizer = AutoTokenizer.from_pretrained(repo_id)