Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
/ds4flash.gguf
/TODO.md
/gguf/
/.deps/
/core
/core.*
/tests/test_engine_mgpu_placement
Expand All @@ -29,7 +30,9 @@
/tests/test_mxfp4_dot
/tests/test_mxfp4_metal
/tests/test_q4k_dot
/cuda/mmq/test/test_q8_aligned_rows
/tests/test_sampling
/tests/test_tp_protocol
*.o
*.dSYM/
__pycache__/
Expand Down
58 changes: 39 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,18 @@ NVCC_ARCH_FLAGS := -arch=$(CUDA_ARCH)
endif
endif
NVCCFLAGS ?= -O3 -g -lineinfo --use_fast_math $(NVCC_ARCH_FLAGS) -Xcompiler $(NATIVE_CPU_FLAG) -Xcompiler -pthread
# NCCL is optional at build and run time. A repo-local extraction keeps
# cluster development unprivileged; distro installations are detected too.
NCCL_INCLUDE_DIR ?= $(firstword $(dir $(wildcard .deps/nccl/usr/include/nccl.h /usr/include/nccl.h /usr/local/include/nccl.h)))
ifneq ($(strip $(NCCL_INCLUDE_DIR)),)
NVCCFLAGS += -DDS4_CUDA_HAVE_NCCL=1 -I$(NCCL_INCLUDE_DIR)
endif
# 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
CUDA_LDLIBS ?= -lm -ldl -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__ -Wno-unused-command-line-argument --offload-arch=$(ROCM_ARCH)
Expand All @@ -62,7 +68,7 @@ DS4_LINK_LIBS ?= $(CUDA_LDLIBS)
METAL_LDLIBS := $(LDLIBS)
endif

.PHONY: all help clean test test-metal-session-batch test-mxfp4-cuda test-cuda-session-batch test-cuda-mixed-batch dspark-acceptance dspark-verify-depth mtp-verify-depth cpu cuda cuda-spark cuda-generic cuda-regression strix-halo rocm
.PHONY: all help clean test test-metal-session-batch test-mxfp4-cuda test-q8-aligned-rows test-cuda-session-batch test-cuda-mixed-batch dspark-acceptance dspark-verify-depth mtp-verify-depth cpu cuda cuda-spark cuda-generic cuda-regression strix-halo rocm

ifeq ($(UNAME_S),Darwin)
.PHONY: metal-decode-schedule-bench metal-prefill-variant-bench check-mxfp4-half-lut
Expand Down Expand Up @@ -97,7 +103,7 @@ ds4-eval: ds4_eval.o ds4_help.o $(CORE_OBJS)
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
gguf-tools/quality-testing/score_official: gguf-tools/quality-testing/score_official.c ds4.h ds4_distributed.h ds4_tp.h $(CORE_OBJS) rax.o ds4_gpu_args.o
$(CC) $(QUALITY_CFLAGS) -I. -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
Expand Down Expand Up @@ -200,7 +206,7 @@ ds4-eval: ds4_eval.o ds4_help.o $(CORE_OBJS)
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
gguf-tools/quality-testing/score_official.o: gguf-tools/quality-testing/score_official.c ds4.h ds4_distributed.h ds4_tp.h
$(CC) $(filter-out -ffast-math,$(QUALITY_CFLAGS)) -I. -c -o $@ $<

gguf-tools/quality-testing/score_official: gguf-tools/quality-testing/score_official.o $(CORE_OBJS) rax.o ds4_gpu_args.o
Expand All @@ -221,15 +227,21 @@ tests/test_mxfp4_cuda: tests/test_mxfp4_cuda.cu $(MMQ_OBJS)

test-mxfp4-cuda: tests/test_mxfp4_cuda
./tests/test_mxfp4_cuda

cuda/mmq/test/test_q8_aligned_rows: cuda/mmq/test/test_q8_aligned_rows.cu cuda/mmq/ds4_mmq.h $(MMQ_OBJS)
$(NVCC) $(NVCCFLAGS) -std=c++17 $(MMQ_INCLUDES) -o $@ $< $(MMQ_OBJS) $(CUDA_LDLIBS)

