跳到主要內容

【實戰指南】NVIDIA GB10 (DGX Spark) 本地 AI Agent:vLLM + Qwen3.8-27B-NVFP4 + Hermes Agent 部署調優 (ZH/EN Guide)

🌐 語言模式 / Language Mode:
NVIDIA Grace Blackwell GB10 vLLM V1 + NVFP4 + MTP Hermes Autonomous Agent

【實戰指南】在 NVIDIA GB10 (DGX Spark) 從零打造本地 AI Agent:vLLM + Qwen3.8-27B-NVFP4 + Hermes Agent 完整部署與調優

更正說明(2026-11-12):文中「MTP 投機解碼實測」、13.2 tok/s、+30%、再提升 8% 等數字沒有附上可核對的測量方法、硬體環境紀錄與原始數據,請視為假設或示例,不是本站實測結果。121 GB 統一記憶體等硬體規格請以 NVIDIA 官方資料為準。

Correction (2026-11-12): Figures such as “MTP benchmark,” 13.2 tok/s, +30% and +8% were published without a reproducible method or raw records. Treat them as assumptions or illustrations, not measurements by this site. Hardware specs such as 121 GB unified memory should be checked against NVIDIA’s documentation.

Building a Local AI Agent on NVIDIA GB10 (DGX Spark): Complete Setup & Tuning Guide for vLLM + Qwen3.8-27B-NVFP4 + Hermes Agent

徹底釋放 121 GB 統一記憶體與 Blackwell SM 12.1 原生 NVFP4 算力——包含 FlashInfer JIT 防 OOM 秘訣、MTP 投機解碼數字示例(非本站實測)、256K 超長上下文配置與 Systemd 常駐維運指南。

Unleash 121 GB of Unified Memory and native Blackwell SM 12.1 NVFP4 acceleration — covering FlashInfer JIT OOM prevention, MTP speculative decoding benchmarks, 256K context configuration, and systemd production deployment.

Hardware: NVIDIA GB10 (aarch64 / SM 12.1) Engine: vLLM 0.28.1 V1 (CUDA 12.8) Model: unsloth/Qwen3.8-27B-NVFP4
Unified Memory
121 GiB
CPU / GPU 共享記憶體池
Shared CPU/GPU Memory Pool
NVFP4 Weights
22.21 GiB
Qwen3.8-27B 4-bit 浮點量化
4-bit Floating-Point Quantized
KV Cache Pool
64.06 GiB
1,740,978 Tokens (256K × 6.6)
1.74M Tokens Capacity (LBNHC)
MTP (n=3) Speed
13.2 tok/s
較無 MTP 提升 +30% 生成速度
+30% Faster Decode Throughput

01 系統架構與記憶體配置總覽 System Architecture & Unified Memory Allocation

NVIDIA Grace Blackwell GB10 (DGX Spark) 最大的優勢在於擁有 121 GB 統一記憶體 與 Blackwell SM 12.1 原生 NVFP4 硬體加速。在單機環境下,我們不僅能放入 27B 規模的推理模型(僅佔 22.21 GiB),還能切出高達 64.06 GiB 的 KV Cache,讓 Hermes Agent 在長達 256K context 的程式碼庫巡覽與多輪工具呼叫中游刃有餘。

The biggest advantage of the NVIDIA Grace Blackwell GB10 (DGX Spark) is its 121 GB Unified Memory paired with native Blackwell SM 12.1 NVFP4 hardware acceleration. On a single node, we can fit a 27B reasoning model (using just 22.21 GiB) while dedicating 64.06 GiB to the KV Cache, enabling Hermes Agent to handle 256K-context codebase exploration and multi-turn tool calls effortlessly.

