# Dual RTX 3090 LLM Inference Platform A production-grade LLM inference server running on consumer hardware. This repository documents the complete engineering process: hardware selection, deployment, benchmarking, optimization, and troubleshooting. ## Quick Facts | | | |---|---| | **Model** | Qwen3.6-35B-A3B (4-bit pack-quantized, 35.3B param MoE, 3.6B active) | | **Hardware** | 2× RTX 3090 24 GB (Z690 Taichi, PCIe Gen5 x8 bifurcation) | | **Framework** | vLLM v0.26.0 (V1 engine, TP=2, FlashInfer, FP8 KV cache) | | **Generation throughput** | **145.6 tok/s single-request** · **447.5 tok/s @ 4-way** (real API tokens, no-MTP) | | **Prompt processing** | **5,568 tok/s @ 1K** · 6,375 @ 32K · 3,518 @ 128K · 2,307 @ 256K (no-MTP burn era) | | **Max context** | **262,144 tokens** (true 256K prefill survives, no OOM) | | **System power** | **~590W** (287W + 203W GPUs + ~100W overhead) | | **Operating cost** | **€0.043 per 1M tokens** (~$0.048, 1.5M tok/hr, €0.065/hr) | | **Stability** | ✅ 10-min burn, 1,292 req, 0 errors · 256K prefill survives | | **Status** | Production — serving Hermes Agent + Free Claude Code (no-MTP, correctness-stable) | ## Repository Structure ``` dual-rtx3090-llm-inference-platform/ ├── README.md ← You are here ├── AGENTS.md — Graphify knowledge-graph hooks ├── architecture/ │ └── hardware-specs.md — BOM, GPU topology, system specs ├── benchmarks/ │ ├── benchmark-command.md — Methodology (reproducible) │ ├── qwen-results.md — Benchmark results │ ├── performance-tuning.md — Parameter exploration & trade-offs │ ├── parallelism-comparison.md — PP=2 vs TP=2 analysis │ ├── sustained-burn-continuous.py — 10-min continuous load test │ ├── sustained-burn-results.json / -uncapped.json — Burn datasets │ ├── comprehensive-benchmark.py / -v2.py — Full benchmark suite │ ├── prefill-scaling-test.py — Context scaling / TTFT test │ └── prefill-scaling-results.json — 1K–256K prefill data ├── deployment/ │ ├── start-vllm.sh — Production launch script (annotated, current config) │ ├── start-vllm-tp2.sh — Historical TP=2 config (reference only) │ ├── environment-notes.md — VENV setup, model storage, FCC integration │ └── docker-compose.yml — Containerized deployment ├── homelab-notes/ │ └── future-proxmox-design.md — Future Proxmox virtualization design ├── troubleshooting/ │ ├── cuda-issues.md — CUDA error catalog with solutions │ ├── nccl-debugging.md — Multi-GPU communication diagnosis │ └── lessons-learned.md — Cumulative engineering log └── screenshots/ — Visual proof (add your own) ``` ## Key Performance > **⚠️ MTP spec-decode is DISABLED in production (2026-08-03).** vLLM 0.26's MTP path is not output-identical to greedy serving: an A/B on 40 HumanEval problems (same prompt, temp 0) scored **27/40 (67.5%) with MTP vs 30/40 (75.0%) no-MTP** — 5/40 outputs diverged from greedy, the spec-decode contract. For code/agent workloads output correctness beats raw speed, so production runs **no MTP**. Numbers below marked "MTP/" are superseded history kept for reference. Details: `troubleshooting/cuda-issues.md`. All throughput values below are **real tokens from API usage accounting** (not word counts). Measured 2026-08-03 on the current production config (vLLM 0.26.0, TP=2, FlashInfer, FP8 KV, gpu-mem 0.80, **no-MTP**). Full sweep + history: `benchmarks/qwen-results.md`. | Metric | Value | Notes | |--------|-------|-------| | **Single-request decode (200 tok)** | 145.6 tok/s | no-MTP, fresh (08-03) | | **Sustained 4-worker decode** | 111.9 tok/s per-req | **447.5 tok/s aggregate**, fresh (08-03) | | **Latency (4-worker, 200-tok)** | P50 1,788ms · P99 ~2.3s | no-MTP | | **Prefill 1K / 8K / 32K** | 5,568 / 7,554 / 6,375 tok/s | TTFT 0.18 / 1.07 / 5.02s (no-MTP) | | **Prefill 64K / 128K / 256K** | 4,937 / 3,518 / 2,307 tok/s | TTFT 12.98 / 36.38 / 110.9s — 256K survives | | **Max context** | 262,144 tokens | true 256K prefill, no OOM | | **Tool calling** | ✅ `qwen3_coder` parser | Hermes/agent ready | | **GPU memory (steady-state)** | 19.4 GB / 24 GB per GPU | ~4.6 GiB headroom for KV spikes | *Superseded MTP (spec-3, 08-02, for reference): single 215.7 tok/s (+59%) · 4-way 606.3 · 8-way 927.2 · 32-way 1,576.4 · acceptance 71% (2.13 tok/draft). Disabled for correctness (see note above).* System efficiency: **0.71 tok/s/W · 2,539 tok/kWh** (590W system). Power/thermal: **GPU0 287W @ 77°C · GPU1 203W @ 69°C**, both 99% util, stable plateau. ## Design Decisions Every flag in the launch script (`deployment/start-vllm.sh`) represents a deliberate engineering trade-off. Here's the reasoning: ### Tensor Parallelism (TP=2) on the V1 engine — current config The current production config uses `--tensor-parallel-size 2` on vLLM's V1 engine, and it is the fastest configuration this platform has ever run: **150 tok/s single-request, 416 tok/s aggregate** — beating the previous PP=2 config (112–117 tok/s) by ~30%. Historical note: the original TP=2 attempt on the V0 engine (vLLM 0.22, `--enforce-eager`, custom all-reduce disabled) was capped at **28 tok/s** by per-layer all-reduce across the PCIe Gen5 x8 link — that's what drove the original switch to PP=2. On V1 + FlashInfer + FP8 KV, TP=2 no longer hits that wall; the V1 scheduler and kernel pipeline hide the inter-GPU communication cost. See `benchmarks/parallelism-comparison.md` for the full V0-era analysis. | Approach | Engine | Communication pattern | Result | |----------|--------|----------------------|--------| | **TP=2 (original)** | V0 | All-reduce every layer across PCIe x8 | 28 tok/s — abandoned | | **PP=2** (superseded) | V0/V1 | Single activation transfer per forward pass | 112–117 tok/s | | **TP=2 (current)** | V1 + FlashInfer | All-reduce hidden by V1 pipeline | **143–151 tok/s** | ### FlashInfer Attention Backend FlashInfer is the fastest attention kernel backend for Ampere (compute 8.6). vLLM defaults to SDP (PyTorch's scaled dot-product attention), which is 20–30% slower on this hardware. FlashInfer's efficient variable-length sequence handling also makes it a better match for chunked prefill — it's the difference between 6K and 36K tok/s prefill. ### FP8 KV Cache KV cache is the largest memory consumer after model weights. At FP8, each KV entry takes 1 byte per value instead of 2 (FP16) or 4 (FP32). This is what makes 262K context fit in 48 GB VRAM alongside weights, activations, and CUDA graphs. The accuracy trade-off is negligible for inference — FP8 KV cache preserves ~99.9% of model output quality. ### Prefix Caching Prefix caching hashes KV cache blocks and reuses them across requests with identical prefixes (e.g., system prompts) — TTFT drops to near zero for the second identical request. For agent workloads that resend the same system prompt, this is the single biggest interactive-latency win. ### 262K Context Window The model natively supports 262,144 tokens of context. Validated on 2026-08-01: a **true 256,016-token prefill completes in 73.6s** (3,480 tok/s) with GPU memory peaking at 23,143 MiB of 24,576 MiB per GPU — **1.4 GiB headroom, no OOM**. This is the synthetic worst case; real agent workloads rely on prefix caching, so repeat long-context requests are far cheaper than the first cold prefill. ### CUDA Graphs + memory profiler fix CUDA graphs are enabled (no `--enforce-eager`), capturing the GPU execution path once and replaying it for ~10% throughput gain. Requires `VLLM_MEMORY_PROFILER_ESTIMATE_CUDAGRAPHS=0` — without it, vLLM over-estimates CUDA graph memory (~2.63 GiB) during KV cache allocation and under-reserves VRAM. ### `--gpu-memory-utilization 0.80` — the OOM fix This is the single most important flag. At 0.95, the server **died (EngineDeadError) during a 262K prefill** — the log showed ~0 MiB free per card and attention intermediates spike ~476 MiB outside the KV pool. Dropping to 0.80 leaves 1.4–4.3 GiB headroom and **survives true 256K prefill**. Higher values (0.85+) OOM at full context length; 0.80 is the validated sweet spot. ### `--max-num-seqs 32` / `--max-num-batched-tokens 32768` Throughput config for concurrent serving. 32 sequence slots saturate both GPUs at ~99% util under 4-worker sustained load (416 tok/s aggregate). 32K batched tokens keeps GDN-attention intermediates bounded — the 65536-batched-token config (with 0.90+ util) is what OOM'd at 262K prefill. This is the difference between a synthetic benchmark config and a production agent-serving config. ## Why This Matters This isn't "I ran a model." This is: - **Hardware systems engineering** — building, diagnosing, and constraining consumer GPU hardware for a workload it wasn't designed for - **Deployment engineering** — selecting and configuring vLLM flags with understanding of their interactions - **Performance analysis** — benchmarking with real metrics, not logs (and correcting word-count vs token-count measurement errors when found) - **Troubleshooting** — solving NCCL deadlocks, CUDA OOM, dtype mismatches, EngineDeadError at prefill, and PCIe topology limits - **Documentation** — capturing decisions, trade-offs, and failures so the next engineer learns faster ## Security This deployment follows standard workstation hardening practices: | Practice | Status | Notes | |---|---|---| | **Firewall** | ✅ UFW active, reject incoming | All inbound ports blocked by default | | **SSH password auth** | ✅ Disabled | Key-based authentication only | | **Root SSH login** | ✅ Key-only | `PermitRootLogin without-password` | | **Brute-force protection** | ✅ fail2ban installed | 3 failed attempts → 1-hour ban | | **Auto security updates** | ✅ unattended-upgrades | Critical patches applied automatically | | **Kernel hardening** | ✅ ASLR, kptr_restrict, dmesg_restrict | Enabled at kernel level | | **vLLM endpoint** | ✅ Bound to localhost | Service not exposed to LAN | | **API keys** | ✅ Stored externally | Not committed to config/repo | | **Secrets management** | ✅ `.env` files excluded | Use environment variables or vault | **Note:** Your user is in the `docker` group (required for GPU containers). This is root-equivalent by design — treat Docker access with the same care as `sudo`. ## Getting Started ```bash # 1. Start the server (current production config) ./deployment/start-vllm.sh # 2. Test curl http://localhost:8000/v1/chat/completions \ -H 'Content-Type: application/json' \ -d '{"model": "/home/ahmed/models/qwen3.6-35b-a3b-awq", "messages": [{"role": "user", "content": "Hello"}], "max_tokens": 10}' # 3. Run benchmarks python3 benchmarks/sustained-burn-continuous.py # 10-min burn (decode) python3 benchmarks/concurrency-scaling-test.py # 1-32 concurrent sweep python3 benchmarks/prefill-scaling-test.py # 1K-256K prefill / TTFT python3 benchmarks/comprehensive-benchmark-v2.py # full suite ```