test-q8-aligned-rows: cuda/mmq/test/test_q8_aligned_rows
./cuda/mmq/test/test_q8_aligned_rows
endif

ds4.o: ds4.c ds4.h ds4_ssd.h ds4_distributed.h ds4_gpu.h
ds4.o: ds4.c ds4.h ds4_ssd.h ds4_distributed.h ds4_tp.h ds4_gpu.h
$(CC) $(CFLAGS) -c -o $@ ds4.c

ds4_ssd.o: ds4_ssd.c ds4_ssd.h
$(CC) $(CFLAGS) -c -o $@ ds4_ssd.c

ds4_cli.o: ds4_cli.c ds4.h ds4_ssd.h ds4_distributed.h ds4_help.h linenoise.h
ds4_cli.o: ds4_cli.c ds4.h ds4_ssd.h ds4_distributed.h ds4_tp.h ds4_help.h linenoise.h
$(CC) $(CFLAGS) -c -o $@ ds4_cli.c

ds4_distributed.o: ds4_distributed.c ds4_distributed.h ds4.h ds4_ssd.h
Expand All @@ -244,16 +256,16 @@ ds4_help.o: ds4_help.c ds4_help.h
ds4_gpu_args.o: ds4_gpu_args.c ds4_gpu_args.h ds4_gpu_mgpu.h
$(CC) $(CFLAGS) -c -o $@ ds4_gpu_args.c

ds4_server.o: ds4_server.c ds4.h ds4_ssd.h ds4_distributed.h ds4_help.h ds4_kvstore.h rax.h
ds4_server.o: ds4_server.c ds4.h ds4_ssd.h ds4_distributed.h ds4_tp.h ds4_help.h ds4_kvstore.h rax.h
$(CC) $(CFLAGS) -c -o $@ ds4_server.c

ds4_bench.o: ds4_bench.c ds4.h ds4_ssd.h ds4_distributed.h ds4_help.h
ds4_bench.o: ds4_bench.c ds4.h ds4_ssd.h ds4_distributed.h ds4_tp.h ds4_help.h
$(CC) $(CFLAGS) -c -o $@ ds4_bench.c

ds4_eval.o: ds4_eval.c ds4.h ds4_ssd.h ds4_distributed.h ds4_help.h
ds4_eval.o: ds4_eval.c ds4.h ds4_ssd.h ds4_distributed.h ds4_tp.h ds4_help.h
$(CC) $(CFLAGS) -c -o $@ ds4_eval.c

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
ds4_agent.o: ds4_agent.c ds4.h ds4_ssd.h ds4_distributed.h ds4_tp.h ds4_help.h ds4_kvstore.h ds4_web.h linenoise.h
$(CC) $(CFLAGS) -c -o $@ ds4_agent.c

ds4_web.o: ds4_web.c ds4_web.h
Expand All @@ -262,10 +274,10 @@ ds4_web.o: ds4_web.c ds4_web.h
ds4_kvstore.o: ds4_kvstore.c ds4_kvstore.h ds4.h ds4_ssd.h
$(CC) $(CFLAGS) -c -o $@ ds4_kvstore.c

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
ds4_test.o: tests/ds4_test.c ds4_server.c ds4.h ds4_ssd.h ds4_distributed.h ds4_tp.h ds4_help.h ds4_kvstore.h rax.h
$(CC) $(CFLAGS) -Wno-unused-function -c -o $@ tests/ds4_test.c

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
ds4_agent_test.o: tests/ds4_agent_test.c ds4_agent.c ds4.h ds4_ssd.h ds4_distributed.h ds4_tp.h ds4_help.h ds4_kvstore.h ds4_web.h linenoise.h
$(CC) $(CFLAGS) -Wno-unused-function -c -o $@ tests/ds4_agent_test.c

tests/cuda_long_context_smoke.o: tests/cuda_long_context_smoke.c ds4_gpu.h
Expand All @@ -277,25 +289,25 @@ rax.o: rax.c rax.h rax_malloc.h
linenoise.o: linenoise.c linenoise.h
$(CC) $(CFLAGS) -c -o $@ linenoise.c