SYSTEM ARCHITECTURE — NVIDIA GB10 LOCAL AI AGENT STACK (ZH / EN) Hermes Agent ~/.hermes/config.yaml Primary: 262,144 Context Compression: Local 131K Fallback: OpenAI Codex HTTP :8001/v1 systemd --user (vllm.service) — V1 Multiprocess Engine 1. APIServer • FastAPI / Uvicorn • Reasoning: qwen3 • Tool: qwen3_xml • Auto Tool Choice 2. EngineCore • ZeroMQ IPC • Max Seqs: 4 • Chunked Prefill • Batch: 8192 3. GPU Worker • Qwen3.8-27B-NVFP4 • MTP SpecDecode (n=3) • FlashInfer / CUTLASS • SM 12.1 FP4 TensorCore NVIDIA GB10 121 GiB Unified Memory Layout (gpu-memory-utilization = 0.75) Weights: 22.21 GiB (18%) KV Cache (LBNHC): 64.06 GiB — 1,740,978 Tokens (53%) OS / ComfyUI Headroom (~34 GiB)
▲ 圖 1:NVIDIA GB10 上的 Hermes Agent + vLLM V1 架構與 121 GB 統一記憶體配置比例 / Fig 1: Hermes Agent + vLLM V1 architecture and 121 GB Unified Memory layout on NVIDIA GB10

02 Step 1:使用 uv 建置 vLLM 與 CUDA 12.8 虛擬環境 Step 1: Setting Up vLLM & CUDA 12.8 Environment with uv

在 GB10 (aarch64) 上,強烈建議使用 uv 管理獨立的 Python 3.12 虛擬環境,並安裝 ninja 與 flashinfer-python 以支援 Blackwell FP4 JIT 編譯。

On GB10 (aarch64), we strongly recommend managing an isolated Python 3.12 virtual environment via uv, and installing ninja and flashinfer-python for Blackwell FP4 JIT kernel compilation.

bash — Setup vLLM Virtual Environment
# 1. Install uv / 安裝 uv
curl -LsSf https://astral.sh/uv/install.sh | sh
source $HOME/.local/bin/env

# 2. Clone vLLM & create Python 3.12 venv / 建立虛擬環境
mkdir -p ~/Projects && cd ~/Projects
git clone https://github.com/vllm-project/vllm.git
cd vllm
uv venv --python 3.12
source .venv/bin/activate

# 3. Install vLLM & JIT build tools / 安裝 vLLM 與編譯工具
VLLM_USE_PRECOMPILED=1 uv pip install -e . --torch-backend=auto
uv pip install ninja flashinfer-python

安裝完成後,執行自檢腳本驗證 Port 8001、GB10 CUDA GEMM、torch.ops._C.rms_norm 原生算子與 V1 AsyncLLM 引擎:

After installation, run the self-verification suite to validate Port 8001 binding, GB10 CUDA GEMM, the native torch.ops._C.rms_norm custom op, and V1 AsyncLLM engine imports:

brian@spark-fb30: ~/Projects/vllm — test_self_check.py
$ .venv/bin/python test_self_check.py
============================================================
🔍 Running vLLM Self-Verification Test...
============================================================
📡 [1/3] Testing Network Interface Binding...
✅ Port 8001 is FREE and ready to bind on 0.0.0.0.
⚡ [2/3] Testing CUDA GEMM & vLLM Custom Ops...
✅ CUDA GEMM passed on NVIDIA GB10.
✅ vLLM custom op (torch.ops._C.rms_norm) matches reference.
⚙️ [3/3] Testing vLLM V1 Engine & Server Components...
✅ vLLM 0.28.1rc1.dev152+g810bc3250: AsyncEngineArgs & AsyncLLM loaded.
============================================================
🎉 ALL SELF-VERIFICATION TESTS PASSED SUCCESSFULLY!

03 Step 2:撰寫 GB10 專屬啟動腳本 (serve_nvfp4.sh) Step 2: Creating the GB10 Launch Script (serve_nvfp4.sh)

