Architecture
~8 min readUpdated: December 2026

Qwen4-35B-A3B: Hybrid Linear-Sparse MoE & 1M Context Guide

Qwen4-35B-A3B hybrid linear-sparse MoE architecture with 1M context in Smoke Monkey

Qwen4-35B-A3B pairs 3B activated parameters across 256 experts with a 20B n-gram embedding table and 2B multi-token prediction (MTP) module (56.82B total BF16 parameters). Alternating 3 Gated DeltaNet linear-attention layers with 1 Qwen Sparse Attention layer across 40 total blocks, it supports a native 1,048,576-token context window under Apache 2.0.

Technical Review: Smoke Monkey Core Architecture Team
Tested on Node.js 18+ & BunTypeScript 5.x
Quick Answer & Executive Definition

Qwen4-35B-A3B: Hybrid Linear-Sparse MoE & 1M Context Guide: Qwen4-35B-A3B pairs 3B activated parameters across 256 experts with a 20B n-gram embedding table and 2B multi-token prediction (MTP) module (56.82B total BF16 parameters). Alternating 3 Gated DeltaNet linear-attention layers with 1 Qwen Sparse Attention layer across 40 total blocks, it supports a native 1,048,576-token context window under Apache 2.0. Designed as a zero-dependency, open-source TypeScript architecture under the MIT License with native Model Context Protocol (MCP) support and deterministic phase state machines.

Key Architectural Takeaways
Quick Implementation Exampleqwen4-35b-a3b-agent.ts
qwen4-35b-a3b-agent.tstypescript
import { createAgent } from '@smoke-monkey/harness';
// Run long-horizon coding and vision tasks on self-hosted Qwen4-35B-A3B
const agent = createAgent({
agentId: 'qwen4-35b-a3b-architect',
provider: 'openai-compatible',
baseUrl: 'http://127.0.0.1:8000/v1',
model: 'Qwen/Qwen4-35B-A3B',
workspacePath: process.cwd(),
mcpServers: {
filesystem: {
command: 'npx',
args: ['-y', '@modelcontextprotocol/server-filesystem', process.cwd()],
},
},
permissions: {
read_file: 'allow',
write_file: 'ask',
run_command: 'ask',
},
});
async function main() {
const result = await agent.run(
'Audit the repository architecture across all TypeScript modules and emit a dependency summary.'
);
console.log('Result:', result.summary);
}
main().catch(console.error);
Video Guides

Watch: Related Video Guides

Qwen4 35B-A3B: The MoE Everyone Was Waiting For, Tested Locally

Qwen4-35B-A3B: Why the 35B Model Is Really 57B

What Is Qwen4-35B-A3B and How Does Its Hybrid MoE Architecture Work?

Qwen4-35B-A3B is an Apache 2.0 open-weight multimodal Mixture-of-Experts model (Qwen4MoeForConditionalGeneration) built on a 3:1 ratio of Gated DeltaNet linear attention to Qwen Sparse Attention. Activating 3B parameters per token across 256 routed experts plus a 20B layer-2 n-gram embedding table, it delivers native 1,048,576-token context for agentic coding and visual workflows.

Because safetensors storage includes the 20B bigram/trigram embedding table (ngram_vocab_size_base: 10000000, ple_layer_ids: [2]) and the 2B Multi-Token Prediction (MTP) module alongside the 35B MoE backbone, the full BF16 checkpoint totals 56,823,261,808 parameters (113.65 GB across shards). During inference, only the active routed experts and indexed sparse KV blocks touch compute bandwidth.

Architectural ComponentVerified Specification (config.json & Model Card)Operational Impact
Total / Active Parameters56.82B BF16 total (35B MoE + 20B N-Gram + 2B MTP) / 3B activeHigh knowledge capacity at 3B-class FLOPs
Layer Layout (40 Layers)10 × (3 × Gated DeltaNet → MoE + 1 × Qwen Sparse Attn → MoE)Linear-time state for 75% of layers
Gated DeltaNet32 V heads, 16 QK heads, head_dim = 128, conv_kernel = 4Constant-memory recurrent state compression
Qwen Sparse Attention16 Q heads, 2 KV heads, head_dim = 256, indexer_budget = 2048Selects 512 blocks / 2,048 tokens dynamically
MoE & Gated Residual256 experts (8 routed + 1 shared, dim 512), 4-branch rank-256 residualFine-grained routing specialization
Context & Vision1,048,576 native context; 27-layer ViT (hidden=1152, patch=16)Handles multi-file repos and UI screenshots

Serving Qwen4-35B-A3B in vLLM, SGLang, and Tuning Thinking Effort

Unlike legacy Jinja-only tokenizers, Qwen4 ships a tiktoken-backed reference tokenizer (trust_remote_code=True) that differentiates control tokens from regular tokens at the ID level. Official recipes support vLLM, SGLang, TokenSpeed, llama.cpp, Ollama, Unsloth, and mlx-vlm.

For multi-turn agent harnesses, Qwen4 exposes reasoning_effort (xhigh, high default, low, off) and preserve_thinking. Lowering reasoning_effort speeds up single turns, yet official guidance notes that under-thinking on complex tool chains increases retry loops and total completion time.

bash
# Serve Qwen4-35B-A3B with SGLang or vLLM (OpenAI-compatible endpoint)
vllm serve "Qwen/Qwen4-35B-A3B" --trust-remote-code --port 8000

# Verify sampling parameters for Thinking vs Non-Thinking modes
curl -s http://127.0.0.1:8000/v1/chat/completions   -H "Content-Type: application/json"   -d '{
    "model": "Qwen/Qwen4-35B-A3B",
    "messages": [{"role": "user", "content": "Trace the MoE routing bottleneck in 3 steps."}],
    "temperature": 1.0,
    "top_p": 0.95,
    "top_k": 20,
    "reasoning_effort": "high"
  }'

Account for the 20B N-Gram Table in Memory Planning

Although compute per token matches a 3B dense model, full BF16 weights occupy ~113.6 GB on disk and VRAM due to the 20B layer-2 n-gram embedding table. Use quantized GGUF or FP8/INT4 shards on dual-GPU workstations, or offload embeddings appropriately.

Google Search Questions & Answers

Frequently Asked Questions

Q:Why does Hugging Face list 57B parameters for Qwen4-35B-A3B?

The 56.82B BF16 parameter count combines the 35B MoE transformer backbone (3B active per token), a 20B layer-2 bigram/trigram n-gram embedding table (10,000,000 entries), and a 2B hybrid Multi-Token Prediction (MTP) head.

Q:What is the native context length of Qwen4-35B-A3B?

Qwen4-35B-A3B supports a native 1,048,576-token context window (max_position_embeddings: 1048576) using a 3:1 ratio of Gated DeltaNet linear attention layers to Qwen Sparse Attention layers.

Q:Which sampling settings does Qwen4 recommend for thinking vs non-thinking mode?

For thinking mode, use temperature=1.0, top_p=0.95, top_k=20, min_p=0.0, presence_penalty=0.0. For non-thinking mode (reasoning_effort="off"), use temperature=0.7, top_p=0.80, top_k=20, presence_penalty=1.5.

Q:Does Qwen4-35B-A3B support multimodal image and video inputs?

Yes. Its config includes a 27-layer vision encoder (qwen4_moe_vision, hidden_size 1152, patch_size 16) and interleaved mRoPE sections [11, 11, 10] under the image-text-to-text pipeline.

Related Alternatives & Comparisons

Related Architecture Guides

View all guides

Build with Smoke Monkey Harness

Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.

npm install smoke-monkey-harness