Model setup recipes
Last updated
Run a llama.cpp MTP Server on DGX Spark: Qwen3.6 Agent Requests
Run a Qwen3.6 MTP server on DGX Spark and continue agent conversations
The llama.cpp server accepts requests and conversation history from an agent app and returns answers from a local Qwen3.6-35B-A3B MTP1 model through an OpenAI-compatible API2. This guide prepares the CUDA3 build and compatible GGUF4 for DGX Spark, then checks MTP initialization and multi-turn history transfer.
A coding agent can edit a repository, run tests, read the logs, and make a follow-up fix. To preserve the work context, the server must load an MTP-compatible model and the agent must continue sending the earlier conversation and thinking history.
Here the server is bound to a local address so only apps on the same Spark use it. First check connectivity and a response with a small request, then send a follow-up in the same conversation, and finally distinguish MTP initialization from performance measurement.
Prepare Spark and the MTP model file
This setup targets DGX Spark, DGX OS, a GB10 GPU5, and 128 GB unified memory6. NVIDIA's playbook specifies about 30 GB of free memory for the example model and KV cache7, and at least about 40 GB of free disk space for the download and build artifacts. The example download is roughly 35 GB; runtime8 memory use depends on context length9 and other running apps.
The model is the UD-Q4_K_XL tag from unsloth/Qwen3.6-35B-A3B-MTP-GGUF. This compatible GGUF includes an MTP head. Do not assume that other quantized files in the same model family include MTP; verify the repository and tag, and make sure you have Hugging Face access and a network that can resume downloads.
Build llama.cpp for Spark
In a terminal, confirm that Git, CMake, and the CUDA Toolkit are available, then install the dependencies documented by NVIDIA. CMAKE_CUDA_ARCHITECTURES=121a-real targets GB10, and GGML_CUDA builds the CUDA backend. Record the llama.cpp source revision and executable version to make the build reproducible.
After building, verify the executable with llama-server --version. If CUDA is not found, check nvcc --version and PATH first. A binary built for another GPU architecture may not recognize the Spark GPU even if compilation completed.
sudo apt update
sudo apt install -y git clang cmake libcurl4-openssl-dev libssl-dev
git clone https://github.com/ggml-org/llama.cpp ~/llama.cpp
cd ~/llama.cpp
cmake -B build -DGGML_NATIVE=ON -DGGML_CUDA=ON -DGGML_CURL=ON -DGGML_RPC=ON -DCMAKE_CUDA_ARCHITECTURES=121a-real
cmake --build build --config Release --target llama-server -j
./build/bin/llama-server --versionStart the server on a local address
Because only an agent on the same Spark should connect, bind the server to 127.0.0.1. The address 0.0.0.0 allows other devices to connect. The -hf option downloads a Hugging Face model into the cache and can also load a vision projector for supported models.
The first startup includes downloading the roughly 35 GB model and loading it into CUDA. Send requests after the server log shows server is listening. CPU10 and GPU share unified memory, so do not estimate available capacity from model-file size alone; also account for context, the operating system, and other apps.
The MTP example specifies draft-mtp and a maximum of three draft tokens11, as documented for this compatible example in NVIDIA's playbook. preserve_thinking keeps the thinking block created by Qwen's template in later conversation history, allowing the agent to include the earlier reasoning record in a follow-up request.
cd ~/llama.cpp/build
./bin/llama-server -hf unsloth/Qwen3.6-35B-A3B-MTP-GGUF:UD-Q4_K_XL --host 127.0.0.1 --port 30000 --chat-template-kwargs '{"preserve_thinking":true}' --spec-type draft-mtp --spec-draft-n-max 3 --alias qwen3.6-35b-a3b --ctx-size 8192 -ngl 99
Check health and the first JSON response
After the server logs show the model loaded and speculative decoding12 context initialized, query the health endpoint from another Spark terminal. This initialization log means the MTP context is ready. Then send a short request with the model ID to the OpenAI-compatible chat/completions API and check for an assistant response under choices. This confirms connectivity, not performance.
When testing a follow-up from the agent, include the first question's conversation history and test logs in the same conversation history. preserve_thinking retains records in the model template; if the app deletes or rewrites messages, that content is not sent. Whether the API wrapper actually sends history and exposes thinking content in the raw response also depends on app settings and response format.
curl --fail-with-body http://127.0.0.1:30000/health
curl --fail-with-body http://127.0.0.1:30000/v1/chat/completions -H 'Content-Type: application/json' -d '{"model":"qwen3.6-35b-a3b","messages":[{"role":"user","content":"Review this Python function for empty-list input and suggest a minimal fix: def first_item(items): return items[0]"}],"max_tokens":128,"temperature":0}'

