Skip to content
Filters & more
45 min
Advanced
deepseekds4rocmllminference
Device Family
Device
OS

Running DeepSeek V4 Flash with ds4

Deploy DeepSeek V4 Flash locally using the ds4 inference engine and manage models interactively with ds4-cockpit.

Overview

DeepSeek V4 Flash is the efficiency-focused variant of the DeepSeek V4 family — a 284 billion parameter Mixture of Experts model with 13 billion active parameters. According to DeepSeek’s technical report, it scores 79% on SWE-bench Verified and 91.6% on LiveCodeBench.

ds4 (Dwarf Star 4) is a dedicated inference engine built specifically for this model architecture. Rather than a general-purpose runtime, ds4 targets the DeepSeek V4 family directly with architecture-specific kernel optimizations for AMD ROCm™ software. It is currently one of the best-performing implementations of DeepSeek V4 Flash on Strix Halo.

This tutorial shows how to use ds4-cockpit, a terminal UI, to set up ds4, download model weights, and start serving DeepSeek V4 Flash locally on the AMD Ryzen™ AI Halo Developer Platform.

What You’ll Learn

  • How to install and launch the ds4-cockpit terminal UI
  • How to create the ds4 ROCm toolbox container
  • Downloading the recommended quantization for a single Halo node
  • Starting the ds4 inference server and exposing an OpenAI-compatible endpoint
  • Connecting a Web UI or coding agent to the local server

Setting the Memory Configuration

For the Ryzen AI Halo, the dedicated GPU memory defaults to 64GB, which is sufficient for most workloads. For larger models or longer contexts, increasing this to 96GB may help. To adjust, open AMD Software: Adrenalin Edition™ and navigate to Performance → Tuning → AMD Variable Graphics Memory. Reboot for the changes to take effect.

AMD Software Adrenalin Edition — AMD Variable Graphics Memory panel

To change the dedicated GPU memory value, open AMD Software: Adrenalin Edition™ and navigate to Performance → Tuning → AMD Variable Graphics Memory. Reboot for the changes to take effect.

AMD Software Adrenalin Edition — AMD Variable Graphics Memory panel

On Linux, to run larger models, increase the shared memory pool available to the GPU. This might involve setting the BIOS dedicated GPU memory to the minimum, so that the shared memory pool can be maximized.

For the AMD Ryzen™ AI Halo, the default is 96GB shared. To modify this, open the AMD Ryzen™ AI Developer Center and go to the Settings tab. Under Graphics Performance Settings, increase the Shared Video Memory slider, then click Apply Changes and reboot for the changes to take effect.

AMD Ryzen AI Developer Center — Graphics Performance Settings with Shared Video Memory slider

Increase the shared memory pool by changing the kernel’s Translation Table Manager (TTM) page setting. AMD recommends setting the minimum dedicated VRAM in the BIOS (0.5 GB) so the maximum amount is available as shared memory.

  1. Install the pipx utility and add the path for pipx-installed wheels to the system search path:
Terminal window
sudo apt install pipx
pipx ensurepath
  1. Install the amd-debug-tools wheel from PyPI:
Terminal window
pipx install amd-debug-tools
  1. Query the current shared memory settings:
Terminal window
amd-ttm
  1. Increase the shared memory allocation (units in GB):
Terminal window
amd-ttm --set <NUM>
  1. Reboot for the changes to take effect.

Installing Software Prerequisites

System requirements for this configuration (single-node IQ2_XXS at 126k context):

  • A Strix Halo system with at least 128 GB of unified memory.
  • BIOS dedicated VRAM (UMA frame buffer) set to the minimum, so the shared memory pool can be as large as possible.
  • The GPU shared-memory pool set to at least 110 GB: run amd-ttm --set 110 (see the memory configuration step above) and reboot. Lower values can fail with out-of-memory when the model loads at a 126k context. If your system has less memory available, lower the Context value in Server Mode instead.

ds4-cockpit uses container toolboxes to run the ds4 engine. Install podman, distrobox, and pipx:

Terminal window
sudo apt update
sudo apt install -y podman distrobox pipx

Available Quantizations

The ds4 author provides several quantized versions of DeepSeek V4 Flash in GGUF format. All models below use importance matrix (imatrix) calibration, which preserves higher precision for the parts of the model that matter most for coding and reasoning tasks.