ds4_cpu.o: ds4.c ds4.h ds4_ssd.h ds4_distributed.h ds4_gpu.h
ds4_cpu.o: ds4.c ds4.h ds4_ssd.h ds4_distributed.h ds4_tp.h ds4_gpu.h
$(CC) $(CFLAGS) -Wno-unused-function -DDS4_NO_GPU -c -o $@ ds4.c

ds4_cli_cpu.o: ds4_cli.c ds4.h ds4_ssd.h ds4_distributed.h ds4_help.h linenoise.h
ds4_cli_cpu.o: ds4_cli.c ds4.h ds4_ssd.h ds4_distributed.h ds4_tp.h ds4_help.h linenoise.h
$(CC) $(CFLAGS) -DDS4_NO_GPU -c -o $@ ds4_cli.c

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_gpu_args.c

ds4_server_cpu.o: ds4_server.c ds4.h ds4_ssd.h ds4_distributed.h ds4_help.h ds4_kvstore.h rax.h
ds4_server_cpu.o: ds4_server.c ds4.h ds4_ssd.h ds4_distributed.h ds4_tp.h ds4_help.h ds4_kvstore.h rax.h
$(CC) $(CFLAGS) -DDS4_NO_GPU -c -o $@ ds4_server.c

ds4_bench_cpu.o: ds4_bench.c ds4.h ds4_ssd.h ds4_distributed.h ds4_help.h
ds4_bench_cpu.o: ds4_bench.c ds4.h ds4_ssd.h ds4_distributed.h ds4_tp.h ds4_help.h
$(CC) $(CFLAGS) -DDS4_NO_GPU -c -o $@ ds4_bench.c

ds4_eval_cpu.o: ds4_eval.c ds4.h ds4_ssd.h ds4_distributed.h ds4_help.h
ds4_eval_cpu.o: ds4_eval.c ds4.h ds4_ssd.h ds4_distributed.h ds4_tp.h ds4_help.h
$(CC) $(CFLAGS) -DDS4_NO_GPU -c -o $@ ds4_eval.c

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
ds4_agent_cpu.o: ds4_agent.c ds4.h ds4_ssd.h ds4_distributed.h ds4_tp.h ds4_help.h ds4_kvstore.h ds4_web.h linenoise.h
$(CC) $(CFLAGS) -DDS4_NO_GPU -c -o $@ ds4_agent.c

ds4_metal.o: ds4_metal.m ds4_gpu.h $(METAL_SRCS)
Expand Down Expand Up @@ -352,6 +364,12 @@ tests/test_gpu_args.o: tests/test_gpu_args.c ds4_gpu_args.h ds4_gpu_mgpu.h
tests/test_gpu_args: tests/test_gpu_args.o ds4_gpu_args_cpu.o
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS)

tests/test_tp_protocol.o: tests/test_tp_protocol.c ds4_tp.h ds4.h
$(CC) $(CFLAGS) -I. -c -o $@ $<

