Running high-context Mixture-of-Experts (MoE) models locally for single-user agentic coding workflows requires balancing VRAM capacity, PCIe bandwidth, quantization precision, and prompt-processing latency. On my local inference server (server6), I benchmarked Qwen4-35B-A3B across two inference engines on dual NVIDIA L4 GPUs (46,068 MiB combined VRAM) in an air-gapped setup:
llama.cpp(llama-server) running Unsloth’s dynamic 6-bit GGUF (UD-Q6_K_XL) with Multi-Token Prediction (MTP) speculative decoding, CPU-offloaded per-layer token embeddings, and a full 524,288-token (512K) context window.vLLM(vllm serve) running the native 8-bit FP8 (Qwen4-35B-A3B-FP8) checkpoint across Tensor Parallelism (TP=2) withfp8KV cache, MTP speculative decoding, and an auto-resolved maximum context window of 178,432 tokens.
Below is the complete hardware topology, sequential llama.cpp compilation and systemd setup, UDM Pro firewall air-gapping, vLLM 8-bit vs. 6-bit GGUF testing findings, and side-by-side synthetic benchmarks.
1. Hardware & System Architecture (server6)
- GPUs: 2× NVIDIA L4 (23,034 MiB VRAM each; 46,068 MiB combined)
- Motherboard & PCIe Topology: ASUS X870E running both GPUs in PCIe 5.0
x8/x8bifurcation - System Memory: 192 GB DDR5 @ 4800 MT/s (used for CPU-offloaded per-layer/N-gram token embeddings and a 64 GB prompt RAM cache)
- Driver & CUDA Stack: NVIDIA Driver
595.112.07with CUDA13.2 - Network: Static IP
10.0.1.6behind a UniFi Dream Machine Pro (UDM Pro)
Understanding the Memory Math on 46 GiB VRAM
Qwen4-35B-A3B combines a 35B-parameter MoE backbone (~3B active parameters per token) with an additional ~21B-parameter N-gram / per-layer token embedding table (~56.4B parameters total).
- 8-Bit GGUF (
UD-Q8_K_XL) doesn’t fit entirely in VRAM: Even when dropping the multimodal projector (--mmproj), halving batch/ubatch sizes, and capping context at 256K, 8-bit GGUF weights plus the MTP draft head exceed the 46,068 MiB L4 ceiling by ~5–7 GB—forcing routed MoE experts onto DDR5 system memory (--n-cpu-moe) at the cost of decode speed. - 6-Bit GGUF (
UD-Q6_K_XL) fits 100% in VRAM: Offloading onlyper_layer_token_embd=CPUinto the 192 GB DDR5-4800 RAM leaves all 99 transformer/MoE layers and the MTP draft head resident on the two L4 GPUs with ~2.7 GiB of free headroom—even with a full 512Kq8_0KV cache.
2. System Prerequisites & Build Dependencies
Start by updating the system packages and installing the compiler toolchain, CMake, Git, and OpenSSL development headers required to build llama.cpp with CUDA and HTTP server support:
apt update && apt install -y build-essential cmake git libcurl4-openssl-dev python3-venv
3. Python Virtual Environment & Model Download
Create an isolated Python virtual environment in /opt/vllm-env and install huggingface_hub to pull the UD-Q6_K_XL 6-bit GGUF shards using the hf CLI:
python3 -m venv /opt/vllm-env
source /opt/vllm-env/bin/activate
pip install --upgrade pip huggingface_hub
mkdir -p /opt/models/Qwen4-35B-A3B-GGUF
hf download unsloth/Qwen4-35B-A3B-GGUF \
--include "UD-Q6_K_XL/*" \
--local-dir /opt/models/Qwen4-35B-A3B-GGUF
(Omitting the multimodal --mmproj projector runs the model language-only, saving ~0.9–1.2 GB of VRAM for long-context KV cache.)
4. Cloning and Compiling llama.cpp from Source
Clone llama.cpp into /opt/llama.cpp and compile llama-server with CUDA enabled (-DGGML_CUDA=ON):
cd /opt
git clone https://github.com/ggml-org/llama.cpp.git
cd /opt/llama.cpp
cmake -B build -DGGML_CUDA=ON -DLLAMA_CURL=ON
cmake --build build --config Release -j $(nproc)
5. Productionizing llama.cpp (6-Bit, 512K Context) with systemd
To serve a single user running heavy agentic coding sessions (large repository context, multi-file diffs, and tool loops), the llama-server flags prioritize maximum single-slot context capacity and KV cache precision:
CUDA_DEVICE_ORDER=PCI_BUS_ID&--device CUDA0,CUDA1 --split-mode layer --tensor-split 54,46: Pins GPU ordering to physical PCIe bus IDs (01:00.0and02:00.0) and balances VRAM allocation across both 24 GB cards.--override-tensor "per_layer_token_embd=CPU": Keeps per-layer token embeddings in DDR5 system RAM so all compute layers and KV cache remain in VRAM.--ctx-size 524288 --parallel 1: Dedicates the entire 512K context window to a single slot without dividing memory across concurrent users—accepting longer prompt/compaction waits at extreme context depth in exchange for keeping massive codebases resident.--cache-type-k q8_0 --cache-type-v q8_0 --flash-attn on: Quantizes the KV cache to 8-bit (q8_0) with Flash Attention enabled to preserve retrieval and code-reasoning accuracy across 512K tokens.--spec-type draft-mtp --spec-draft-n-max 2 --spec-draft-n-ubatch 512: Enables Qwen4’s native Multi-Token Prediction (MTP) speculative decoding head.--cache-ram 65536: Allocates 64 GB of DDR5 RAM for prompt prefix caching across turns.
Create /etc/systemd/system/llama.service:
Ini, TOML
[Unit]
Description=llama.cpp — Qwen4-35B-A3B UD-Q6_K_XL (6-bit) + MTP (512K)
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=root
WorkingDirectory=/opt/llama.cpp
Environment=LD_LIBRARY_PATH=/opt/llama.cpp/build/bin
Environment=CUDA_DEVICE_ORDER=PCI_BUS_ID
ExecStartPre=/bin/sh -c ': > /var/log/llama.log'
ExecStartPre=/bin/sh -c 'sync; echo 3 > /proc/sys/vm/drop_caches'
ExecStart=/opt/llama.cpp/build/bin/llama-server \
--model /opt/models/Qwen4-35B-A3B-GGUF/UD-Q6_K_XL/Qwen4-35B-A3B-UD-Q6_K_XL-00001-of-00002.gguf \
--spec-type draft-mtp --spec-draft-n-max 2 \
--device CUDA0,CUDA1 --split-mode layer --tensor-split 54,46 \
--n-gpu-layers 99 \
--ctx-size 524288 --parallel 1 \
--batch-size 4096 \
--ubatch-size 1024 \
--spec-draft-n-ubatch 512 \
--override-tensor "per_layer_token_embd=CPU" \
--load-mode none \
--flash-attn on \
--threads 8 \
--threads-batch 16 \
--threads-http 4 \
--cache-type-k q8_0 --cache-type-v q8_0 \
--cache-ram 65536 \
--host 0.0.0.0 --port 4000 \
--alias qwen \
--jinja \
--reasoning on \
--reasoning-preserve
StandardOutput=append:/var/log/llama.log
StandardError=append:/var/log/llama.log
Restart=on-failure
RestartSec=10
TimeoutStartSec=900
KillSignal=SIGINT
[Install]
WantedBy=multi-user.target
Enable and start the service:
systemctl daemon-reload
systemctl enable llama.service
systemctl start llama.service
6. Air-Gapping server6 on a UniFi Dream Machine Pro (UDM Pro)
Because server6 (10.0.1.6) processes private source code and repositories, I isolated it from the internet using a Zone-Based Firewall policy on my UDM Pro while keeping local LAN API access on port 4000 open:
- In UniFi Network, create a new Firewall policy named
Block LLM Internet access. - Set Source Zone to
Internal, select IP (or Device to cover both IPv4 and IPv6 addresses on the host), enter10.0.1.6, and click Add. - Set Action to
Block, IP Version toBoth, and Protocol toAll. - Set Destination Zone to
External(Any), then save and apply.
Testing from server6 confirms outbound WAN requests hang and drop while local LAN clients retain full access to [http://10.0.1.6:4000](http://10.0.1.6:4000):
root@server6:~# wget google.com
--2026-12-06 08:01:49-- http://google.com/
Resolving google.com (google.com)... 142.250.183.174, 2404:6800:4007:815::200e
Connecting to google.com (google.com)|142.250.183.174|:80... ^C
7. Testing vLLM: 8-Bit FP8 vs. 6-Bit GGUF Compatibility
To compare engines on the exact same dual-L4 hardware, I also ran vLLM (0.35.0rc1) on port 4000 (--max-num-seqs 1 for single-request concurrency, --tensor-parallel-size 2, --kv-cache-dtype fp8, and --speculative-config '{"method":"mtp","num_speculative_tokens":3,"index_share_for_mtp_iteration":true}').
Why 6-Bit Doesn’t Work in vLLM (Yet)
- No native 6-bit safetensors support: vLLM supports 8-bit (
FP8/INT8) and 4-bit (AWQ/GPTQ/Marlin) safetensors formats, but has no native 6-bit safetensors quantization kernels. - GGUF plugin blocker (
qwen4_exp): Merging the two 6-bit GGUF shards into a single file viallama-gguf-split --merge(912tensors), installingvllm-gguf-plugin, pointing--tokenizerto the local FP8 directory, and removing--speculative-configstill failed during model weight mapping:PlaintextRuntimeError: Unknown gguf model_type: qwen4_exp
Restoring 8-Bit Qwen4-35B-A3B-FP8 in vLLM
Switching vllm.service back to the native 8-bit checkpoint (/opt/models/Qwen4-35B-A3B-FP8) with HF_HUB_OFFLINE=1 and --kv-cache-memory 1417339207 (~1.32 GiB per GPU) booted cleanly across TP=2 and auto-resolved the maximum context length:
root@server6:~# curl -s http://localhost:4000/v1/models | grep -o '"max_model_len":[^,}]*'
"max_model_len":178432
Here is the working /etc/systemd/system/vllm.service unit for the 8-bit FP8 configuration:
Ini, TOML
[Unit]
Description=vLLM server for Qwen4-35B-A3B-FP8
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=root
WorkingDirectory=/root
Environment=CUDA_VISIBLE_DEVICES=0,1
Environment=NCCL_P2P_DISABLE=0
Environment=NCCL_IB_DISABLE=1
Environment=TOKENIZERS_PARALLELISM=false
Environment=PYTHONUNBUFFERED=1
Environment="TRITON_CACHE_DIR=/var/cache/vllm/triton"
Environment="VLLM_CACHE_ROOT=/var/cache/vllm"
Environment="OMP_NUM_THREADS=1"
Environment="HF_HUB_OFFLINE=1"
ExecStartPre=/usr/bin/mkdir -p /var/log /var/cache/vllm/triton
ExecStartPre=/usr/bin/bash -c ': > /var/log/vllm.log'
ExecStart=/opt/vllm-env/bin/vllm serve \
/opt/models/Qwen4-35B-A3B-FP8 \
--served-model-name qwen \
--host 0.0.0.0 \
--port 4000 \
--tensor-parallel-size 2 \
--max-num-seqs 1 \
--max-num-batched-tokens 2048 \
--max-model-len auto \
--kv-cache-memory 1417339207 \
--kv-cache-dtype fp8 \
--attention-config.indexer_kv_dtype fp8 \
--language-model-only \
--enable-prefix-caching \
--disable-flashinfer-autotune \
--enable-auto-tool-choice \
--reasoning-parser qwen4 \
--tool-call-parser qwen4 \
--speculative-config '{"method":"mtp","num_speculative_tokens":3,"index_share_for_mtp_iteration":true}' \
--default-chat-template-kwargs '{"enable_thinking": true, "reasoning_effort": "high", "preserve_thinking": true}' \
--trust-remote-code
Restart=on-failure
RestartSec=10
TimeoutStartSec=300
TimeoutStopSec=60
KillSignal=SIGINT
StandardOutput=append:/var/log/vllm.log
StandardError=append:/var/log/vllm.log
LimitNOFILE=1048576
[Install]
WantedBy=multi-user.target
8. GPU Telemetry Under Load: llama.cpp vs. vLLM
llama.cpp (UD-Q6_K_XL, Layer Split, 512K Context)
In llama.cpp, both L4s run at 60°C, 51W–58W / 72W, 42%–43% GPU utilization, and 43,358 MiB combined VRAM (21,955 MiB + 21,403 MiB), leaving ~2.7 GiB free:
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 595.112.07 Driver Version: 595.112.07 CUDA Version: 13.2 |
+-----------------------------------------+------------------------+----------------------+
| 0 NVIDIA L4 Off | 00000000:01:00.0 Off | 0 |
| N/A 60C P0 51W / 72W | 21955MiB / 23034MiB | 43% Default |
+-----------------------------------------+------------------------+----------------------+
| 1 NVIDIA L4 Off | 00000000:02:00.0 Off | 0 |
| N/A 60C P0 58W / 72W | 21403MiB / 23034MiB | 42% Default |
+-----------------------------------------+------------------------+----------------------+
vLLM (Qwen4-35B-A3B-FP8, TP=2, 178K Context)
In vLLM, Tensor Parallelism saturates both L4 GPUs at 100% utilization and right at their 71W–72W TDP ceiling (59°C–62°C), consuming 45,108 MiB combined VRAM (22,553 MiB + 22,555 MiB):
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 595.112.07 Driver Version: 595.112.07 CUDA Version: 13.2 |
+-----------------------------------------+------------------------+----------------------+
| 0 NVIDIA L4 Off | 00000000:01:00.0 Off | 0 |
| N/A 62C P0 72W / 72W | 22553MiB / 23034MiB | 100% Default |
+-----------------------------------------+------------------------+----------------------+
| 1 NVIDIA L4 Off | 00000000:02:00.0 Off | 0 |
| N/A 59C P0 71W / 72W | 22555MiB / 23034MiB | 100% Default |
+-----------------------------------------+------------------------+----------------------+
9. Synthetic Benchmark Comparison (bench_vllm.py)
Testing across prompt depths from 32K up to 512K highlights the exact trade-off between 8-bit FP8 in vLLM and 6-bit GGUF in llama.cpp on dual NVIDIA L4s:
| Target Prompt / Output | vLLM (8-Bit FP8, TP=2, MTP=3) | llama.cpp (6-Bit UD-Q6_K_XL, MTP=2) | Comparison |
| 32K / 1024 | 5.58 s TTFT · 5,746.4 PPS · 82.4 TGS | 11.24 s TTFT · 2,854.4 PPS · 61.3 TGS | vLLM 2.01× faster prefill · 1.34× faster decode |
| 64K / 2048 | 11.12 s TTFT · 5,761.9 PPS · 75.3 TGS | 21.59 s TTFT · 2,968.4 PPS · 50.8 TGS | vLLM 1.94× faster prefill · 1.48× faster decode |
| 128K / 4096 | 22.69 s TTFT · 5,644.0 PPS · 67.9 TGS | 46.14 s TTFT · 2,775.8 PPS · 39.8 TGS | vLLM 2.03× faster prefill · 1.71× faster decode |
| 170K / 4096 (vLLM ceiling) | 30.68 s TTFT · 5,544.3 PPS · 69.8 TGS | Between 128K and 256K points | vLLM maxes out at max_model_len: 178,432 |
| 256K / 8192 | HTTP 400 (> 178,432 max_model_len) | 107.38 s TTFT · 2,384.7 PPS · 27.7 TGS | llama.cpp clears 256K+8K (264K total) |
| 512K / 16384 | Exceeds VRAM / context ceiling | 293.02 s TTFT · 1,747.6 PPS · 16.5 TGS | llama.cpp reaches full 512K (524,288) |
10. Final Verdict: Which Runtime to Choose on Dual L4s?
- Choose
vLLM(Qwen4-35B-A3B-FP8,TP=2) when context fits inside ~178K tokens: By saturating both L4 GPUs’ native FP8 Tensor Cores (100%utilization) with Tensor Parallelism,vLLMdelivers ~2× faster prompt prefill (~5,544–5,762 tok/s) and 34%–71% faster decode (67.9–82.4 tok/s) while running higher-precision 8-bit FP8 weights. - Choose
llama.cpp(UD-Q6_K_XL+ CPU embedding offload) when you need 256K–512K context: Becausellama.cppsupports Unsloth’s dynamic 6-bit GGUF quantization and offloadsper_layer_token_embd=CPUcleanly to DDR5 RAM, it unlocks nearly 3× the maximum context window (524,288vs.178,432tokens) within the same 46 GiB VRAM footprint—running full half-million-token prompts locally without OOM or spilling compute layers onto system memory.