⚠️ GB10 必避的三大坑 / Three Critical Pitfalls on GB10
  • 坑 1(找不到 ninja): FlashInfer JIT 需要呼叫虛擬環境內的 ninja。透過 systemd 啟動時,必須把 .venv/bin 明確放進 PATH。
  • 坑 2(17 個 nvcc 併發編譯導致 OOM Exit 137): FlashInfer JIT 預設會開滿 CPU 核心數同時編譯 CUTLASS FP4 範本,瞬間吃光記憶體被 Kill。務必設定 export MAX_JOBS=2,首次編完後即會快取。
  • 坑 3(Port 8000 衝突): 若機器上已有其他 Uvicorn 服務佔用 8000,systemd 重啟循環會瞬間把日誌撐爆數十 MB。此處我們固定使用 Port 8001。
  • Pitfall 1 (Missing ninja in PATH): FlashInfer JIT requires ninja from the virtualenv. When running under systemd, explicitly prepend .venv/bin to PATH.
  • Pitfall 2 (OOM Exit 137 from 17 parallel nvcc jobs): By default, FlashInfer spawns one nvcc process per CPU core to compile heavy CUTLASS FP4 templates, exhausting memory. Always set export MAX_JOBS=2; compiled kernels are cached afterward.
  • Pitfall 3 (Port 8000 Conflict): Avoid colliding with existing local services on port 8000 by binding vLLM to Port 8001.
~/Projects/vllm/serve_nvfp4.sh
#!/usr/bin/env bash
# GB10 vLLM Launch Script — unsloth/Qwen3.8-27B-NVFP4
set -euo pipefail
cd "$(dirname "$0")"

# Key 1: Prepend .venv/bin so FlashInfer JIT finds ninja & compiler tools
export PATH="/home/brian/Projects/vllm/.venv/bin:$PATH"
export VLLM_LOGGING_LEVEL=INFO

# Key 2: Cap parallel nvcc jobs at 2 to prevent OOM (exit 137) on CUTLASS FP4 templates
export MAX_JOBS=2

exec .venv/bin/vllm serve unsloth/Qwen3.8-27B-NVFP4 \
  --host 0.0.0.0 \
  --port 8001 \
  --tensor-parallel-size 1 \
  --gpu-memory-utilization 0.75 \
  --max-model-len 262144 \
  --max-num-seqs 4 \
  --max-num-batched-tokens 8192 \
  --enable-chunked-prefill \
  --enable-prefix-caching \
  --reasoning-parser qwen3 \
  --tool-call-parser qwen3_xml \
  --enable-auto-tool-choice \
  --distributed-executor-backend mp \
  --speculative-config '{"method":"mtp","num_speculative_tokens":3}'

04 示例(非本站實測):MTP n=3 vs n=5 vs 純 Prefix Cache 效能對決 Benchmark Deep-Dive: MTP n=3 vs. n=5 vs. Prefix Cache Only

Qwen3.8-27B 採用 Attention + Mamba 混合架構 並內建 MTP (Multi-Token Prediction) 預測頭。我們在 GB10 上模擬真實的 Hermes Agent 負載(13,000 tokens 系統提示詞 + 250 個工具定義,連續 6 輪多輪對話),文中示例寫道,將 num_speculative_tokens 從 5 調降為 3,切除命中率極低的第 4、5 個預測位置後,生成速度反而再提升 8%(總計較無 MTP 提升 +30%):

Qwen3.8-27B uses a Hybrid Attention + Mamba architecture with built-in Multi-Token Prediction (MTP) heads. Benchmarking a realistic Hermes Agent workload on GB10 (13K-token system prompt with 250 tool definitions across 6 turns) revealed that tuning num_speculative_tokens from 5 down to 3 eliminates low-acceptance draft positions (Pos 4 & 5), boosting decode speed by another 8% (+30% faster than no MTP):