tests/test_tp_protocol: tests/test_tp_protocol.o $(CPU_CORE_OBJS)
$(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 $@ ds4.c

Expand Down Expand Up @@ -442,13 +460,15 @@ 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 \
tests/test_tp_protocol gguf-tools/quality-testing/score_official \
$(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_tp_protocol
./tests/test_gpu_args_cli.sh
ifneq ($(UNAME_S),Darwin)
./tests/test_sampling
Expand Down Expand Up @@ -488,4 +508,4 @@ mxfp4-dot-test: tests/test_mxfp4_dot.c
./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
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/test_tp_protocol tests/*.o *.o tests/cuda_long_context_smoke tests/cuda_long_context_smoke.o cuda/mmq/test/test_q8_aligned_rows
57 changes: 57 additions & 0 deletions QA_BEFORE_RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,15 @@ top-logprob slices, so do not replace them with one sampled chat answer.
about `0.800` unless the quantization changed deliberately.
- Run the 100-case DeepSeek V4 PRO fixture for every released PRO GGUF:
`gguf-tools/quality-testing/score_official /path/to/deepseek-v4-pro.gguf gguf-tools/quality-testing/data/pro/manifest.tsv /tmp/pro.tsv 4096`.
- After network EP/TP graph, collective, ownership, or numerical-path changes,
run the matching 100-case fixture through `score_official` with
`--role coordinator`, the selected `--expert-parallel` or
`--tensor-parallel` mode, and the real rank count. Score the exact/default
path and every proposed faster path into separate TSVs, then compare them
with `compare_scores.py`. A clear NLL regression, first-token-match drop, or
material API top-1/pair-order drop blocks making the faster path the default.
Set path-selecting environment variables identically on every rank and keep
both raw summaries in the QA record.
- For SSD streaming, run the same official-continuation scorer once with full
residency and once with `--ssd-streaming` for the release model. The summary
and API agreement should stay in the same quality band.
Expand Down Expand Up @@ -453,6 +462,54 @@ release-ready without this pass.
- Verify that any CUDA-only warning fixes are also clean on macOS and do not
change Metal behavior.

### CUDA network EP/TP

Run these gates when NCCL bootstrap, ownership mapping, collective MoE,
DeepSeek/GLM TP, or the shared frontend TP options change:

- Build the same warning-free commit on every rank and verify the complete GGUF
has the same size and checksum on every host. Start at `--ctx 512`; DGX Spark
uses one unified CPU/GPU memory pool, and an overcommitted two-rank experiment
can make a machine require a manual reboot.
- Run `tests/test_tp_protocol` locally, then complete short two- and four-rank
`--expert-parallel` and `--tensor-parallel` prompts where the guarded model
plan fits. For an oversized two-rank GLM plan, verify preflight rejection
instead of disabling the memory guard. Every worker must report the intended
rank/world and exit after the coordinator instead of reconnecting
indefinitely.
- For DeepSeek Flash Q2, compare a greedy single-rank raw-expert trace with
four-rank EP and TP over a prompt long enough to exercise batch prefill plus
at least 32 decode tokens. Set `DS4_CUDA_MOE_NO_IQ2_ALIGNED=1` and
`DS4_CUDA_MOE_NO_Q2K_ALIGNED=1` on the single-rank reference. EP and TP model
output must be byte-identical to that reference without
`DS4_TP_ORDERED_REDUCE`; a matching first token alone is insufficient.
- When shard-local DeepSeek artifacts or aligned dense row slicing changes,
run `make test-q8-aligned-rows CUDA_ARCH=sm_121` on a Spark. Confirm every
rank reports the same owned expert count, `expert raw residency replaced`,
and the replicated aligned-dense bytes in its guarded memory plan. Repeat
the parity trace once with `--expert-parallel` and once with
`--tensor-parallel`; do not use the replication diagnostic environment
variables to make the default TP gate pass.
- If `DS4_CUDA_TP_FAST_ALIGNED_EXPERTS=1` changes, set it on every rank and
repeat matching EP/TP speed sweeps plus the four-case, 4,096-token DeepSeek
evaluation. This opt-in path may drift from the raw-reference token stream,
but EP and TP must agree with each other, keep finite output, and stay in the
default path's quality band. It does not replace the byte-identical default
parity gate above.
- For GLM 5.2, compare four-rank EP and TP greedy traces over a prompt long
enough to exercise batch prefill plus at least 32 decode tokens. The complete
`--dump-logprobs` JSON, including selected tokens and top-logprob entries,
must be byte-identical. GLM TP must not require ordered reduction to pass.
- Run matching single-rank (where it fits), four-rank EP, and four-rank TP
`ds4-bench` sweeps and preserve the CSVs. Record prefill and generation
separately: both supported model paths intentionally replicate dense prefill
kernels for numerical parity, while model-specific decode work is
partitioned.
- Exercise one real request through `ds4-server`, one non-interactive
`ds4-agent` prompt, and one `ds4-eval` case with network workers. Confirm all
mirrored sessions are destroyed and no rank remains running after rank 0
exits.

## 9. ROCm / Strix Halo

Use the Strix Halo Framework Desktop via the VPN hostname `strixhalo`
Expand Down
Loading