QuantizationSizeDescription
IQ2_XXS imatrix~80.8 GBRecommended for a single 128 GB node
Hybrid Q2/Q4 imatrix~97 GBKeeps layers 37–42 at Q4 precision for better accuracy. Fits in 128 GB but leaves less room for context
Q4 imatrix~153 GBHigher quality. Requires two Halo nodes via multi-node clustering
MTP Speculative Decoding~3.6 GBOptional add-on for speculative decoding to improve generation speed

The IQ2_XXS imatrix model is a good starting point. It fits comfortably on a single node and leaves enough memory for a reasonable context window.

Installing ds4-cockpit

ds4-cockpit is a light terminal UI to make getting up and running with ds4 on Strix Halo easy. It handles creating toolbox containers, downloading model weights, and starting servers. Install it with pipx:

Terminal window
pipx install "git+https://github.com/kyuz0/strix-halo-ds4-toolbox.git#subdirectory=ds4-strix-halo-cockpit"

Launch the cockpit:

Terminal window
ds4-cockpit

Creating the Toolbox

In the Interactive Toolboxes tab, select the latest available/stable toolbox (e.g. ds4-rocm-7.2.4) and click Create/Update. This pulls the container image and creates the toolbox environment.

Selecting the ds4 toolbox in ds4-cockpit

Downloading the Model

Go to the Model Manager tab. Select IQ2_XXS imatrix (~80.8 GB) from the dropdown and click Download. The model files will be saved to ~/ds4 by default (you can change the storage path).

Selecting and downloading the IQ2_XXS model

Starting the Server

Go to the Server Mode tab. Select the downloaded model and the toolbox, then configure the context size, host, and port. When ready, click Start ds4-server.

KV Disk Cache (optional). Turning on KV Disk Cache offloads the KV cache to disk (at Host Cache Dir, default ~/.cache/ds4-kv) so repeated system prompts are restored from SSD instead of being recomputed. It’s a performance optimization for coding-agent workflows with long, repeated prompts, and is not required to run the server.

Configuring and starting the ds4 server

The server will start and listen on port 8000, exposing an OpenAI-compatible API endpoint at http://localhost:8000/v1.

Quick test:

Terminal window
curl http://127.0.0.1:8000/v1/chat/completions \
-H 'Content-Type: application/json' \
-d '{
"model": "deepseek-v4-flash",
"messages": [{"role": "user", "content": "Hello!"}],
"stream": false
}'

Connecting a Web UI

You can connect any chat interface that supports the OpenAI API format. For example, to use HuggingFace ChatUI:

Terminal window
docker run -p 3000:3000 \
--add-host=host.docker.internal:host-gateway \
-e OPENAI_BASE_URL=http://host.docker.internal:8000/v1 \
-e OPENAI_API_KEY=dummy \
-v chat-ui-data:/data \
ghcr.io/huggingface/chat-ui-db

Open http://localhost:3000 in your browser to start chatting.

Connecting a Coding Agent

The ds4 server exposes both OpenAI and Anthropic-compatible endpoints, so most coding agents can connect to it directly. For example, to add it to the pi coding agent, add the following block to ~/.pi/agent/models.json:

"ds4": {
"name": "ds4.c local",
"baseUrl": "http://localhost:8000/v1",
"api": "openai-completions",
"apiKey": "dsv4-local",
"compat": {
"supportsStore": false,
"supportsDeveloperRole": false,
"supportsReasoningEffort": true,
"supportsUsageInStreaming": true,
"maxTokensField": "max_tokens",
"supportsStrictMode": false,
"thinkingFormat": "deepseek",
"requiresReasoningContentOnAssistantMessages": true
},
"models": [
{
"id": "deepseek-v4-flash",
"name": "DeepSeek V4 Flash (ds4.c local)",
"reasoning": true,
"thinkingLevelMap": {
"off": null,
"minimal": "low",
"low": "low",
"medium": "medium",
"high": "high",
"xhigh": "xhigh"
},
"input": ["text"],
"contextWindow": 131072,
"maxTokens": 65536,
"cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 }
}
]
}

Next Steps

  • Multi-node clustering: If you have two Halo devices, ds4 supports distributing the Q4 model (~153 GB) across both machines via pipeline parallelism. See the ds4-toolbox documentation for setup instructions.
  • Speculative decoding (MTP): Download the MTP weights (~3.6 GB) and pass --mtp to the server for faster generation speed.
  • KV cache disk offloading: For coding agent workflows, enable --kv-disk-dir so that repeated system prompts are restored from SSD instead of being recomputed each time.

For more information, see the ds4 repository and the ds4-cockpit toolbox.

Need help with this playbook?

Run into an issue or have a question? Open a GitHub issue and our team will take a look.