Download Makefile from julianmb/ds4fa: direct link, hf CLI and curl.
- Browser
- Download file 26.5 kB
-
https://huggingface.co/julianmb/ds4fa/resolve/main/Makefile
- Command line
-
hf download hf://julianmb/ds4fa/Makefile
-
curl -L -o Makefile https://huggingface.co/julianmb/ds4fa/resolve/main/Makefile
26.5 kB
| VPATH = src | |
| CC ?= cc | |
| UNAME_S := $(shell uname -s) | |
| ifeq ($(UNAME_S),Darwin) | |
| NATIVE_CPU_FLAG ?= -mcpu=native | |
| SAMPLING_TEST := | |
| else | |
| NATIVE_CPU_FLAG ?= -march=native | |
| SAMPLING_TEST := tests/test_sampling | |
| endif | |
| DEBUG_FLAGS ?= -g | |
| CFLAGS ?= -O3 -ffast-math $(DEBUG_FLAGS) $(NATIVE_CPU_FLAG) -Wall -Wextra -std=c99 | |
| OBJCFLAGS ?= -O3 -ffast-math $(DEBUG_FLAGS) $(NATIVE_CPU_FLAG) -Wall -Wextra -fobjc-arc | |
| QUALITY_CFLAGS ?= -O3 $(DEBUG_FLAGS) $(NATIVE_CPU_FLAG) -Wall -Wextra -std=c11 | |
| LDLIBS ?= -lm -pthread | |
| METAL_SRCS := $(wildcard metal/*.metal) | |
| ROCM_SRCS := $(wildcard src/rocm/*.cuh) | |
| DS4_TEST_MODEL ?= ds4flash.gguf | |
| DS4_TEST_MTP ?= gguf/DeepSeek-V4-Flash-MTP-Q4K-Q8_0-F32.gguf | |
| DS4_DSPARK_MODEL ?= $(DS4_TEST_MODEL) | |
| DS4_DSPARK_SUPPORT ?= gguf/DeepSeek-V4-Flash-DSpark-support-0731.gguf | |
| ifeq ($(UNAME_S),Darwin) | |
| METAL_LDLIBS := $(LDLIBS) -framework Foundation -framework Metal | |
| CORE_OBJS = ds4.o ds4_distributed.o ds4_tp.o ds4_ssd.o ds4_metal.o ds4_layer_pack.o | |
| CPU_CORE_OBJS = ds4_cpu.o ds4_distributed.o ds4_tp.o ds4_ssd.o ds4_layer_pack.o | |
| else | |
| CFLAGS += -D_GNU_SOURCE -fno-finite-math-only | |
| CUDA_HOME ?= $(shell if [ -x /usr/local/cuda/bin/nvcc ]; then \ | |
| printf '%s' /usr/local/cuda; \ | |
| elif command -v nvcc >/dev/null 2>&1; then \ | |
| dirname "$$(dirname "$$(command -v nvcc)")"; \ | |
| else \ | |
| printf '%s' /usr/local/cuda; \ | |
| fi) | |
| NVCC ?= $(CUDA_HOME)/bin/nvcc | |
| CUDA_ARCH ?= | |
| ifneq ($(strip $(CUDA_ARCH)),) | |
| ifneq ($(filter sm_120 sm_120a,$(strip $(CUDA_ARCH))),) | |
| NVCC_ARCH_FLAGS := -gencode arch=compute_120a,code=sm_120a -DDS4_CUDA_HAVE_MXF4=1 | |
| else ifneq ($(filter sm_121 sm_121a,$(strip $(CUDA_ARCH))),) | |
| NVCC_ARCH_FLAGS := -gencode arch=compute_121a,code=sm_121a -DDS4_CUDA_HAVE_MXF4=1 | |
| else | |
| NVCC_ARCH_FLAGS := -arch=$(CUDA_ARCH) | |
| endif | |
| endif | |
| NVCCFLAGS ?= -O3 -g -lineinfo --use_fast_math $(NVCC_ARCH_FLAGS) -Xcompiler $(NATIVE_CPU_FLAG) -Xcompiler -pthread | |
| # Vendored llama.cpp mmq prefill tier (cuda/mmq/, see cuda/mmq/VENDOR.md). | |
| MMQ_INCLUDES := -Icuda/mmq | |
| MMQ_OBJS := 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 | |
| CORE_OBJS = ds4.o ds4_distributed.o ds4_tp.o ds4_ssd.o ds4_cuda.o ds4_layer_pack.o $(MMQ_OBJS) | |
| CPU_CORE_OBJS = ds4_cpu.o ds4_distributed.o ds4_tp.o ds4_ssd.o ds4_layer_pack.o | |
| CUDA_LDLIBS ?= -lm -Xcompiler -pthread -L$(CUDA_HOME)/targets/sbsa-linux/lib -L$(CUDA_HOME)/lib64 -lcudart -lcublas | |
| HIPCC ?= $(shell command -v hipcc 2>/dev/null || echo /opt/rocm/bin/hipcc) | |
| ROCM_ARCH ?= gfx1151 | |
| ROCM_CFLAGS ?= -O3 -ffast-math -g -fno-finite-math-only -pthread -D__HIP_PLATFORM_AMD__ -DDFLASH_WAVE_SIZE=32 -Wno-unused-command-line-argument --offload-arch=$(ROCM_ARCH) | |
| ROCM_LDLIBS ?= -lm -pthread -lhipblas -lhipblaslt | |
| DS4_LINK ?= $(NVCC) $(NVCCFLAGS) | |
| DS4_LINK_LIBS ?= $(CUDA_LDLIBS) | |
| METAL_LDLIBS := $(LDLIBS) | |
| endif | |
| ifeq ($(UNAME_S),Darwin) | |
| all: ds4 ds4-server ds4-bench ds4-eval ds4-agent | |
| help: | |
| @echo "DS4 build targets:" | |
| @echo " make Build Metal ./ds4, ./ds4-server, ./ds4-bench, ./ds4-eval, and ./ds4-agent" | |
| @echo " make cpu Build CPU-only ./ds4, ./ds4-server, ./ds4-bench, ./ds4-eval, and ./ds4-agent" | |
| @echo " make test Build and run tests" | |
| @echo " make metal-decode-schedule-bench Build the balanced Metal decode schedule benchmark" | |
| @echo " make metal-prefill-variant-bench Build the balanced Metal prefill variant benchmark" | |
| @echo " make check-mxfp4-half-lut Verify the checked-in MXFP4 half LUT matches the generator" | |
| @echo " make test-mxfp4-metal Check the MXFP4 half LUT, then run Metal MXFP4 exactness tests" | |
| @echo " make dspark-verify-depth Run DSpark speculative verification smoke if support GGUF is present" | |
| @echo " make mtp-verify-depth Run legacy MTP speculative verification smoke if MTP GGUF is present" | |
| @echo " make clean Remove build outputs" | |
| ds4: ds4_cli.o ds4_help.o linenoise.o ds4_gpu_args.o $(CORE_OBJS) | |
| $(CC) $(CFLAGS) -o $@ ds4_cli.o ds4_help.o linenoise.o ds4_gpu_args.o $(CORE_OBJS) $(METAL_LDLIBS) | |
| ds4-server: ds4_server.o ds4_help.o ds4_kvstore.o rax.o ds4_gpu_args.o $(CORE_OBJS) | |
| $(CC) $(CFLAGS) -o $@ ds4_server.o ds4_help.o ds4_kvstore.o rax.o ds4_gpu_args.o $(CORE_OBJS) $(METAL_LDLIBS) | |
| ds4-bench: ds4_bench.o ds4_help.o ds4_gpu_args.o $(CORE_OBJS) | |
| $(CC) $(CFLAGS) -o $@ ds4_bench.o ds4_help.o ds4_gpu_args.o $(CORE_OBJS) $(METAL_LDLIBS) | |
| ds4-eval: ds4_eval.o ds4_help.o $(CORE_OBJS) | |
| $(CC) $(CFLAGS) -o $@ ds4_eval.o ds4_help.o $(CORE_OBJS) $(METAL_LDLIBS) | |
| ds4-agent: ds4_agent.o ds4_help.o ds4_web.o ds4_kvstore.o linenoise.o ds4_gpu_args.o $(CORE_OBJS) | |
| $(CC) $(CFLAGS) -o $@ ds4_agent.o ds4_help.o ds4_web.o ds4_kvstore.o linenoise.o ds4_gpu_args.o $(CORE_OBJS) $(METAL_LDLIBS) | |
| gguf-tools/quality-testing/score_official: gguf-tools/quality-testing/score_official.c ds4.h $(CORE_OBJS) rax.o ds4_gpu_args.o | |
| $(CC) $(QUALITY_CFLAGS) -I src -o $@ gguf-tools/quality-testing/score_official.c $(CORE_OBJS) rax.o ds4_gpu_args.o $(METAL_LDLIBS) | |
| tests/test_metal_session_batch.o: tests/test_metal_session_batch.c ds4.h | |
| $(CC) $(CFLAGS) -I src -c -o $@ $< | |
| tests/test_metal_session_batch: tests/test_metal_session_batch.o $(CORE_OBJS) | |
| $(CC) $(CFLAGS) -o $@ $^ $(METAL_LDLIBS) | |
| test-metal-session-batch: tests/test_metal_session_batch | |
| DS4_TEST_MODEL="$(DS4_TEST_MODEL)" ./tests/test_metal_session_batch | |
| speed-bench/metal_decode_schedule_bench.o: speed-bench/metal_decode_schedule_bench.c ds4.h | |
| $(CC) $(CFLAGS) -I. -c -o $@ $< | |
| speed-bench/metal_decode_schedule_bench: speed-bench/metal_decode_schedule_bench.o $(CORE_OBJS) | |
| $(CC) $(CFLAGS) -o $@ $^ $(METAL_LDLIBS) | |
| metal-decode-schedule-bench: speed-bench/metal_decode_schedule_bench | |
| speed-bench/metal_prefill_variant_bench.o: speed-bench/metal_prefill_variant_bench.c ds4.h | |
| $(CC) $(CFLAGS) -I. -c -o $@ $< | |
| speed-bench/metal_prefill_variant_bench: speed-bench/metal_prefill_variant_bench.o $(CORE_OBJS) | |
| $(CC) $(CFLAGS) -o $@ $^ $(METAL_LDLIBS) | |
| metal-prefill-variant-bench: speed-bench/metal_prefill_variant_bench | |
| tests/test_mxfp4_metal.o: tests/test_mxfp4_metal.c ds4_gpu.h | |
| $(CC) $(CFLAGS) -I. -c -o $@ $< | |
| tests/test_mxfp4_metal: tests/test_mxfp4_metal.o ds4_metal.o | |
| $(CC) $(CFLAGS) -o $@ $^ $(METAL_LDLIBS) | |
| check-mxfp4-half-lut: | |
| python3 metal/generate_mxfp4_half_lut.py --check | |
| test-mxfp4-metal: check-mxfp4-half-lut tests/test_mxfp4_metal | |
| ./tests/test_mxfp4_metal | |
| cpu: ds4_cli_cpu.o ds4_server_cpu.o ds4_bench_cpu.o ds4_eval_cpu.o ds4_agent_cpu.o ds4_help.o ds4_web.o ds4_kvstore.o linenoise.o rax.o ds4_gpu_args_cpu.o $(CPU_CORE_OBJS) | |
| $(CC) $(CFLAGS) -o ds4 ds4_cli_cpu.o ds4_help.o linenoise.o ds4_gpu_args_cpu.o $(CPU_CORE_OBJS) $(LDLIBS) | |
| $(CC) $(CFLAGS) -o ds4-server ds4_server_cpu.o ds4_help.o ds4_kvstore.o rax.o ds4_gpu_args_cpu.o $(CPU_CORE_OBJS) $(LDLIBS) | |
| $(CC) $(CFLAGS) -o ds4-bench ds4_bench_cpu.o ds4_help.o ds4_gpu_args_cpu.o $(CPU_CORE_OBJS) $(LDLIBS) | |
| $(CC) $(CFLAGS) -o ds4-eval ds4_eval_cpu.o ds4_help.o $(CPU_CORE_OBJS) $(LDLIBS) | |
| $(CC) $(CFLAGS) -o ds4-agent ds4_agent_cpu.o ds4_help.o ds4_web.o ds4_kvstore.o linenoise.o ds4_gpu_args_cpu.o $(CPU_CORE_OBJS) $(LDLIBS) | |
| cuda-regression: | |
| @echo "cuda-regression requires a CUDA build" | |
| else | |
| all: help | |
| help: | |
| @echo "DS4 build targets:" | |
| @echo " make cuda-spark Build CUDA for DGX Spark / GB10" | |
| @echo " make cuda-generic Build CUDA for a generic local CUDA GPU" | |
| @echo " make cuda CUDA_ARCH=sm_N Build CUDA with an explicit nvcc -arch value" | |
| @echo " make strix-halo Build ROCm for Strix Halo / gfx1151" | |
| @echo " make rocm Alias for make strix-halo" | |
| @echo " make rocm-smoke Build and run the ROCm/Strix Halo hardware smoke test" | |
| @echo " make rocm-model-fit Report whether DS4_TEST_MODEL fits the TTM/GTT limit" | |
| @echo " make rocm-verify Full verification: doctor + smoke + bench + model-fit" | |
| @echo " make rocm-doctor One-screen triage for Strix Halo setup" | |
| @echo " make cpu Build CPU-only ./ds4, ./ds4-server, ./ds4-bench, ./ds4-eval, and ./ds4-agent" | |
| @echo " make test Build and run tests" | |
| @echo " make dspark-verify-depth Run DSpark speculative verification smoke if support GGUF is present" | |
| @echo " make mtp-verify-depth Run legacy MTP speculative verification smoke if MTP GGUF is present" | |
| @echo " make clean Remove build outputs" | |
| cuda-spark: | |
| $(MAKE) -B ds4 ds4-server ds4-bench ds4-eval ds4-agent CUDA_ARCH=sm_121 | |
| cuda-generic: | |
| $(MAKE) -B ds4 ds4-server ds4-bench ds4-eval ds4-agent CUDA_ARCH=native | |
| cuda: | |
| @if [ -z "$(strip $(CUDA_ARCH))" ]; then \ | |
| echo "error: specify CUDA_ARCH, for example: make cuda CUDA_ARCH=sm_120"; \ | |
| echo " or use make cuda-spark / make cuda-generic"; \ | |
| exit 2; \ | |
| fi | |
| $(MAKE) -B ds4 ds4-server ds4-bench ds4-eval ds4-agent CUDA_ARCH="$(CUDA_ARCH)" | |
| strix-halo: | |
| $(MAKE) -B ds4 ds4-server ds4-bench ds4-eval ds4-agent \ | |
| CORE_OBJS="ds4.o ds4_distributed.o ds4_tp.o ds4_ssd.o ds4_rocm.o ds4_rocm_compat.o ds4_rocm_unavailable.o ds4_layer_pack.o" \ | |
| CFLAGS="$(CFLAGS) -DDS4_ROCM_BUILD" \ | |
| DS4_LINK="$(HIPCC) $(ROCM_CFLAGS)" \ | |
| DS4_LINK_LIBS="$(ROCM_LDLIBS)" | |
| rocm: strix-halo | |
| tests/rocm_smoke.o: tests/rocm_smoke.c ds4_gpu.h | |
| $(HIPCC) $(ROCM_CFLAGS) -I src -c -o $@ $< | |
| tests/rocm_smoke: tests/rocm_smoke.o ds4_rocm.o ds4_rocm_compat.o ds4_rocm_unavailable.o | |
| $(HIPCC) $(ROCM_CFLAGS) -o $@ $^ $(ROCM_LDLIBS) | |
| rocm-smoke: tests/rocm_smoke | |
| ./tests/rocm_smoke | |
| # Print only the Strix Halo runtime profile (no model needed). Honors | |
| # DS4_ROCM_DIAG to also write a machine-readable summary. The smoke test calls | |
| # ds4_gpu_init() which prints the profile; it PASSES without a model. | |
| rocm-diag: tests/rocm_smoke | |
| ./tests/rocm_smoke | |
| @echo "rocm-diag: profile printed above (set DS4_ROCM_DIAG=FILE to capture)" | |
| tests/rocm_bench_quick.o: tests/rocm_bench_quick.c ds4_gpu.h | |
| $(HIPCC) $(ROCM_CFLAGS) -I src -c -o $@ $< | |
| tests/rocm_bench_quick: tests/rocm_bench_quick.o ds4_rocm.o ds4_rocm_compat.o ds4_rocm_unavailable.o | |
| $(HIPCC) $(ROCM_CFLAGS) -o $@ $^ $(ROCM_LDLIBS) | |
| tests/rocm_model_fit.o: tests/rocm_model_fit.c ds4_gpu.h | |
| $(HIPCC) $(ROCM_CFLAGS) -I src -c -o $@ $< | |
| tests/rocm_model_fit: tests/rocm_model_fit.o ds4_rocm.o ds4_rocm_compat.o ds4_rocm_unavailable.o | |
| $(HIPCC) $(ROCM_CFLAGS) -o $@ $^ $(ROCM_LDLIBS) | |
| # Report whether DS4_TEST_MODEL fits the TTM/GTT limit (per-model verdict). | |
| # Exit 0 = fits, 1 = does not fit / error, 2 = no DS4_TEST_MODEL set. | |
| rocm-model-fit: tests/rocm_model_fit | |
| ./tests/rocm_model_fit | |
| # Launch real compute kernels on gfx1151 and report bandwidth. Confirms the | |
| # kernel path actually executes (not just malloc). | |
| rocm-bench-quick: tests/rocm_bench_quick | |
| ./tests/rocm_bench_quick | |
| # One-screen triage: permissions, gfx1151, TTM/GTT, amd-ttm, profile, bench. | |
| rocm-doctor: tests/rocm_smoke tests/rocm_bench_quick | |
| sh misc/rocm-doctor.sh | |
| # Full verification: doctor + strict smoke + bench + model-fit (if DS4_TEST_MODEL set). | |
| rocm-verify: tests/rocm_smoke tests/rocm_bench_quick tests/rocm_model_fit | |
| sh misc/rocm-doctor.sh | |
| ROCM_SMOKE_STRICT=1 ./tests/rocm_smoke | |
| ./tests/rocm_bench_quick | |
| @if [ -n "$$DS4_TEST_MODEL" ]; then \ | |
| echo "rocm-verify: checking model fit for $$DS4_TEST_MODEL"; \ | |
| ./tests/rocm_model_fit || exit 1; \ | |
| fi | |
| @echo "rocm-verify: ALL PASSED" | |
| # Fork CI: strict smoke test + bench + model-fit (if set) + upstream divergence policy check. | |
| ci: tests/rocm_smoke tests/rocm_bench_quick tests/rocm_model_fit | |
| ROCM_SMOKE_STRICT=1 ./tests/rocm_smoke | |
| ./tests/rocm_bench_quick | |
| @if [ -n "$$DS4_TEST_MODEL" ]; then \ | |
| echo "ci: checking model fit for $$DS4_TEST_MODEL"; \ | |
| ./tests/rocm_model_fit || exit 1; \ | |
| fi | |
| sh misc/sync-check.sh | |
| ds4: ds4_cli.o ds4_help.o linenoise.o ds4_gpu_args.o $(CORE_OBJS) | |
| $(DS4_LINK) -o $@ $^ $(DS4_LINK_LIBS) | |
| ds4-server: ds4_server.o ds4_help.o ds4_kvstore.o rax.o ds4_gpu_args.o $(CORE_OBJS) | |
| $(DS4_LINK) -o $@ $^ $(DS4_LINK_LIBS) | |
| ds4-bench: ds4_bench.o ds4_help.o ds4_gpu_args.o $(CORE_OBJS) | |
| $(DS4_LINK) -o $@ $^ $(DS4_LINK_LIBS) | |
| ds4-eval: ds4_eval.o ds4_help.o $(CORE_OBJS) | |
| $(DS4_LINK) -o $@ $^ $(DS4_LINK_LIBS) | |
| ds4-agent: ds4_agent.o ds4_help.o ds4_web.o ds4_kvstore.o linenoise.o ds4_gpu_args.o $(CORE_OBJS) | |
| $(DS4_LINK) -o $@ $^ $(DS4_LINK_LIBS) | |
| gguf-tools/quality-testing/score_official.o: gguf-tools/quality-testing/score_official.c ds4.h | |
| $(CC) $(filter-out -ffast-math,$(QUALITY_CFLAGS)) -I src -c -o $@ $< | |
| gguf-tools/quality-testing/score_official: gguf-tools/quality-testing/score_official.o $(CORE_OBJS) rax.o ds4_gpu_args.o | |
| $(DS4_LINK) -o $@ $^ $(DS4_LINK_LIBS) | |
| cpu: ds4_cli_cpu.o ds4_server_cpu.o ds4_bench_cpu.o ds4_eval_cpu.o ds4_agent_cpu.o ds4_help.o ds4_web.o ds4_kvstore.o linenoise.o rax.o ds4_gpu_args_cpu.o $(CPU_CORE_OBJS) | |
| $(CC) $(CFLAGS) -o ds4 ds4_cli_cpu.o ds4_help.o linenoise.o ds4_gpu_args_cpu.o $(CPU_CORE_OBJS) $(LDLIBS) | |
| $(CC) $(CFLAGS) -o ds4-server ds4_server_cpu.o ds4_help.o ds4_kvstore.o rax.o ds4_gpu_args_cpu.o $(CPU_CORE_OBJS) $(LDLIBS) | |
| $(CC) $(CFLAGS) -o ds4-bench ds4_bench_cpu.o ds4_help.o ds4_gpu_args_cpu.o $(CPU_CORE_OBJS) $(LDLIBS) | |
| $(CC) $(CFLAGS) -o ds4-eval ds4_eval_cpu.o ds4_help.o $(CPU_CORE_OBJS) $(LDLIBS) | |
| $(CC) $(CFLAGS) -o ds4-agent ds4_agent_cpu.o ds4_help.o ds4_web.o ds4_kvstore.o linenoise.o ds4_gpu_args_cpu.o $(CPU_CORE_OBJS) $(LDLIBS) | |
| cuda-regression: tests/cuda_long_context_smoke | |
| ./tests/cuda_long_context_smoke | |
| tests/test_mxfp4_cuda: tests/test_mxfp4_cuda.cu $(MMQ_OBJS) | |
| $(NVCC) $(NVCCFLAGS) -std=c++17 $(MMQ_INCLUDES) -o $@ $^ $(CUDA_LDLIBS) | |
| test-mxfp4-cuda: tests/test_mxfp4_cuda | |
| ./tests/test_mxfp4_cuda | |
| endif | |
| ds4.o: ds4.c ds4.h ds4_ssd.h ds4_distributed.h ds4_gpu.h | |
| $(CC) $(CFLAGS) -c -o $@ $< | |
| ds4_ssd.o: ds4_ssd.c ds4_ssd.h | |
| $(CC) $(CFLAGS) -c -o $@ $< | |
| ds4_cli.o: ds4_cli.c ds4.h ds4_ssd.h ds4_distributed.h ds4_help.h linenoise.h | |
| $(CC) $(CFLAGS) -c -o $@ $< | |
| ds4_distributed.o: ds4_distributed.c ds4_distributed.h ds4.h ds4_ssd.h | |
| $(CC) $(CFLAGS) -c -o $@ $< | |
| ds4_tp.o: ds4_tp.c ds4_tp.h ds4.h ds4_ssd.h | |
| $(CC) $(CFLAGS) -c -o $@ $< | |
| ds4_help.o: ds4_help.c ds4_help.h | |
| $(CC) $(CFLAGS) -c -o $@ $< | |
| ds4_gpu_args.o: ds4_gpu_args.c ds4_gpu_args.h ds4_gpu_mgpu.h | |
| $(CC) $(CFLAGS) -c -o $@ $< | |
| ds4_server.o: ds4_server.c ds4.h ds4_ssd.h ds4_distributed.h ds4_help.h ds4_kvstore.h rax.h | |
| $(CC) $(CFLAGS) -c -o $@ $< | |
| ds4_bench.o: ds4_bench.c ds4.h ds4_ssd.h ds4_distributed.h ds4_help.h | |
| $(CC) $(CFLAGS) -c -o $@ $< | |
| ds4_eval.o: ds4_eval.c ds4.h ds4_ssd.h ds4_distributed.h ds4_help.h | |
| $(CC) $(CFLAGS) -c -o $@ $< | |
| ds4_agent.o: ds4_agent.c ds4.h ds4_ssd.h ds4_distributed.h ds4_help.h ds4_kvstore.h ds4_web.h linenoise.h | |
| $(CC) $(CFLAGS) -c -o $@ $< | |
| ds4_web.o: ds4_web.c ds4_web.h | |
| $(CC) $(CFLAGS) -c -o $@ $< | |
| ds4_kvstore.o: ds4_kvstore.c ds4_kvstore.h ds4.h ds4_ssd.h | |
| $(CC) $(CFLAGS) -c -o $@ $< | |
| ds4_test.o: tests/ds4_test.c ds4_server.c ds4.h ds4_ssd.h ds4_distributed.h ds4_help.h ds4_kvstore.h rax.h | |
| $(CC) $(CFLAGS) -Wno-unused-function -c -o $@ $< | |
| ds4_agent_test.o: tests/ds4_agent_test.c ds4_agent.c ds4.h ds4_ssd.h ds4_distributed.h ds4_help.h ds4_kvstore.h ds4_web.h linenoise.h | |
| $(CC) $(CFLAGS) -Wno-unused-function -c -o $@ $< | |
| tests/cuda_long_context_smoke.o: tests/cuda_long_context_smoke.c ds4_gpu.h | |
| $(CC) $(CFLAGS) -I src -c -o $@ $< | |
| rax.o: rax.c rax.h rax_malloc.h | |
| $(CC) $(CFLAGS) -c -o $@ $< | |
| linenoise.o: linenoise.c linenoise.h | |
| $(CC) $(CFLAGS) -c -o $@ $< | |
| ds4_cpu.o: ds4.c ds4.h ds4_ssd.h ds4_distributed.h ds4_gpu.h | |
| $(CC) $(CFLAGS) -Wno-unused-function -DDS4_NO_GPU -c -o $@ $< | |
| ds4_cli_cpu.o: ds4_cli.c ds4.h ds4_ssd.h ds4_distributed.h ds4_help.h linenoise.h | |
| $(CC) $(CFLAGS) -DDS4_NO_GPU -c -o $@ $< | |
| ds4_gpu_args_cpu.o: ds4_gpu_args.c ds4_gpu_args.h ds4_gpu_mgpu.h | |
| $(CC) $(CFLAGS) -DDS4_NO_GPU -c -o $@ $< | |
| ds4_server_cpu.o: ds4_server.c ds4.h ds4_ssd.h ds4_distributed.h ds4_help.h ds4_kvstore.h rax.h | |
| $(CC) $(CFLAGS) -DDS4_NO_GPU -c -o $@ $< | |
| ds4_bench_cpu.o: ds4_bench.c ds4.h ds4_ssd.h ds4_distributed.h ds4_help.h | |
| $(CC) $(CFLAGS) -DDS4_NO_GPU -c -o $@ $< | |
| ds4_eval_cpu.o: ds4_eval.c ds4.h ds4_ssd.h ds4_distributed.h ds4_help.h | |
| $(CC) $(CFLAGS) -DDS4_NO_GPU -c -o $@ $< | |
| ds4_agent_cpu.o: ds4_agent.c ds4.h ds4_ssd.h ds4_distributed.h ds4_help.h ds4_kvstore.h ds4_web.h linenoise.h | |
| $(CC) $(CFLAGS) -DDS4_NO_GPU -c -o $@ $< | |
| ds4_metal.o: ds4_metal.m ds4_gpu.h $(METAL_SRCS) | |
| $(CC) $(OBJCFLAGS) -c -o $@ $< | |
| ds4_cuda.o: ds4_cuda.cu ds4_gpu.h ds4_gpu_mgpu.h ds4_iq2_tables_cuda.inc cuda/mmq/ds4_mmq.h | |
| $(NVCC) $(NVCCFLAGS) -c -o $@ $< | |
| # Vendored mmq pieces (see cuda/mmq/VENDOR.md). ds4_mmq.cu transitively | |
| # pulls in mmq.cuh which has heavy template instantiation -- each piece | |
| # compiles in its own TU and links in. | |
| cuda/mmq/ds4_ggml_stubs.o: cuda/mmq/ds4_ggml_stubs.cu cuda/mmq/ds4_ggml_stubs.h cuda/mmq/common.cuh | |
| $(NVCC) $(NVCCFLAGS) -std=c++17 $(MMQ_INCLUDES) -c -o $@ $< | |
| cuda/mmq/ds4_mmq.o: cuda/mmq/ds4_mmq.cu cuda/mmq/ds4_mmq.h cuda/mmq/ds4_mmq_d2r.cuh cuda/mmq/mmq.cuh cuda/mmq/common.cuh cuda/mmq/ds4_ggml_stubs.h cuda/mmq/quantize.cuh cuda/mmq/mmid.cuh cuda/mmq/vecdotq.cuh cuda/mmq/mma.cuh | |
| $(NVCC) $(NVCCFLAGS) -std=c++17 $(MMQ_INCLUDES) -c -o $@ $< | |
| cuda/mmq/ds4_mmq_d2r.o: cuda/mmq/ds4_mmq_d2r.cu cuda/mmq/ds4_mmq_d2r.cuh cuda/mmq/mmq.cuh cuda/mmq/common.cuh cuda/mmq/ds4_ggml_stubs.h cuda/mmq/vecdotq.cuh cuda/mmq/mma.cuh | |
| $(NVCC) $(NVCCFLAGS) -std=c++17 $(MMQ_INCLUDES) -c -o $@ $< | |
| cuda/mmq/quantize.o: cuda/mmq/quantize.cu cuda/mmq/quantize.cuh cuda/mmq/common.cuh cuda/mmq/ds4_ggml_stubs.h cuda/mmq/mmq.cuh | |
| $(NVCC) $(NVCCFLAGS) -std=c++17 $(MMQ_INCLUDES) -c -o $@ $< | |
| cuda/mmq/mmid.o: cuda/mmq/mmid.cu cuda/mmq/mmid.cuh cuda/mmq/common.cuh cuda/mmq/ds4_ggml_stubs.h | |
| $(NVCC) $(NVCCFLAGS) -std=c++17 $(MMQ_INCLUDES) -c -o $@ $< | |
| cuda/mmq/mmvq.o: cuda/mmq/mmvq.cu cuda/mmq/mmvq.cuh cuda/mmq/common.cuh cuda/mmq/ds4_ggml_stubs.h cuda/mmq/quantize.cuh cuda/mmq/vecdotq.cuh cuda/mmq/unary.cuh | |
| $(NVCC) $(NVCCFLAGS) -std=c++17 $(MMQ_INCLUDES) -c -o $@ $< | |
| cuda/mmq/ds4_repack.o: cuda/mmq/ds4_repack.cu cuda/mmq/ds4_repack.h | |
| $(NVCC) $(NVCCFLAGS) -std=c++17 -c -o $@ $< | |
| ds4_rocm.o: ds4_rocm.cu ds4_gpu.h ds4_iq2_tables_cuda.inc $(ROCM_SRCS) | |
| $(HIPCC) $(ROCM_CFLAGS) -c -o $@ $< | |
| ds4_rocm_compat.o: ds4_rocm_compat.cu ds4_gpu.h ds4_gpu_mgpu.h ds4_gpu_args.h | |
| $(HIPCC) $(ROCM_CFLAGS) -c -o $@ $< | |
| ds4_rocm_unavailable.o: ds4_rocm_unavailable.cu | |
| $(HIPCC) $(ROCM_CFLAGS) -c -o $@ $< | |
| tests/cuda_long_context_smoke: tests/cuda_long_context_smoke.o ds4_cuda.o $(MMQ_OBJS) | |
| $(NVCC) $(NVCCFLAGS) -o $@ $^ $(CUDA_LDLIBS) | |
| tests/test_layer_pack.o: tests/test_layer_pack.c ds4_layer_pack.h | |
| $(CC) $(CFLAGS) -I src -c -o $@ $< | |
| tests/test_layer_pack: tests/test_layer_pack.o ds4_layer_pack.o | |
| $(CC) $(CFLAGS) -o $@ $^ $(LDLIBS) | |
| tests/test_gpu_args.o: tests/test_gpu_args.c ds4_gpu_args.h ds4_gpu_mgpu.h | |
| $(CC) $(CFLAGS) -I src -DDS4_NO_GPU -c -o $@ $< | |
| tests/test_gpu_args: tests/test_gpu_args.o ds4_gpu_args_cpu.o | |
| $(CC) $(CFLAGS) -o $@ $^ $(LDLIBS) | |
| ds4_cpu_test_hooks.o: ds4.c ds4.h ds4_gpu.h ds4_gpu_mgpu.h ds4_layer_pack.h | |
| $(CC) $(CFLAGS) -Wno-unused-function -DDS4_NO_GPU -DDS4_TEST_HOOKS -c -o $@ $< | |
| tests/test_engine_mgpu_placement.o: tests/test_engine_mgpu_placement.c ds4.h ds4_gpu_mgpu.h ds4_layer_pack.h | |
| $(CC) $(CFLAGS) -I src -c -o $@ $< | |
| tests/test_engine_mgpu_placement: tests/test_engine_mgpu_placement.o ds4_cpu_test_hooks.o ds4_distributed.o ds4_tp.o ds4_ssd.o ds4_layer_pack.o | |
| $(CC) $(CFLAGS) -o $@ $^ $(LDLIBS) | |
| ifneq ($(UNAME_S),Darwin) | |
| tests/test_gpu_xdev.o: tests/test_gpu_xdev.c ds4_gpu.h ds4_gpu_mgpu.h | |
| $(CC) $(CFLAGS) -I src -I$(CUDA_HOME)/include -c -o $@ $< | |
| tests/test_gpu_xdev: tests/test_gpu_xdev.o ds4_cuda.o $(MMQ_OBJS) | |
| $(NVCC) $(NVCCFLAGS) -o $@ $^ $(CUDA_LDLIBS) | |
| tests/test_gpu_model_cache.o: tests/test_gpu_model_cache.c ds4_gpu.h | |
| $(CC) $(CFLAGS) -I src -I$(CUDA_HOME)/include -c -o $@ $< | |
| tests/test_gpu_model_cache: tests/test_gpu_model_cache.o ds4_cuda.o $(MMQ_OBJS) | |
| $(NVCC) $(NVCCFLAGS) -o $@ $^ $(CUDA_LDLIBS) | |
| tests/test_gpu_lookup_cache_strict.o: tests/test_gpu_lookup_cache_strict.c ds4_gpu.h ds4_gpu_mgpu.h | |
| $(CC) $(CFLAGS) -I src -I$(CUDA_HOME)/include -c -o $@ $< | |
| tests/test_gpu_lookup_cache_strict: tests/test_gpu_lookup_cache_strict.o ds4_cuda.o $(MMQ_OBJS) | |
| $(NVCC) $(NVCCFLAGS) -o $@ $^ $(CUDA_LDLIBS) | |
| ds4_cuda_test_hooks.o: ds4.c ds4.h ds4_gpu.h ds4_gpu_mgpu.h ds4_layer_pack.h | |
| $(CC) $(CFLAGS) -Wno-unused-function -DDS4_TEST_HOOKS -I$(CUDA_HOME)/include -c -o $@ $< | |
| tests/test_engine_mgpu_refusal.o: tests/test_engine_mgpu_refusal.c ds4.h ds4_gpu_mgpu.h | |
| $(CC) $(CFLAGS) -I src -I$(CUDA_HOME)/include -c -o $@ $< | |
| tests/test_engine_mgpu_refusal: tests/test_engine_mgpu_refusal.o ds4_gpu_args.o ds4_kvstore.o rax.o $(CORE_OBJS) | |
| $(NVCC) $(NVCCFLAGS) -o $@ $^ $(CUDA_LDLIBS) | |
| tests/test_engine_mgpu_runtime.o: tests/test_engine_mgpu_runtime.c ds4.h ds4_gpu_mgpu.h | |
| $(CC) $(CFLAGS) -DDS4_TEST_HOOKS -I src -I$(CUDA_HOME)/include -c -o $@ $< | |
| tests/test_engine_mgpu_runtime: tests/test_engine_mgpu_runtime.o ds4_cuda_test_hooks.o ds4_gpu_args.o ds4_kvstore.o rax.o ds4_distributed.o ds4_tp.o ds4_ssd.o ds4_cuda.o ds4_layer_pack.o $(MMQ_OBJS) | |
| $(NVCC) $(NVCCFLAGS) -o $@ $^ $(CUDA_LDLIBS) | |
| tests/test_engine_correctness.o: tests/test_engine_correctness.c ds4.h ds4_gpu_mgpu.h | |
| $(CC) $(CFLAGS) -I src -I$(CUDA_HOME)/include -c -o $@ $< | |
| tests/test_engine_correctness: tests/test_engine_correctness.o ds4_gpu_args.o ds4_kvstore.o rax.o $(CORE_OBJS) | |
| $(NVCC) $(NVCCFLAGS) -o $@ $^ $(CUDA_LDLIBS) | |
| tests/test_sampling.o: tests/test_sampling.c ds4.h | |
| $(CC) $(CFLAGS) -DDS4_TEST_HOOKS -I src -c -o $@ $< | |
| tests/test_sampling: tests/test_sampling.o ds4_cuda_test_hooks.o ds4_gpu_args.o ds4_kvstore.o rax.o ds4_distributed.o ds4_tp.o ds4_ssd.o ds4_cuda.o ds4_layer_pack.o $(MMQ_OBJS) | |
| $(NVCC) $(NVCCFLAGS) -o $@ $^ $(CUDA_LDLIBS) | |
| tests/test_cuda_session_batch.o: tests/test_cuda_session_batch.c ds4.h ds4_gpu_args.h ds4_gpu_mgpu.h | |
| $(CC) $(CFLAGS) -I src -I$(CUDA_HOME)/include -c -o $@ $< | |
| tests/test_cuda_session_batch: tests/test_cuda_session_batch.o ds4_gpu_args.o ds4_kvstore.o rax.o $(CORE_OBJS) | |
| $(NVCC) $(NVCCFLAGS) -o $@ $^ $(CUDA_LDLIBS) | |
| test-cuda-session-batch: tests/test_cuda_session_batch | |
| DS4_TEST_MODEL="$(DS4_TEST_MODEL)" ./tests/test_cuda_session_batch | |
| tests/test_cuda_mixed_batch.o: tests/test_cuda_mixed_batch.c ds4.h ds4_gpu_args.h ds4_gpu_mgpu.h | |
| $(CC) $(CFLAGS) -DDS4_TEST_HOOKS -I src -I$(CUDA_HOME)/include -c -o $@ $< | |
| tests/test_cuda_mixed_batch: tests/test_cuda_mixed_batch.o ds4_cuda_test_hooks.o ds4_gpu_args.o ds4_kvstore.o rax.o ds4_distributed.o ds4_tp.o ds4_ssd.o ds4_cuda.o ds4_layer_pack.o $(MMQ_OBJS) | |
| $(NVCC) $(NVCCFLAGS) -o $@ $^ $(CUDA_LDLIBS) | |
| test-cuda-mixed-batch: tests/test_cuda_mixed_batch | |
| DS4_TEST_MODEL="$(DS4_TEST_MODEL)" ./tests/test_cuda_mixed_batch | |
| endif | |
| ds4_test: ds4_test.o ds4_help.o ds4_kvstore.o rax.o $(CORE_OBJS) | |
| ifeq ($(UNAME_S),Darwin) | |
| $(CC) $(CFLAGS) -o $@ ds4_test.o ds4_help.o ds4_kvstore.o rax.o $(CORE_OBJS) $(METAL_LDLIBS) | |
| else | |
| $(NVCC) $(NVCCFLAGS) -o $@ ds4_test.o ds4_help.o ds4_kvstore.o rax.o $(CORE_OBJS) $(CUDA_LDLIBS) | |
| endif | |
| ds4_agent_test: ds4_agent_test.o ds4_help.o ds4_web.o ds4_kvstore.o linenoise.o $(CORE_OBJS) | |
| ifeq ($(UNAME_S),Darwin) | |
| $(CC) $(CFLAGS) -o $@ ds4_agent_test.o ds4_help.o ds4_web.o ds4_kvstore.o linenoise.o $(CORE_OBJS) $(METAL_LDLIBS) | |
| else | |
| $(NVCC) $(NVCCFLAGS) -o $@ ds4_agent_test.o ds4_help.o ds4_web.o ds4_kvstore.o linenoise.o $(CORE_OBJS) $(CUDA_LDLIBS) | |
| endif | |
| test: ds4_test ds4_agent_test ds4-eval q4k-dot-test mxfp4-dot-test \ | |
| tests/test_layer_pack tests/test_engine_mgpu_placement tests/test_gpu_args \ | |
| $(SAMPLING_TEST) ds4 ds4-server ds4-bench ds4-agent | |
| ./ds4-eval --self-test-extractors | |
| ./ds4_agent_test | |
| ./ds4_test | |
| ./tests/test_layer_pack | |
| ./tests/test_engine_mgpu_placement | |
| ./tests/test_gpu_args | |
| ./tests/test_gpu_args_cli.sh | |
| ifneq ($(UNAME_S),Darwin) | |
| ./tests/test_sampling | |
| # Run the Strix Halo ROCm smoke test only when building the ROCm backend. | |
| ifeq ($(DS4_ROCM_BUILD),1) | |
| $(MAKE) rocm-smoke | |
| endif | |
| endif | |
| dspark-acceptance: ds4 | |
| DS4_DSPARK_MODEL="$(DS4_DSPARK_MODEL)" \ | |
| DS4_DSPARK_SUPPORT="$(DS4_DSPARK_SUPPORT)" \ | |
| sh tests/dspark_acceptance_fixture.sh | |
| dspark-verify-depth: ds4_test | |
| @if [ ! -f "$(DS4_TEST_MODEL)" ]; then \ | |
| echo "dspark-verify-depth: skipped, missing model $(DS4_TEST_MODEL)"; \ | |
| elif [ ! -f "$(DS4_DSPARK_SUPPORT)" ]; then \ | |
| echo "dspark-verify-depth: skipped, missing DSpark support $(DS4_DSPARK_SUPPORT)"; \ | |
| echo "dspark-verify-depth: run ./download_model.sh ds4f-dspark or set DS4_DSPARK_SUPPORT=FILE"; \ | |
| else \ | |
| DS4_TEST_MODEL="$(DS4_TEST_MODEL)" DS4_TEST_DSPARK="$(DS4_DSPARK_SUPPORT)" ./ds4_test --dspark-verify-depth; \ | |
| fi | |
| mtp-verify-depth: ds4_test | |
| @if [ ! -f "$(DS4_TEST_MODEL)" ]; then \ | |
| echo "mtp-verify-depth: skipped, missing model $(DS4_TEST_MODEL)"; \ | |
| elif [ ! -f "$(DS4_TEST_MTP)" ]; then \ | |
| echo "mtp-verify-depth: skipped, missing MTP support $(DS4_TEST_MTP)"; \ | |
| echo "mtp-verify-depth: set DS4_TEST_MTP=FILE to a legacy support GGUF"; \ | |
| else \ | |
| DS4_TEST_MODEL="$(DS4_TEST_MODEL)" DS4_TEST_MTP="$(DS4_TEST_MTP)" ./ds4_test --mtp-verify-depth; \ | |
| fi | |
| q4k-dot-test: tests/test_q4k_dot.c | |
| $(CC) -O2 -Wall -Wextra -std=c99 -o tests/test_q4k_dot tests/test_q4k_dot.c -lm -pthread | |
| ./tests/test_q4k_dot | |
| mxfp4-dot-test: tests/test_mxfp4_dot.c | |
| $(CC) -O2 -Wall -Wextra -std=c99 -o tests/test_mxfp4_dot tests/test_mxfp4_dot.c -lm | |
| ./tests/test_mxfp4_dot | |
| clean: | |
| rm -f ds4 ds4-server ds4-bench ds4-eval ds4-agent ds4_cpu ds4_native ds4_server_test ds4_test ds4_agent_test gguf-tools/quality-testing/score_official gguf-tools/quality-testing/score_official.o speed-bench/metal_decode_schedule_bench speed-bench/metal_prefill_variant_bench speed-bench/*.o tests/test_q4k_dot tests/test_mxfp4_dot tests/test_mxfp4_metal tests/test_mxfp4_cuda tests/test_metal_session_batch tests/test_gpu_xdev tests/test_gpu_model_cache tests/test_gpu_lookup_cache_strict tests/test_engine_mgpu_refusal tests/test_engine_mgpu_runtime tests/test_engine_correctness tests/test_sampling tests/test_cuda_session_batch tests/test_cuda_mixed_batch tests/*.o *.o tests/cuda_long_context_smoke tests/cuda_long_context_smoke.o \ | |
| tests/rocm_smoke tests/rocm_smoke.o \ | |
| tests/rocm_bench_quick tests/rocm_bench_quick.o | |