Skip to content

Instantly share code, notes, and snippets.

@Spencer-Easton
Last active August 31, 2026 21:57
Show Gist options
  • Select an option

  • Save Spencer-Easton/2aaf17225a96d93e71f693bbbf5a118a to your computer and use it in GitHub Desktop.

Select an option

Save Spencer-Easton/2aaf17225a96d93e71f693bbbf5a118a to your computer and use it in GitHub Desktop.
Public SparkRun recipe for GLM-5.3-Flash NVFP4 + DFlash2 on two DGX Sparks, with image support and OpenCode setup

GLM-5.3-Flash NVFP4 + DFlash2 TP2 on two DGX Sparks

This is a reusable SparkRun v4 adaptation of Tony D's two-node DGX Spark deployment for GLM-5.3-Flash NVFP4 with DFlash2 speculative decoding.

Upstream credit: The container image, SM121 patches, launch settings, debugging work, and performance findings come from Tony D (tonyd2wild) and contributors to GLM-5.3-Flash-NVFP4-DFlash2-2x-DGX-Spark. This Gist only translates that work into a portable SparkRun recipe. It is not an official upstream artifact.

SparkRun supplies each node's rank, rendezvous address and port, --nnodes, and the worker's --headless flag through its native vllm-distributed runtime. It detects cluster communication interfaces, so this recipe contains no hostnames, IP addresses, cluster names, or NIC names.

Requirements

  • Exactly two NVIDIA DGX Spark nodes in a saved SparkRun cluster
  • SparkRun 0.3.6 or newer
  • SSH connectivity from the SparkRun control machine to both nodes
  • Enough free local storage for the model on both nodes

Stop other GPU workloads before launching. Keep swap enabled as a safety valve, set vm.swappiness=0, and drop filesystem caches on both nodes when your sudo configuration permits it.

1. Stage the model on both nodes

Run these commands on each DGX Spark:

hf download RedHatAI/GLM-5.3-Flash-NVFP4 \
  --local-dir /var/tmp/glm-5.3-flash-nvfp4

hf download incoai/GLM-5.3-Flash-DFlash2 \
  --local-dir /var/tmp/glm-5.3-flash-nvfp4/dflash2-draft

curl -fL \
  https://raw.githubusercontent.com/tonyd2wild/GLM-5.3-Flash-NVFP4-DFlash2-2x-DGX-Spark/53912b4494bb04c71f381e1b0680ae4fa7747ce9/chat_template_mm.jinja \
  -o /var/tmp/glm-5.3-flash-nvfp4/chat_template_mm.jinja

The model directory must have the same absolute path on both nodes. SparkRun identity-mounts that path into each container instead of redistributing the large checkpoint at launch.

2. Stage the SM121 patch on the SparkRun control machine

Run this on the same machine from which you invoke sparkrun run:

mkdir -p /var/tmp/sparkrun-patches/glm53-sm121

curl -fL \
  https://raw.githubusercontent.com/tonyd2wild/GLM-5.3-Flash-NVFP4-DFlash2-2x-DGX-Spark/a5c4b197b2bd57d7be734b0ea17183e36fea962b/docker/sparse_attn_indexer_kpool_sm121.py \
  -o /var/tmp/sparkrun-patches/glm53-sm121/sparse_attn_indexer_kpool_sm121.py

echo "8a3ecfb0bab2441dd7417ed00a10d142191496149f88e5fe79fcfaea4b160980  /var/tmp/sparkrun-patches/glm53-sm121/sparse_attn_indexer_kpool_sm121.py" \
  | sha256sum -c -

The recipe copies the directory, not the individual file, because SparkRun 0.3.6 copy hooks use directory semantics. With no source_host, the source is the control machine running SparkRun. The checksum is verified again inside every container before installation.

If launch fails with rsync ... change_dir ... No such file or directory, the patch was staged on a different machine or at a different path. Stage the directory above on the machine that actually runs sparkrun run.

3. Create or select a two-node cluster

Skip this if you already have a suitable saved cluster:

sparkrun cluster create glm-tp2 \
  --hosts HEAD_HOST,WORKER_HOST \
  -d "2x DGX Spark GLM-5.3 TP2"

Replace the placeholders with SSH-reachable names or addresses. Do not copy upstream hard-coded NIC or subnet values unless they match your fabric.

4. Validate and run

sparkrun recipe validate glm-5.3-flash-nvfp4-dflash2-tp2.yaml
sparkrun run glm-5.3-flash-nvfp4-dflash2-tp2.yaml \
  --cluster YOUR_CLUSTER

Startup commonly takes 10–15 minutes because checkpoint loading dominates. Use the engine health endpoint for readiness:

curl -f http://HEAD_HOST:8000/health

Do not use /v1/models as the readiness probe: it may return configuration metadata before the engine core is healthy.

To follow both tensor-parallel ranks, get the job/cluster ID from sparkrun cluster status, then run:

sparkrun logs JOB_ID --cluster YOUR_CLUSTER --lines 200 --follow --all-sources

Press Ctrl-C to detach from logs without stopping the workload.

Why the multimodal limit is explicit

The default vLLM multimodal profile reserved one maximum-size video with a 32,242-token encoder budget on the tested build. That consumed enough activation memory to leave only 1.05 GiB for KV cache, below the 2.65 GiB required to start with a 262,144-token context.

This recipe uses:

limit_mm_per_prompt: '{"video":0}'

This keeps image input, disables video input.

Measured on one two-node DGX Spark cluster with this recipe:

  • Encoder cache budget: 8,192 tokens
  • Peak activation memory: 4.5 GiB per rank
  • Available KV cache: 3.37 GiB per rank
  • KV capacity: 330,861 tokens
  • Maximum 262,144-token request concurrency: 1.26x

Treat the memory figures as observations, not guarantees; background memory, driver versions, and container builds can move them between boots.

The recipe deliberately omits --kv-cache-memory. A fixed KV allocation can bypass activation-headroom accounting and boot successfully while remaining unsafe under a long prompt. Let vLLM profile the available memory.

OpenCode configuration

Add the model under an OpenAI-compatible provider in ~/.config/opencode/opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "spark-local": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "DGX Spark (local cluster)",
      "options": {
        "baseURL": "http://HEAD_HOST:8000/v1",
        "apiKey": "local"
      },
      "models": {
        "glm-5.3-flash": {
          "name": "GLM-5.3 Flash NVFP4 + DFlash2 (2-node)",
          "reasoning": true,
          "attachment": true,
          "modalities": {
            "input": ["text", "image"],
            "output": ["text"]
          },
          "limit": {
            "context": 262144,
            "output": 16384
          },
          "variants": {
            "low": { "reasoningEffort": "low" },
            "high": { "reasoningEffort": "high" },
            "max": { "reasoningEffort": "max" }
          }
        }
      }
    }
  }
}

Select it with /models, or launch OpenCode with:

opencode -m spark-local/glm-5.3-flash

low, high, and max are native GLM-5.3 reasoning levels. The OpenCode AI-SDK option is camel-case reasoningEffort; the OpenAI-compatible provider translates it to the API's reasoning_effort. With no variant, this recipe's server default leaves thinking disabled for faster speculative decoding.

Core serving configuration

  • Tensor parallelism: 2
  • Context length: 262,144 tokens
  • DFlash2 speculative tokens: 7
  • KV cache: FP8 E4M3
  • GPU memory utilization: 0.85
  • Block size: 2304
  • MoE backend: Marlin
  • Maximum sequences: 6
  • Maximum batched tokens: 8192
  • Multimodal limit: 0 videos
  • Tool parser: glm47
  • Reasoning parser: glm45
  • Thinking disabled by default; OpenCode variants enable native reasoning

Adapting paths

If you use different model, draft, cache, or patch paths, update every matching path in the YAML. In particular, model:, speculative_config, --chat-template, the cache volume, and both patch-hook paths must remain consistent.

