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
17 changes: 14 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@ 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_HOST_CFLAGS ?= -fPIC
ROCM_CFLAGS ?= -O3 -ffast-math -g -fno-finite-math-only -pthread -D__HIP_PLATFORM_AMD__ -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

.PHONY: all help clean test test-metal-session-batch 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-rocm 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)
all: ds4 ds4-server ds4-bench ds4-eval ds4-agent
Expand Down Expand Up @@ -116,6 +117,7 @@ help:
@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 test-mxfp4-rocm Build and run the synthetic ROCm MXFP4 MoE test"
@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"
Expand All @@ -139,7 +141,7 @@ cuda:
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" \
CFLAGS="$(CFLAGS) $(ROCM_HOST_CFLAGS) -DDS4_ROCM_BUILD" \
DS4_LINK="$(HIPCC) $(ROCM_CFLAGS)" \
DS4_LINK_LIBS="$(ROCM_LDLIBS)"

Expand Down Expand Up @@ -258,6 +260,15 @@ ds4_cuda.o: ds4_cuda.cu ds4_gpu.h ds4_gpu_mgpu.h ds4_iq2_tables_cuda.inc
ds4_rocm.o: ds4_rocm.cu ds4_gpu.h ds4_iq2_tables_cuda.inc $(ROCM_SRCS)
$(HIPCC) $(ROCM_CFLAGS) -c -o $@ ds4_rocm.cu

tests/test_mxfp4_rocm.o: tests/test_mxfp4_rocm.c ds4_gpu.h
$(CC) $(filter-out -ffast-math,$(CFLAGS)) $(ROCM_HOST_CFLAGS) -DDS4_ROCM_BUILD -I. -c -o $@ $<

tests/test_mxfp4_rocm: tests/test_mxfp4_rocm.o ds4_rocm.o
$(HIPCC) $(ROCM_CFLAGS) -o $@ $^ $(ROCM_LDLIBS)

test-mxfp4-rocm: tests/test_mxfp4_rocm
./tests/test_mxfp4_rocm

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_compat.cu

Expand Down Expand Up @@ -415,4 +426,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 tests/test_q4k_dot tests/test_mxfp4_dot tests/test_mxfp4_metal 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 tests/test_q4k_dot tests/test_mxfp4_dot tests/test_mxfp4_metal tests/test_mxfp4_rocm 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
3 changes: 3 additions & 0 deletions QA_BEFORE_RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ a substitute for CUDA or Metal release testing.
- Build:
`make clean && make strix-halo`.
- Require the ROCm build to complete without compiler warnings.
- After MXFP4 or ROCm routed-MoE changes, run `make test-mxfp4-rocm`. Require
zero `failures` for both `mid` and `out` at 1, 3, 32, 128, and 512 tokens,
followed by `MXFP4 ROCm routed MoE: PASS`.
- Use the q2 Flash imatrix GGUF for release smoke tests:
`DeepSeek-V4-Flash-IQ2XXS-w2Q2K-AProjQ8-SExpQ8-OutQ8-chat-v2-imatrix.gguf`.
- Do not use the mixed q2-q4 or Q4 Flash GGUFs for routine Strix Halo QA yet.
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,12 @@ To build an initial mental model, here are the high level concepts:
4. Each worker keeps its slice of the KV cache.
5. Communication is worker-to-worker, there is no need to use the coordinator as relay, so if your coordinator is `A`, and you make a request, activations will flow in `A -> B -> C -> back to A`.

The resident ROCm MXFP4 routed-expert path supports the same pipeline mode. A
tested two-host Strix Halo split uses `--layers 0:21` on the coordinator and
`--layers 22:output` on the worker. This is a capacity configuration for a
model that does not fit on one 128 GB system; it does not add ROCm SSD
streaming support for Flash.

### How it works and how to configure it

The prefill path is pipelined (this is why it can go faster than in a single machine).
Expand Down
10 changes: 10 additions & 0 deletions STRIXHALO.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ make strix-halo -j"$(nproc)"

`make rocm` is an alias for `make strix-halo`.

After changes to the ROCm MXFP4 or routed-MoE kernels, run the standalone
CPU-oracle regression:

```sh
make test-mxfp4-rocm
```

This test does not require a full model GGUF. It covers resident decode and
batched routed-MoE execution at 1, 3, 32, 128, and 512 tokens.

## 5. Use the right GGUF

Use the standard IQ2XXS/Q2K/Q8 imatrix GGUF:
Expand Down
3 changes: 2 additions & 1 deletion ds4.c
Original file line number Diff line number Diff line change
Expand Up @@ -49606,7 +49606,8 @@ int ds4_engine_routed_quant_bits(ds4_engine *e) {
for (uint32_t il = 0; il < DS4_N_LAYER; il++) {
const ds4_tensor *gate = e->weights.layer[il].ffn_gate_exps;
if (!gate) continue;
return gate->type == DS4_TENSOR_Q4_K ? 4 : 2;
return (gate->type == DS4_TENSOR_Q4_K ||
gate->type == DS4_TENSOR_MXFP4) ? 4 : 2;
}
return 0;
}
Expand Down
14 changes: 14 additions & 0 deletions ds4_rocm.cu
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,20 @@ typedef struct {
uint16_t qs[CUDA_QK_K / 8];
} cuda_block_iq2_xxs;

typedef struct {
uint8_t e;
uint8_t qs[16];
} cuda_block_mxfp4;

static_assert(sizeof(cuda_block_mxfp4) == 17, "cuda_block_mxfp4 must match the GGUF MXFP4 block layout");

/* Twice the MXFP4 values so each 32-value sub-block can use signed-int8
* dp4a; the factor of 1/2 is folded into the sub-block scale. */
__device__ __constant__ static const int8_t cuda_mxfp4_values_x2[16] = {
0, 1, 2, 3, 4, 6, 8, 12,
0, -1, -2, -3, -4, -6, -8, -12,
};

#include "ds4_iq2_tables_cuda.inc"

#include "rocm/ds4_rocm_runtime.cuh"
Expand Down
Loading