Validate follow-up requests and speed separately
For the second request, include the earlier messages and test logs from the same conversation, then check that the agent relates its first proposed fix to the test result. NVIDIA's playbook prefers at least 32K context for agentic/coding work and 100K or more when possible. Choose the actual context length based on repository content and memory used by concurrent apps.
Check MTP use in the initialization log and server timing or speculative statistics. To compare speed, keep the model revision, input, and generation limit the same, warm up, and measure several runs. For the baseline, remove only the MTP options and send the same question; do not mix first-download or model-load time into generation speed. NVIDIA's playbook does not publish a direct tok/s comparison for this combination, so no figure is inferred.
Troubleshoot connection, model, and memory in order
If curl cannot connect, check that the server has logged server is listening and that the request uses 127.0.0.1:30000. If the server exits during startup, inspect the error log for the Hugging Face model name, download, CUDA initialization, or OOM messages.
If the response is missing or unexpected, check that the GGUF is MTP-compatible, the executable initialized draft-mtp, and the agent uses the exact model ID and chat template. Also confirm that messages in the second request include the required earlier turns.
If memory is insufficient, close other running apps and adjust the context limit. Reducing context in a long agent session also reduces the conversation and code the model can see. If you switch to another quantized file, recheck that it includes an MTP head and is supported.
Terminology notes
MTP — A training objective or model component for predicting multiple future tokens at once. In speculative decoding, those predictions can be proposed as candidate tokens.
Back to the textAPI — A defined interface that lets other code call a program’s functions.
Back to the textCUDA — A software platform for general-purpose computing on NVIDIA GPUs.
Back to the textGGUF — A file format for model data, widely used by llama.cpp-based tools.
Back to the textGPU — A processor designed to handle many calculations in parallel. It performs model computations during AI inference.
Back to the textUnified memory — An architecture where the CPU and GPU share one physical memory pool.
Back to the textKV cache — Memory that stores attention keys and values from earlier tokens for reuse during later token generation. Its size depends on context length and batch size.
Back to the textRuntime — The software environment that provides facilities needed while a program runs. In local AI, it can also refer to a model execution engine.
Back to the textContext window — The token span of input and generated content a model can handle in one request. The supported limit and memory use depend on the model and runtime settings.
Back to the textCPU — The central processor that runs the operating system and general-purpose instructions; in AI workloads it also handles tasks such as preprocessing and data movement.
Back to the textToken — A unit into which a model divides input or output for processing.
Back to the textSpeculative decoding — A generation method in which a draft model, MTP head, or repeated-context lookup proposes output candidates for the main model to verify and accept.
Back to the text
Frequently asked questions
- What should you check first in this article?
- The llama.cpp server accepts requests and conversation history from an agent app and returns answers from a local Qwen3.6-35B-A3B MTP model through an OpenAI-compatible API. This guide prepares the CUDA build and compatible GGUF for DGX Spark, then checks MTP initialization and multi-turn history transfer.
- How much memory does it need?
- This setup targets DGX Spark, DGX OS, a GB10 GPU, and 128 GB unified memory. NVIDIA's playbook specifies about 30 GB of free memory for the example model and KV cache, and at least about 40 GB of free disk space for the download and build artifacts. The example download is roughly 35 GB; runtime memory use depends on context length and other running apps.
Read next
Model setup recipes
Qwen3.6 35B-A3B setup: NVFP4 on Mac, RTX, and DGX Spark
Response speed and acceleration
Run DFlash and DSpark with llama.cpp: A Qwen3-4B Walkthrough
Response speed and acceleration
MTP: how multi-token prediction works and when to use it
Executable programs and extensions
llama.cpp: finding which settings are slowing you down