# GLM-5.3-Flash NVFP4 + DFlash2 on exactly two DGX Spark nodes.
#
# SparkRun adaptation of Tony D's original deployment:
# https://github.com/tonyd2wild/GLM-5.3-Flash-NVFP4-DFlash2-2x-DGX-Spark
#
# Required on both target nodes:
# /var/tmp/glm-5.3-flash-nvfp4/config.json
# /var/tmp/glm-5.3-flash-nvfp4/chat_template_mm.jinja
# /var/tmp/glm-5.3-flash-nvfp4/dflash2-draft/config.json
#
# Required on the machine that runs `sparkrun run`:
# /var/tmp/sparkrun-patches/glm53-sm121/sparse_attn_indexer_kpool_sm121.py
#
# Both checkpoints are intentionally pre-placed under one absolute directory.
# SparkRun identity-mounts that directory into every container and skips
# copying the roughly 180 GiB main checkpoint on every run.
#
# The SM121 patch is copied as a DIRECTORY because SparkRun 0.3.6 copy hooks
# use directory semantics. With no source_host, the source is the control
# machine running SparkRun; SparkRun distributes it to both target nodes.
recipe_version: "4"
name: glm-5.3-flash-nvfp4-dflash2-tp2
description: >-
GLM-5.3-Flash NVFP4 with DFlash2 speculative decoding at TP2 and 262K
context on exactly two NVIDIA DGX Spark nodes.
model: /var/tmp/glm-5.3-flash-nvfp4
runtime: vllm-distributed
container: ghcr.io/tonyd2wild/vllm-glm53-flash:sm121-v11-dflash2
min_nodes: 2
max_nodes: 2
metadata:
source: https://github.com/tonyd2wild/GLM-5.3-Flash-NVFP4-DFlash2-2x-DGX-Spark
upstream_author: Tony D (tonyd2wild) and contributors
attribution: SparkRun adaptation of the upstream image, patches, flags, and operational findings
model_params: 320B
model_dtype: nvfp4
kv_dtype: fp8_e4m3
quantization: compressed-tensors
quant_bits: 4
model_type: glm5_next_text
num_layers: 45
kv_lora_rank: 512
index_head_dim: 128
defaults:
port: 8000
host: 0.0.0.0
tensor_parallel: 2
served_model_name: glm-5.3-flash
distributed_executor_backend: mp
gpu_memory_utilization: 0.85
max_model_len: 262144
max_num_seqs: 6
max_num_batched_tokens: 8192
block_size: 2304
limit_mm_per_prompt: '{"video":0}'
kv_cache_dtype: fp8_e4m3
trust_remote_code: true
enforce_eager: true
enable_auto_tool_choice: true
tool_call_parser: glm47
reasoning_parser: glm45
speculative_config: '{"method":"dflash","model":"/var/tmp/glm-5.3-flash-nvfp4/dflash2-draft","num_speculative_tokens":7}'
env:
HF_HOME: /cache/huggingface
HF_HUB_OFFLINE: "1"
TRANSFORMERS_OFFLINE: "1"
VLLM_ENGINE_READY_TIMEOUT_S: "3600"
PYTORCH_CUDA_ALLOC_CONF: "expandable_segments:True"
TORCH_CUDA_ARCH_LIST: "12.1a"
FLASHINFER_CUDA_ARCH_LIST: "12.1a"
FLASHINFER_DISABLE_VERSION_CHECK: "1"
NCCL_NET: "IB"
NCCL_IB_DISABLE: "0"
NCCL_IB_GID_INDEX: "3"
NCCL_IB_ROCE_VERSION_NUM: "2"
NCCL_IB_ADDR_FAMILY: "AF_INET"
NCCL_NVLS_ENABLE: "0"
NCCL_CROSS_NIC: "0"
NCCL_IB_MERGE_NICS: "0"
NCCL_CUMEM_ENABLE: "0"
NCCL_IGNORE_CPU_AFFINITY: "1"
NCCL_DEBUG: "WARN"
TORCH_NCCL_ASYNC_ERROR_HANDLING: "1"
executor: docker
executor_config:
auto_remove: false
gpus: all
ipc: host
network: host
shm_size: 32gb
entrypoint: ""
cap_add:
- IPC_LOCK
ulimit:
- memlock=-1:-1
devices:
- /dev/infiniband:/dev/infiniband
volumes:
- /var/tmp/glm53-vllm-cache:/cache
pre_exec:
- copy: /var/tmp/sparkrun-patches/glm53-sm121
dest: /workspace/glm53-sm121-patch
- |
set -eu
src=/workspace/glm53-sm121-patch/sparse_attn_indexer_kpool_sm121.py
dst=/usr/local/lib/python3.12/dist-packages/vllm/model_executor/layers/sparse_attn_indexer_kpool.py
echo "8a3ecfb0bab2441dd7417ed00a10d142191496149f88e5fe79fcfaea4b160980 $src" | sha256sum -c -
install -m 0644 "$src" "$dst"
command: |
vllm serve {model} \
--served-model-name {served_model_name} \
--host {host} --port {port} \
--trust-remote-code \
--tensor-parallel-size {tensor_parallel} \
--distributed-executor-backend {distributed_executor_backend} \
--gpu-memory-utilization {gpu_memory_utilization} \
--max-model-len {max_model_len} \
--max-num-seqs {max_num_seqs} \
--block-size {block_size} \
--limit-mm-per-prompt '{limit_mm_per_prompt}' \
--moe-backend marlin \
--speculative-config '{speculative_config}' \
--kv-cache-dtype {kv_cache_dtype} \
--enforce-eager \
--max-num-batched-tokens {max_num_batched_tokens} \
--tool-call-parser {tool_call_parser} \
--enable-auto-tool-choice \
--reasoning-parser {reasoning_parser} \
--default-chat-template-kwargs '{"enable_thinking":false}' \
--chat-template {model}/chat_template_mm.jinja
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment