# Qwen3-Coder-Next — Architecture & VRAM Specs

**Source:** unsloth/Qwen3-Coder-Next-GGUF Q4_K_M (46 GB file on disk, 48.5 GB nominal)

## Architecture

| Property | Value |
|----------|-------|
| **Total params** | 80B |
| **Active params** | 3B |
| **Architecture** | Hybrid: Gated DeltaNet + Gated Attention + MoE |
| **Layers** | 48 (12 × [3×DeltaNet→MoE + 1×Attention→MoE]) |
| **Attention layers** | 12 (only these produce KV cache) |
| **DeltaNet layers** | 36 (no KV cache) |
| **Q heads** | 16 |
| **KV heads** | 2 (GQA 8:1) |
| **Head dim** | 256 |
| **Rope dim** | 64 |
| **Experts** | 512 total, 10 active + 1 shared per token |
| **Native context** | 256K (262,144 tokens) |

## VRAM Budget (11 GB RTX 2080 Ti)

### With `--n-cpu-moe 48` (all MoE on CPU) + `-c 32768`

| Component | Size |
|-----------|------|
| Non-expert weights (GPU) | ~8-9 GB |
| MoE weights (GPU) | 0 GB (all on CPU) |
| KV cache at 32K ctx (q8_0) | ~1.57 GB |
| Overhead (OS/driver/buffers) | ~0.5 GB |
| **Total** | **~10.1-11.1 GB** ✓ fits |

### With `--n-cpu-moe 46` (2 layers' MoE on GPU) + `-c 131072` (validated)

| Component | Size |
|-----------|------|
| Non-expert weights (GPU) | ~0.8 GB |
| MoE weights (2 layers, ~830 MB each) | ~1.7 GB |
| KV cache at 128K ctx (q8_0) | ~6.29 GB |
| Overhead (OS/driver/buffers) | ~0.5 GB |
| **Total** | **~9.3 GB** ✓ fits |

**Benchmark (ncm=46):** 33.7 t/s generation, 69-70 t/s prompt processing. No OOM at 30K+ prompt tokens.

### With `--n-cpu-moe 42` (6 layers' MoE on GPU) + `-c 131072`

| Component | Size |
|-----------|------|
| Non-expert weights (GPU) | ~0.8 GB |
| MoE weights (6 layers, ~830 MB each) | ~5 GB |
| KV cache at 128K ctx (q8_0) | ~6.29 GB |
| Overhead | ~0.5 GB |
| **Total** | **~12.6 GB** ✗ OOM on 11 GB |

## KV Cache Calculation

- Per-layer KV: 2 (K+V) × 2 (KV heads) × 256 (head_dim) = **1,024 bytes/layer at q8_0**
- Per token (all 48 layers allocated): 48 × 1,024 = **49,152 bytes = 48 KB/token**
- Per token (actual 12 attention layers): 12 × 1,024 = **12,288 bytes = 12 KB/token**

⚠️ llama.cpp allocates KV buffer for all 48 layers regardless of architecture. Budget from 48 KB/token.

| Context length | KV cache VRAM (q8_0) |
|---------------|---------------------|
| 8K | 0.39 GB |
| 16K | 0.79 GB |
| 32K | 1.57 GB |
| 64K | 3.15 GB |
| 128K | 6.29 GB |
| 256K | 12.6 GB |

## Recommended Flags for 11GB Card

```yaml
# Balanced: 2 layers MoE on GPU, full 128K context (validated: 33.7 t/s)
-ngl 99 --n-cpu-moe 46 -c 131072 --cache-type-k q8_0 --cache-type-v q8_0
--flash-attn on --no-host -fitt 1024

# Conservative: all MoE on CPU, limited context
-ngl 99 --n-cpu-moe 48 -c 32768 --cache-type-k q8_0 --cache-type-v q8_0
```

32K is the safe maximum with all-MoE-on-CPU. 128K works at --n-cpu-moe 46. At --n-cpu-moe 42, 128K context OOMs on 11 GB.
