Project

go-ds4

active

Go inference engine for sparse MoE models, with CPU and GPU backends.

Overview

A Go inference engine for sparse mixture-of-experts models, including DeepSeek V4 Flash, ported from antirez's C implementation. It provides a command-line chat client and an OpenAI-compatible API server, with CPU, CUDA and Vulkan backends. Metal support is experimental.

The default build has no mandatory C/C++ runtime dependency. Model weights are memory-mapped rather than copied into a separate loading buffer.

How it works

The inference pipeline reads model weights from disk through memory mapping and runs attention and expert layers using the selected compute backend. CPU execution uses SIMD kernels; GPU backends handle supported operations on the device. The command-line client and HTTP server share this inference engine.

Features
⚡
CPU kernels

SIMD matrix operations for CPU inference, including work shared with go-pherence.

🖥
GPU backends

CUDA and Vulkan compute paths, with experimental Metal support.

🦙
Sparse MoE models

Inference support for mixture-of-experts models, including DeepSeek V4 Flash.

🌐
OpenAI-compatible API

A /v1/chat/completions server with streaming.

📦
Go build

Build the CLI with go build ./cmd/ds4chat, without a mandatory C/C++ runtime.

🗺
Memory-mapped weights

Accesses model weights through memory mapping; inference still needs to read the required pages from storage.

Architecture
Safetensors weights 128 GB Q2 via mmap Inference engine 43-layer pipeline MLA Attention LoRA + KV cache MoE FFN 256 experts top-6 Hyper-conn 4-stream mixing Compute backends AVX2/NEON SIMD GEMM CUDA PTX GPU kernels OpenAI API /v1/chat/completions mmap DeepSeek V4 Flash inference — pure Go, AVX2 + CUDA PTX
Posts