Share the Metal session graph with CUDA for text and vision, MTP and exact sampling, steering, checkpoints, and disk-only BF16 n-grams. Add bounded concurrent Linux n-gram reads, vectorized dense and expert kernels, register-held recurrent prefill state, and efficient small speculative batches. Keep Qwen out of DeepSeek batch dispatch and exclude disk n-grams from resident memory accounting. Use normal file-backed weight loading in diagnostics and link n-gram support into the CUDA quality scorer. Include independent kernel and memory-safety tests, mixed-prefill and recovery checks, long-context server and agent coverage, and user documentation with measured DGX Spark performance.
70 lines
3.3 KiB
Makefile
70 lines
3.3 KiB
Makefile
CC ?= cc
|
|
CXX ?= c++
|
|
UNAME_S := $(shell uname -s)
|
|
LLAMA_CPP_DIR ?= ../../deepseek-v4-quants/llama.cpp
|
|
LLAMA_CPP_BUILD ?= $(LLAMA_CPP_DIR)/build-remote
|
|
LLAMA_CPP_BIN ?= $(LLAMA_CPP_BUILD)/bin
|
|
LLAMA_CPP_CXXFLAGS ?= -O3 -Wall -Wextra -std=c++17 \
|
|
-I$(LLAMA_CPP_DIR)/include -I$(LLAMA_CPP_DIR)/ggml/include
|
|
|
|
ifeq ($(UNAME_S),Darwin)
|
|
NATIVE_CPU_FLAG ?= -mcpu=native
|
|
QUANTS_SHARED := libds4quants.dylib
|
|
SHARED_FLAGS := -dynamiclib
|
|
QUALITY_LDLIBS := -lm -pthread -framework Foundation -framework Metal
|
|
QUALITY_TARGETS := ds4.o ds4_metal.o ds4_distributed.o ds4_tp.o ds4_ssd.o ds4_layer_pack.o ds4_engram.o ds4_image.o rax.o ds4_gpu_args.o
|
|
QUALITY_OBJS := ../ds4.o ../ds4_metal.o ../ds4_distributed.o ../ds4_tp.o ../ds4_ssd.o ../ds4_layer_pack.o ../ds4_engram.o ../ds4_image.o ../rax.o ../ds4_gpu_args.o
|
|
QUALITY_LINK = $(CC) $(CFLAGS) -I.. -o
|
|
LLAMA_CPP_LDLIBS ?= -L$(LLAMA_CPP_BIN) -Wl,-rpath,$(abspath $(LLAMA_CPP_BIN)) \
|
|
-lllama -lggml -lggml-base -lggml-cpu -lggml-blas -lggml-metal \
|
|
-framework Foundation -framework Metal -framework Accelerate
|
|
else
|
|
NATIVE_CPU_FLAG ?= -march=native
|
|
QUANTS_SHARED := libds4quants.so
|
|
SHARED_FLAGS := -shared
|
|
CUDA_NVCC := $(shell command -v nvcc 2>/dev/null)
|
|
CUDA_HOME ?= $(if $(wildcard /usr/local/cuda/bin/nvcc),/usr/local/cuda,$(if $(CUDA_NVCC),$(patsubst %/bin/nvcc,%,$(CUDA_NVCC)),/usr/local/cuda))
|
|
NVCC ?= $(CUDA_HOME)/bin/nvcc
|
|
CUDA_ARCH ?=
|
|
ifneq ($(strip $(CUDA_ARCH)),)
|
|
NVCC_ARCH_FLAGS := -arch=$(CUDA_ARCH)
|
|
endif
|
|
NVCCFLAGS ?= -O3 --use_fast_math $(NVCC_ARCH_FLAGS) -Xcompiler $(NATIVE_CPU_FLAG) -Xcompiler -pthread
|
|
QUALITY_LDLIBS ?= -lm -Xcompiler -pthread -L$(CUDA_HOME)/targets/sbsa-linux/lib -L$(CUDA_HOME)/lib64 -lcudart -lcublas
|
|
QUALITY_TARGETS := ds4.o ds4_cuda.o ds4_distributed.o ds4_tp.o ds4_ssd.o ds4_layer_pack.o ds4_engram.o ds4_image.o rax.o ds4_gpu_args.o \
|
|
cuda/mmq/ds4_ggml_stubs.o cuda/mmq/ds4_mmq.o cuda/mmq/ds4_mmq_d2r.o \
|
|
cuda/mmq/quantize.o cuda/mmq/mmid.o cuda/mmq/mmvq.o cuda/mmq/ds4_repack.o
|
|
QUALITY_OBJS := ../ds4.o ../ds4_cuda.o ../ds4_distributed.o ../ds4_tp.o ../ds4_ssd.o ../ds4_layer_pack.o ../ds4_engram.o ../ds4_image.o ../rax.o ../ds4_gpu_args.o \
|
|
../cuda/mmq/ds4_ggml_stubs.o ../cuda/mmq/ds4_mmq.o ../cuda/mmq/ds4_mmq_d2r.o \
|
|
../cuda/mmq/quantize.o ../cuda/mmq/mmid.o ../cuda/mmq/mmvq.o ../cuda/mmq/ds4_repack.o
|
|
QUALITY_LINK := $(NVCC) $(NVCCFLAGS) -I.. -o
|
|
LLAMA_CPP_LDLIBS ?= -L$(LLAMA_CPP_BIN) -Wl,-rpath,$(abspath $(LLAMA_CPP_BIN)) \
|
|
-lllama -lggml -lggml-base -lggml-cpu -ldl -lpthread
|
|
endif
|
|
|
|
CFLAGS ?= -O3 -Wall -Wextra -std=c11 $(NATIVE_CPU_FLAG)
|
|
CPPFLAGS ?= -D_GNU_SOURCE
|
|
|
|
.PHONY: all clean quants-shared quality-score quality-llama-score
|
|
|
|
all: deepseek4-quantize $(QUANTS_SHARED)
|
|
|
|
quants-shared: $(QUANTS_SHARED)
|
|
|
|
deepseek4-quantize: deepseek4-quantize.c quants.c quants.h
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ deepseek4-quantize.c quants.c -lm -pthread
|
|
|
|
$(QUANTS_SHARED): quants.c quants.h
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) $(SHARED_FLAGS) -fPIC -o $@ quants.c -lm -pthread
|
|
|
|
quality-score:
|
|
$(MAKE) -C .. $(QUALITY_TARGETS)
|
|
$(QUALITY_LINK) quality-testing/score_official quality-testing/score_official.c $(QUALITY_OBJS) $(QUALITY_LDLIBS)
|
|
|
|
quality-llama-score:
|
|
$(CXX) $(LLAMA_CPP_CXXFLAGS) -o quality-testing/score_llama quality-testing/score_llama.cpp $(LLAMA_CPP_LDLIBS)
|
|
|
|
clean:
|
|
rm -f deepseek4-quantize libds4quants.dylib libds4quants.so \
|
|
quality-testing/score_official quality-testing/score_llama
|