Model setup recipes

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.

Requirements and key details
  • Build llama.cpp for Spark with the CMAKE_CUDA_ARCHITECTURES=121a-real setting documented by NVIDIA.
  • Use a Q4_K_XL GGUF that includes an MTP head together with the draft-mtp setting.
  • preserve_thinking keeps Qwen's thinking record in conversation history for follow-up requests.

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.

Install dependencies and build the server for Spark
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 --version
Build with the CUDA settings in NVIDIA's playbook, then verify that the server version prints on Spark.

Start 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.

Run the Spark server with MTP and preserved thinking history
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
Select the compatible Q4_K_XL file and wait for the server is listening log.
A small AI computer beside a code-editing screen on a desk
Bind the server to a local address so only an agent on the same Spark can connect.

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.

Check server health and submit the first chat request
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}'
After health succeeds, use the exact model ID and check for an assistant message under choices in the response JSON.
Small draft-candidate blocks and larger verification blocks beside an AI computer
When the main model verifies MTP's candidates, it can accept multiple tokens at once.
A local AI workspace connecting code and conversation screens
Include the earlier conversation and test results again in a follow-up request.

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

  1. 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 text
  2. API — A defined interface that lets other code call a program’s functions.

    Back to the text
  3. CUDA — A software platform for general-purpose computing on NVIDIA GPUs.

    Back to the text
  4. GGUF — A file format for model data, widely used by llama.cpp-based tools.

    Back to the text
  5. GPU — A processor designed to handle many calculations in parallel. It performs model computations during AI inference.

    Back to the text
  6. Unified memory — An architecture where the CPU and GPU share one physical memory pool.

    Back to the text
  7. KV 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 text
  8. Runtime — 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 text
  9. Context 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 text
  10. CPU — 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 text
  11. Token — A unit into which a model divides input or output for processing.

    Back to the text
  12. Speculative 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.