DwarfStar + DeepSeek V4

A fast fixed schedule with a deliberately narrow contract.

DeepSeek V4 names the model architecture. DwarfStar names AFM's in-process fixed-schedule Metal executor for a specially packed DeepSeek V4 checkpoint. DSpark is an optional speculative support model layered on that executor. They are related, but they are not interchangeable.

The three layers

LayerWhat it isWhat it is not
DeepSeek V4The model_type: deepseek_v4 architecture and its chat/reasoning contract.It does not imply DwarfStar compatibility; ordinary MLX checkpoints use the MLX runtime.
DwarfStarA local, in-process Metal backend with persistent scratch storage and a fixed decode schedule.It is not an external server, a generic GGUF runner, or an alias for MLX custom kernels.
DSparkAn optional support GGUF used for greedy speculative proposals and verifier acceptance.It is not enabled by --mtp, and it does not accelerate sampled requests.

Runtime selection

--mlx-runtime auto is the default. It selects DwarfStar when the model argument is a local GGUF whose metadata declares the compatible deepseek4 architecture. A remote Hugging Face ID must first be resolved to a local file. Explicit dwarfstar requires a compatible local GGUF and fails early on a directory, missing file, or incompatible architecture; explicit mlx keeps the general MLX path.

# Auto-select DwarfStar for a compatible local GGUF
afm mlx -m /models/deepseek-v4-dwarfstar.gguf

# Require DwarfStar and fail early if the GGUF is incompatible
afm mlx -m /models/deepseek-v4-dwarfstar.gguf   --mlx-runtime dwarfstar

# Force the general MLX runtime for an ordinary MLX checkpoint
afm mlx -m /models/deepseek-v4-mlx   --mlx-runtime mlx

Executor package format

The converter and lower-level AFMKit integration can also describe an AFM-native safetensor executor package. This is packaging reference—not the AFM 0.9.15 CLI launch path above. Its config.json declares all of the following:

MarkerRequired valueReason
model_typedeepseek_v4Selects the only architecture currently supported by this loader.
afm_native_checkpointtrueConfirms that AFM's architecture mapping has already been applied.
afm_q8_0trueUses the dense Q8_0 ABI expected by the fixed executor.
afm_dwarfstar_mxfp4_layouttrueMarks DwarfStar's routed-expert MXFP4 representation.
afm_dwarfstar_mxfp4_packedtrueConfirms the lane-oriented packed expert blocks consumed by Metal kernels.
afm_dwarfstar_executor_layout_version3 or newerRequires the corrected aligned executor layout.

The package also needs model.safetensors.index.json, every indexed shard, all real tensor offsets aligned to 32 bytes, and the bundled dwarfstar-template.gguf. The catalog is validated before the engine opens; a nearly compatible package is not accepted.

Build an executor package

afm mlx-convert   --source /path/to/official-DeepSeek-V4-Flash-0731   --output /path/to/deepseek-v4-afm-executor   --profile dwarfstar-executor   --template-gguf /path/to/reference-dwarfstar.gguf

The reference GGUF supplies compact metadata and tensor schema for the bundled template; the converted AFM safetensor shards remain the model payload. Conversion is persistent, shard-streaming, and resumable. Use --overwrite only when you intend to recreate the output directory.

# Upgrade an older AFM executor package in place to the aligned layout
afm mlx-align-executor   --checkpoint /path/to/deepseek-v4-afm-executor

What the runtime does support

  • OpenAI-compatible streaming and non-streaming text chat.
  • Greedy decoding and temperature sampling with top_p, top_k, min_p, and seed.
  • Maximum-token limits, stop sequences, cancellation, token usage, and timing metadata.
  • DeepSeek reasoning policy through reasoning_effort, template kwargs, and --no-thinking.
  • Resident concurrent sessions with --concurrent N.
  • Exact-prefix reuse with --enable-prefix-caching.
  • The built-in WebUI, restricted to text input for this runtime.

Limitations matrix

AreaStatusPractical consequence
InputText messages onlyImages, PDFs, audio, --vlm, and --media are rejected.
ToolsNot supportedAny request containing tools is rejected by the DwarfStar provider.
Structured outputNot supportedGuided JSON, response-schema grammar, and token-level tool grammar are MLX paths.
PenaltiesNot supportedRepetition and presence penalties are rejected at startup; frequency penalties are not implemented.
KV controlsFixed runtime cache--kv-bits, MLX KV eviction, and MLX cache implementations do not apply.
SpeculationDSpark support GGUF only--mtp and --eagle3 are rejected. Do not confuse DwarfStar DSpark with the embedded MLX AFM_DSPARK path.
Log probabilitiesNot returnedThe fixed-schedule provider does not populate token logprob records.
Batch APINot registeredDwarfStar can schedule resident concurrent sessions, but /v1/batch/completions and /v1/batches are MLX-only.
Context32,768 tokens in the public CLI pathThe AFMKit provider can be configured directly, but afm mlx currently fixes DwarfStar server context to 32,768.
Model familyCompatible DeepSeek V4 GGUFAn arbitrary GGUF, Hugging Face ID, or ordinary MLX DeepSeek checkpoint is not sufficient.

Concurrency and prefix reuse

--concurrent N creates N resident DwarfStar sessions and batches active decode items through the fixed engine. This is ordinary multi-session serving, not the MLX batch API. Each session consumes cache and runtime resources, so increase it only after measuring unified-memory headroom.

Prefix caching is intentionally conservative. AFM reuses a resident session only when the session's complete live token history is a prefix of the new prompt. A shorter common prefix is reported as a miss because DwarfStar would still need to rebuild compressor and KV frontiers.

DSpark speculative decoding

afm mlx -m /path/to/deepseek-v4-dwarfstar.gguf   --mlx-runtime dwarfstar   --dspark-support /path/to/support.gguf   --dspark-draft-tokens 5   --dspark-confidence 0.7
ControlContract
--dspark-supportMust be an existing local GGUF compatible with the loaded executor. Supplying it enables DSpark only if the opened engine reports MTP support.
--dspark-draft-tokensInteger from 1 through 16; default 5.
--dspark-confidencePruning threshold from 0 through 1; default 0.7.
--dspark-strictLoads the support model but retains target-only decoding for correctness comparisons.

Performance boundary

The repository's M3 Ultra validation found that the fixed executor's roughly two command buffers per generated token removed the graph-fragmentation boundary seen in the native MLX DeepSeek V4 path. The aligned AFM executor measured within the canonical DwarfStar run variance and preserved exact greedy output in the validated bracket.

Those 35–37 token/s measurements are evidence for one DeepSeek V4 Flash 0731 package, prompt, build, and M3 Ultra—not a universal speed guarantee. Checkpoint conversion changes weight ABI and loadability; semantic quality and performance still require validation on the package and Mac you will deploy.

For the complete benchmark record, controlled variables, rejected hypotheses, hashes, and capture inventory, read the DeepSeek V4 performance record.

Choose DwarfStar or MLX

Choose DwarfStar when…Choose MLX when…
You have a compatible local DeepSeek V4 GGUF and want its fixed schedule.You have an ordinary Hugging Face/MLX checkpoint or a different architecture.
Your workload is text chat, sampling, streaming, or measured DSpark speculation.You need tools, JSON Schema, logprobs, VLM media, KV quantization, or MLX batch endpoints.
You can validate the converted package and its memory footprint on target hardware.You prefer the broad, general runtime and its larger compatibility surface.