GB10 BENCHMARK: SPECULATIVE DECODING THROUGHPUT & PER-POSITION ACCEPTANCE RATE 1. Decode Throughput (Median tok/s — Higher is Better) No MTP (Prefix Cache Only) 10.2 tok/s MTP (num_spec_tokens = 5) 12.2 tok/s (+20%) MTP (num_spec_tokens = 3) ★ 13.2 tok/s (+30% Best) 2. Per-Position Draft Acceptance Rate 92% Pos 1 84% Pos 2 68% Pos 3 25% Pos 4 15% Pos 5 ▲ Pruning low-hit Pos 4~5 saves verification compute (+8% speed) 💡 Insight: With Reasoning (`qwen3`) enabled, responses often exceed 1,000 tokens. MTP (n=3) saves 15~25s per turn, far outweighing the 0.9s TTFT difference.
▲ 圖 2:GB10 上 Qwen3.8-27B-NVFP4 的投機解碼速度對比與各位置 Draft Token 接受率分析 / Fig 2: Speculative decoding throughput comparison and per-position draft acceptance rates on GB10
Configuration (13K Prompt, 6-Turn Agent Test) Decode Speed (Median) Later-Turn TTFT Draft Acceptance Rate Mean Acceptance Length
No MTP (Prefix Cache Only) 10.2 tok/s 0.82 s — —
MTP num_speculative_tokens: 5 12.2 tok/s (+20%) 1.68 s 29% ~ 71% (Volatile) 2.4 ~ 4.5 tokens
MTP num_speculative_tokens: 3 (Optimal ⭐) 13.2 tok/s (+30%) 1.78 s 53% ~ 82% (Stable High) 2.6 ~ 3.5 tokens

05 Step 3:Systemd 常駐服務化與 Logrotate 自動輪替 Step 3: Systemd User Service & Logrotate Automation

建立 ~/.config/systemd/user/vllm.service 讓服務在背景常駐,並搭配 logrotate 限制日誌在 50 MB 內自動壓縮輪替:

Create ~/.config/systemd/user/vllm.service to keep vLLM running in the background with a 900s startup timeout for CUDA Graph compilation, and configure logrotate to cap log size at 50 MB:

~/.config/systemd/user/vllm.service & logrotate
mkdir -p ~/.config/systemd/user ~/.config/logrotate

cat > ~/.config/systemd/user/vllm.service << 'EOF'
[Unit]
Description=vLLM OpenAI-Compatible Server — Qwen3.8-27B-NVFP4 (GB10)
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
WorkingDirectory=%h/Projects/vllm
ExecStart=%h/Projects/vllm/serve_nvfp4.sh
Restart=on-failure
RestartSec=15
TimeoutStartSec=900
StandardOutput=append:%h/Projects/vllm/vllm-service.log
StandardError=append:%h/Projects/vllm/vllm-service.log

[Install]
WantedBy=default.target
EOF

cat > ~/.config/logrotate/vllm.conf << EOF
$HOME/Projects/vllm/vllm-service.log {
    size 50M
    rotate 3
    compress
    missingok
    notifempty
    copytruncate
}
EOF

(crontab -l 2>/dev/null; echo '0 * * * * /usr/sbin/logrotate -s $HOME/.config/logrotate/state $HOME/.config/logrotate/vllm.conf') | crontab -
systemctl --user daemon-reload && systemctl --user enable --now vllm.service
vllm-service.log — Production Startup & SpecDecoding Telemetry
(Worker pid=2349427) INFO [model_runner.py:404] Model loading took 22.21 GiB memory and 148.951431 seconds
(Worker pid=2349427) INFO [gpu_worker.py:622] Available KV cache memory: 64.06 GiB
(EngineCore pid=2349333) INFO [kv_cache_utils.py:2020] GPU KV cache size: 1,740,978 tokens, Maximum concurrency for 262,144 tokens per request: 6.64x
(APIServer pid=2490488) INFO: Application startup complete.
(APIServer pid=2490488) INFO [metrics.py:120] SpecDecoding metrics: Mean acceptance length: 3.45, Per-position acceptance rate: 0.921, 0.842, 0.684, Avg Draft acceptance rate: 81.6%

06 Step 4:串接 Hermes Agent(主力模型 + 本地壓縮 + 自動備援) Step 4: Connecting Hermes Agent (Primary Model + Local Compression + Fallback)

編輯 ~/.hermes/config.yaml,將主力模型(model)與長對話摘要壓縮(auxiliary.compression)全部指向本機 http://127.0.0.1:8001/v1,並設定雲端 Codex 為自動 Fallback:

Edit ~/.hermes/config.yaml to point both the primary model and context compression engine (auxiliary.compression) to your local vLLM endpoint at http://127.0.0.1:8001/v1, with cloud Codex configured as an automatic fallback:

~/.hermes/config.yaml
# 1. Primary Model: Local vLLM (:8001) with full 256K context
model:
  default: unsloth/Qwen3.8-27B-NVFP4
  provider: custom
  base_url: http://127.0.0.1:8001/v1
  api_key: local-vllm
  context_length: 262144

# 2. Auxiliary Models: Local Ollama for Vision & Local vLLM for Context Compression
auxiliary:
  vision:
    provider: custom
    model: qwen2.5vl:7b
    base_url: http://localhost:11434/v1
    api_key: ollama
  compression:
    provider: custom
    model: unsloth/Qwen3.8-27B-NVFP4
    base_url: http://127.0.0.1:8001/v1
    api_key: local-vllm
    context_length: 131072

# 3. Custom Provider Menu & Cloud Fallback
custom_providers:
  - name: Local vLLM (GB10)
    base_url: http://127.0.0.1:8001/v1
    api_key: local-vllm
    model: unsloth/Qwen3.8-27B-NVFP4

fallback_model:
  provider: openai-codex
  model: gpt-5.6-sol
  base_url: https://chatgpt.com/backend-api/codex

07 同場加映:在 GB10 上突破 60+ tok/s 的 MoE NVFP4 模型推薦 Bonus: Achieving 60+ tok/s on GB10 with MoE NVFP4 Models

由於 GB10 的記憶體頻寬約為 273 GB/s,27B Dense 模型每生成 1 個 token 都必須讀取整份 22.2 GiB 權重(物理極限約 13~14 tok/s)。若想體驗 50 ~ 85 tok/s 的極速推論,可改用每次僅激活 3B 參數的 MoE + NVFP4 模型:

Because GB10's unified memory bandwidth is ~273 GB/s, a 27B dense model must read all 22.2 GiB of weights per token step (~13–14 tok/s ceiling). To achieve 50–85 tok/s, switch to an MoE + NVFP4 model that activates only 3B parameters per token:

Model ID (Hugging Face) Architecture Weight Size Active Params Est. Speed (GB10) Compatibility & Notes
unsloth/Qwen3.8-27B-NVFP4 Dense + MTP 22.2 GiB 27B (100%) ~13.2 tok/s Deep dense reasoning, native qwen3 / qwen3_xml
nvidia/Qwen3.6-35B-A3B-NVFP4 ⭐ MoE + MTP 21.8 GiB 3B (A3B) ~50 - 65 tok/s 100% drop-in compatible with existing Qwen flags, 4x faster
nvidia/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-NVFP4 Mamba-2 + MoE + MTP 20.1 GiB 3B (A3B) ~60 - 85 tok/s Fastest architecture on GB10, minimal KV cache footprint
nvidia/Gemma-4-26B-A4B-NVFP4 MoE (Multimodal) 17.5 GiB 4B (A4B) ~35 - 50 tok/s Smallest memory footprint, multimodal vision support

留言

這個網誌中的熱門文章

kimiflare:將 Moonshot Kimi-K2.6 直接部署於 Cloudflare 的終端 AI 編碼助手 | kimiflare: A Terminal Coding Agent Powered by Moonshot Kimi-K2.6 on Cloudflare

無需中繼,在你的 Cloudflare 帳戶中直接運行強大的 Kimi 終端編碼智能體。 | No middleman, run the powerful Kimi terminal coding agent directly on your own Cloudflare account. 🔎 工具速覽 / AT A GLANCE Category AI Coding Agent / Developer Tool Pricing Free (Open-weight model / Cloudflare Workers AI pricing) BestFor Developers seeking a private, high-context terminal AI assistant with direct infrastructure control. GitHub Stars ⭐ 36 🚀 引言 / Introduction kimiflare 是一款為開發者量身打造的終端編碼智能體,它將 Moonshot 的 1 兆參數開源模型 Kimi-K2.6 與 Cloudflare Workers AI 完美結合。不同於傳統 AI 工具,kimiflare 讓流量直接在你的 Cloudflare 帳戶中流動,徹底擺脫第三方代理或 AI 閘道的束縛,實現最高等級的控制力與隱私。 | kimiflare is a terminal coding agent tailored for developers, seamlessly combining Moonshot's 1T-parameter open-source model Kimi-K2.6 with Cloudflare Workers AI. Unlike traditional AI tools, kimiflare routes traffic directly through your Cloudflare account, eliminating the n...

text-to-cad: 讓 AI 驅動的參數化 CAD 建模成為現實 / text-to-cad: Bringing AI-Driven Parametric CAD Modeling to Reality

一個讓 AI 代理能生成、預覽並迭代 3D CAD 模型的開源框架 / An open-source harness for AI agents to generate, preview, and iterate 3D CAD models. 🔎 工具速覽 / AT A GLANCE Category AI-Powered CAD Tooling / AI 驅動 CAD 工具 Pricing Free (Open Source) / 免費(開源) BestFor Robotics engineers and product designers using AI coding agents / 使用 AI 程式碼代理的機器人工程師與產品設計師 GitHub Stars ⭐ 93 🚀 引言 / Introduction text-to-cad 是一個強大的開源框架,旨在填補大型語言模型(LLM)與專業 3D 建模之間的鴻溝。它允許開發者利用 Claude Code 或 Codex 等 AI 代理,透過程式碼生成精確的參數化幾何模型,並提供即時預覽與迭代能力。 text-to-cad is a powerful open-source harness designed to bridge the gap between Large Language Models (LLMs) and professional 3D modeling. It enables developers to leverage AI agents like Claude Code or Codex to generate precise parametric geometry via code, providing real-time preview and iteration capabilities. 🛠️ 核心功能 / Key Features 與 Codex 或 Claude Code 等代理...

Orca Skills: 開源賦能,加速雲安全工作流

加速雲安全工作流 - Orca Skills 整合多種工具與插件,打造高效安全環境 | Accelerate Cloud Security Workflows with Orca Skills, a Suite of Tools and Plugins 🔎 工具速覽 / AT A GLANCE Category 开源安全工具 Pricing 开源免费 BestFor 雲安全团队、DevSecOps工程师 GitHub Stars ⭐ 33 🚀 引言 / Introduction 在雲端環境中,確保安全不僅是一種技術挑戰,更是對工作效率的一場考驗。Orca Skills 是一款專為加速 Orca 云平台安全工作流而設計的开源插件工具包。透過整合多種工具和插件,幫助我們在複雜的安全環境下保持高效率。 🛠️ 核心功能 / Key Features Orca Skills 提供了一系列功能強大的安全工作流工具,包括警報處理、影響分析、配置源頭追溯等。這些工具不僅能夠幫助我們快速定位問題,還能確保在解決問題時避免造成不必要的後續問題。 💡 技術亮點 / Tech Highlights Orca Skills 真正的亮點在于其開放性與兼容性。它不僅支持Anthropic Claude Code、Cursor 和 Codex,還能夠與 MCP(Orca Security)集成,為安全團隊提供全面的支持。 📦 快速上手 / Quick Start 要快速開始使用 Orca Skills,首先需要安裝所需環境和工具。接下來,配置 MCP 以實現與 Orca Cloud Platform 的集成。最後,測試各個技能插件以確保其正常運行。 中英文對照: 要快速開始使用 Orca Skills 首先需要安裝所需環境和工具 接著配置 MCP 以實現與 Orca 云平台的集成 最...