forked from antirez/ds4
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMakefile
More file actions
1032 lines (849 loc) · 37.3 KB
/
Copy pathMakefile
File metadata and controls
1032 lines (849 loc) · 37.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
CC ?= cc
.DEFAULT_GOAL := all
UNAME_S := $(shell uname -s)
UNAME_M := $(shell uname -m)
ifeq ($(UNAME_S),Darwin)
NATIVE_CPU_FLAG ?= -mcpu=native
else
NATIVE_CPU_FLAG ?= -march=native
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
# Qwen's stable softmax rejects non-finite logits; retain that branch while
# keeping the remaining fast-math optimizations used by the scalar CPU path.
QWEN_CFLAGS ?= -fno-finite-math-only
DEPFLAGS ?= -MMD -MP
BUILD_GIT_SHA ?= $(shell git rev-parse --short=12 HEAD 2>/dev/null || echo unknown)
BUILD_GIT_SUFFIX ?= $(shell test -z "$$(git status --porcelain --untracked-files=normal 2>/dev/null)" || printf '%s' -dirty)
CFLAGS += -DDS4_BUILD_GIT_SHA=\"$(BUILD_GIT_SHA)$(BUILD_GIT_SUFFIX)\"
LDLIBS ?= -lm -pthread
METAL_SRCS := $(wildcard metal/*.metal)
BUILD_ROOT ?= build
HEBRUS_PROGRAMS := hebrus hebrus-server hebrus-bench hebrus-eval hebrus-agent
DS4_PROGRAMS := ds4 ds4-server ds4-bench ds4-eval ds4-agent
PROGRAMS := $(HEBRUS_PROGRAMS) $(DS4_PROGRAMS)
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
INSTALL ?= install
INSTALL_MODE ?= 0755
INSTALL_DEST_BINDIR = $(DESTDIR)$(BINDIR)
INSTALL_SOURCE_PROGRAMS = $(addprefix $(INSTALL_SOURCE_BINDIR)/,$(HEBRUS_PROGRAMS))
SERVER_ALIAS_EXPECTED_BACKEND ?= metal
SERVER_ALIAS_EXPECTED_BUILD_SHA ?= $(BUILD_GIT_SHA)
SERVER_ALIAS_PORT ?= 0
.PHONY: all help clean test model-free-test premerge context-audit doc-links \
brand-boundary-audit brand-boundary-test brand-asset-test \
release-contract release-contract-test \
imatrix-dataset-check prompt-fixture-check cpu FORCE \
metal build-isolation-test q4k-dot-test qwen-metadata-test \
qwen-reference-test qwen-unicode-test qwen-tokenizer-test \
qwen-expert-group-test expert-store-test metal-ssd-profile-test \
download-model-test capabilities-test command-alias-test \
visible-identity-test server-alias-model-unit-test \
server-alias-model-test \
install uninstall install-test $(PROGRAMS) \
ds4_test ds4_agent_test
download-model-test: tests/test_download_model.sh download_model.sh \
docs/contracts/qwen-release.json
sh tests/test_download_model.sh
release-contract: tools/qwen_release_contract.py \
docs/contracts/qwen-release.json README.md CONTRIBUTING.md \
QA_BEFORE_RELEASES.md docs/contracts/RUNTIME_SUPPORT.md \
docs/qwen-expert-major-store.md download_model.sh \
tests/test_download_model.sh
python3 tools/qwen_release_contract.py
release-contract-test: release-contract tools/qwen_release_contract.py \
tests/test_qwen_release_contract.py
python3 tests/test_qwen_release_contract.py
brand-boundary-audit: tools/brand_boundary_audit.py tools/brand_boundary.json
python3 tools/brand_boundary_audit.py --check
brand-boundary-test: tools/brand_boundary_audit.py tests/test_brand_boundary_audit.py
python3 tests/test_brand_boundary_audit.py
brand-asset-test: tests/test_brand_asset.py docs/media/hebrus-typographic.png README.md
python3 tests/test_brand_asset.py
ifeq ($(UNAME_S),Darwin)
# A build profile owns every object and binary it produces. In particular, a
# CPU build can never satisfy a Metal prerequisite (or replace a Metal binary).
METAL_PROFILE := metal-$(UNAME_M)
CPU_PROFILE := cpu-$(UNAME_M)
METAL_OBJDIR := $(BUILD_ROOT)/$(METAL_PROFILE)/obj
METAL_BINDIR := $(BUILD_ROOT)/$(METAL_PROFILE)/bin
CPU_OBJDIR := $(BUILD_ROOT)/$(CPU_PROFILE)/obj
CPU_BINDIR := $(BUILD_ROOT)/$(CPU_PROFILE)/bin
INSTALL_SOURCE_BINDIR := $(METAL_BINDIR)
INSTALL_BACKEND := metal
METAL_LDLIBS := $(LDLIBS) -framework Foundation -framework Metal
METAL_CORE_OBJS := $(addprefix $(METAL_OBJDIR)/,ds4.o ds4_build.o ds4_ssd.o ds4_profile.o ds4_expert_store.o ds4_qwen.o ds4_qwen_unicode.o ds4_qwen_expert_group.o ds4_metal.o)
CPU_CORE_OBJS := $(addprefix $(CPU_OBJDIR)/,ds4.o ds4_build.o ds4_ssd.o ds4_profile.o ds4_expert_store.o ds4_qwen.o ds4_qwen_unicode.o)
METAL_BINS := $(addprefix $(METAL_BINDIR)/,$(PROGRAMS))
CPU_BINS := $(addprefix $(CPU_BINDIR)/,$(PROGRAMS))
METAL_TEST_BINS := \
$(METAL_BINDIR)/ds4_test \
$(METAL_BINDIR)/ds4_agent_test \
$(METAL_BINDIR)/test_q4k_dot \
$(METAL_BINDIR)/test_q4k_top8 \
$(METAL_BINDIR)/test_qwen_session \
$(METAL_BINDIR)/test_qwen_gdn_ref \
$(METAL_BINDIR)/test_qwen_attention_ref \
$(METAL_BINDIR)/test_qwen_state \
$(METAL_BINDIR)/test_qwen_unicode \
$(METAL_BINDIR)/test_qwen_tokenizer \
$(METAL_BINDIR)/test_qwen_expert_group \
$(METAL_BINDIR)/test_expert_store \
$(METAL_BINDIR)/test_metal_ssd_profile \
$(METAL_BINDIR)/test_ssd_residency \
$(METAL_BINDIR)/test_visible_identity
all: metal
help:
@echo "Hebrus build targets:"
@echo " make / make metal Build Metal and publish ./hebrus* plus ./ds4* aliases"
@echo " make cpu Build CPU-only commands in $(CPU_BINDIR); keep root Metal links"
@echo " make test Build and run the Metal test suite"
@echo " make model-free-test"
@echo " Run all Metal gates that do not require a GGUF"
@echo " make build-isolation-test"
@echo " Prove Metal -> CPU -> Metal cannot mix artifacts"
@echo " make install Install commands under DESTDIR+$(BINDIR)"
@echo " make uninstall Remove only the ten installed command paths"
@echo " make install-test Verify staged install layout and capabilities"
@echo " make brand-boundary-audit"
@echo " Reject unclassified or increased legacy brand tokens"
@echo " make release-contract"
@echo " Reject Qwen release identity drift"
@echo " make server-alias-model-test QWEN_V2=/absolute/model.gguf"
@echo " Run the opt-in model-backed server alias release gate"
@echo " make premerge Run context/docs, isolation, and model-free gates"
@echo " make clean Remove build outputs and published root binaries"
# Root binaries are a Metal-only compatibility surface on macOS. These targets
# are phony so an old regular CPU binary is replaced even when its timestamp is
# newer than the namespaced Metal binary.
metal: $(PROGRAMS) $(METAL_BINS)
hebrus ds4: $(METAL_BINDIR)/hebrus
hebrus-server ds4-server: $(METAL_BINDIR)/hebrus-server
hebrus-bench ds4-bench: $(METAL_BINDIR)/hebrus-bench
hebrus-eval ds4-eval: $(METAL_BINDIR)/hebrus-eval
hebrus-agent ds4-agent: $(METAL_BINDIR)/hebrus-agent
$(PROGRAMS):
@rm -f "$@"
@ln -s "$<" "$@"
cpu: $(CPU_BINS)
@echo "CPU-only binaries: $(CPU_BINDIR)"
$(METAL_BINDIR)/hebrus: \
$(METAL_OBJDIR)/ds4_cli.o $(METAL_OBJDIR)/ds4_help.o \
$(METAL_OBJDIR)/linenoise.o $(METAL_CORE_OBJS)
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -o $@ $^ $(METAL_LDLIBS)
$(METAL_BINDIR)/hebrus-server: \
$(METAL_OBJDIR)/ds4_server.o $(METAL_OBJDIR)/ds4_help.o \
$(METAL_OBJDIR)/ds4_kvstore.o $(METAL_OBJDIR)/rax.o $(METAL_CORE_OBJS)
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -o $@ $^ $(METAL_LDLIBS)
$(METAL_BINDIR)/hebrus-bench: \
$(METAL_OBJDIR)/ds4_bench.o $(METAL_OBJDIR)/ds4_help.o $(METAL_CORE_OBJS)
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -o $@ $^ $(METAL_LDLIBS)
$(METAL_BINDIR)/hebrus-eval: \
$(METAL_OBJDIR)/ds4_eval.o $(METAL_OBJDIR)/ds4_help.o $(METAL_CORE_OBJS)
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -o $@ $^ $(METAL_LDLIBS)
$(METAL_BINDIR)/hebrus-agent: \
$(METAL_OBJDIR)/ds4_agent.o $(METAL_OBJDIR)/ds4_help.o \
$(METAL_OBJDIR)/ds4_web.o $(METAL_OBJDIR)/ds4_kvstore.o \
$(METAL_OBJDIR)/linenoise.o $(METAL_CORE_OBJS)
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -o $@ $^ $(METAL_LDLIBS)
$(METAL_BINDIR)/ds4: $(METAL_BINDIR)/hebrus
$(METAL_BINDIR)/ds4-server: $(METAL_BINDIR)/hebrus-server
$(METAL_BINDIR)/ds4-bench: $(METAL_BINDIR)/hebrus-bench
$(METAL_BINDIR)/ds4-eval: $(METAL_BINDIR)/hebrus-eval
$(METAL_BINDIR)/ds4-agent: $(METAL_BINDIR)/hebrus-agent
$(addprefix $(METAL_BINDIR)/,$(DS4_PROGRAMS)):
@rm -f "$@"
@ln -s "$(notdir $<)" "$@"
$(CPU_BINDIR)/hebrus: \
$(CPU_OBJDIR)/ds4_cli.o $(CPU_OBJDIR)/ds4_help.o \
$(CPU_OBJDIR)/linenoise.o $(CPU_CORE_OBJS)
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS)
$(CPU_BINDIR)/hebrus-server: \
$(CPU_OBJDIR)/ds4_server.o $(CPU_OBJDIR)/ds4_help.o \
$(CPU_OBJDIR)/ds4_kvstore.o $(CPU_OBJDIR)/rax.o $(CPU_CORE_OBJS)
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS)
$(CPU_BINDIR)/hebrus-bench: \
$(CPU_OBJDIR)/ds4_bench.o $(CPU_OBJDIR)/ds4_help.o $(CPU_CORE_OBJS)
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS)
$(CPU_BINDIR)/hebrus-eval: \
$(CPU_OBJDIR)/ds4_eval.o $(CPU_OBJDIR)/ds4_help.o $(CPU_CORE_OBJS)
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS)
$(CPU_BINDIR)/hebrus-agent: \
$(CPU_OBJDIR)/ds4_agent.o $(CPU_OBJDIR)/ds4_help.o \
$(CPU_OBJDIR)/ds4_web.o $(CPU_OBJDIR)/ds4_kvstore.o \
$(CPU_OBJDIR)/linenoise.o $(CPU_CORE_OBJS)
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS)
$(CPU_BINDIR)/ds4: $(CPU_BINDIR)/hebrus
$(CPU_BINDIR)/ds4-server: $(CPU_BINDIR)/hebrus-server
$(CPU_BINDIR)/ds4-bench: $(CPU_BINDIR)/hebrus-bench
$(CPU_BINDIR)/ds4-eval: $(CPU_BINDIR)/hebrus-eval
$(CPU_BINDIR)/ds4-agent: $(CPU_BINDIR)/hebrus-agent
$(addprefix $(CPU_BINDIR)/,$(DS4_PROGRAMS)):
@rm -f "$@"
@ln -s "$(notdir $<)" "$@"
$(METAL_OBJDIR)/%.o: %.c
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) $(DEPFLAGS) -c -o $@ $<
# Textual implementation partitions stay in the ds4.c translation unit. Keep
# the dependency explicit as well as in the generated .d file so incremental
# builds remain correct before dependency metadata exists.
$(METAL_OBJDIR)/ds4.o: runtime/ds4_glm_graph.inc \
runtime/ds4_deepseek_cache_phase.inc
$(CPU_OBJDIR)/ds4.o: runtime/ds4_glm_graph.inc \
runtime/ds4_deepseek_cache_phase.inc
$(CPU_OBJDIR)/%.o: %.c
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -DDS4_NO_GPU $(DEPFLAGS) -c -o $@ $<
# Build provenance is intentionally refreshed on every invocation. Keeping it
# in this tiny object prevents a clean/dirty transition from forcing the giant
# engine translation unit to rebuild while ensuring --build-info is truthful.
$(METAL_OBJDIR)/ds4_build.o: ds4_build.c ds4.h ds4_expert_store.h FORCE
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) $(DEPFLAGS) -c -o $@ $<
$(CPU_OBJDIR)/ds4_build.o: ds4_build.c ds4.h ds4_expert_store.h FORCE
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -DDS4_NO_GPU $(DEPFLAGS) -c -o $@ $<
$(METAL_OBJDIR)/ds4_qwen.o: ds4_qwen.c ds4_qwen.h
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) $(QWEN_CFLAGS) $(DEPFLAGS) -c -o $@ $<
$(CPU_OBJDIR)/ds4_qwen.o: ds4_qwen.c ds4_qwen.h
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) $(QWEN_CFLAGS) -DDS4_NO_GPU $(DEPFLAGS) -c -o $@ $<
$(METAL_OBJDIR)/ds4_qwen_unicode.o: ds4_qwen_unicode.c ds4_qwen_unicode.h \
ds4_qwen_unicode_data.inc
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) $(DEPFLAGS) -c -o $@ $<
$(CPU_OBJDIR)/ds4_qwen_unicode.o: ds4_qwen_unicode.c ds4_qwen_unicode.h \
ds4_qwen_unicode_data.inc
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -DDS4_NO_GPU $(DEPFLAGS) -c -o $@ $<
$(METAL_OBJDIR)/ds4_test_core.o: ds4.c ds4.h ds4_ssd.h ds4_profile.h \
ds4_gpu.h ds4_qwen.h ds4_expert_store.h \
ds4_qwen_unicode.h ds4_streaming_hotlist.inc \
tests/internal/ds4_qwen_cpu_test_hooks.h
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) $(QWEN_CFLAGS) $(DEPFLAGS) -DDS4_NO_GPU \
-DDS4_TEST_HOOKS -Wno-unused-function -Wno-unused-parameter \
-c -o $@ $<
$(METAL_OBJDIR)/ds4_metal.o: ds4_metal.m ds4_gpu.h \
ds4_qwen_expert_group.h runtime/ds4_metal_glm.inc $(METAL_SRCS)
@mkdir -p "$(@D)"
$(CC) $(OBJCFLAGS) $(DEPFLAGS) -c -o $@ ds4_metal.m
# These white-box implementation objects deliberately omit normal entrypoints
# or GPU consumers. Keep unused-only suppression scoped to the implementation
# variants until the remaining server/Qwen seams remove this coupling debt.
$(METAL_OBJDIR)/ds4_test.o: tests/ds4_test.c
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) $(DEPFLAGS) -Wno-unused-function -c -o $@ $<
$(METAL_OBJDIR)/ds4_agent_test.o: tests/ds4_agent_test.c \
tests/internal/ds4_agent_unit.h
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) $(DEPFLAGS) -c -o $@ $<
$(METAL_OBJDIR)/ds4_agent_test_impl.o: ds4_agent.c ds4.h ds4_ssd.h \
ds4_help.h ds4_kvstore.h ds4_web.h linenoise.h \
tests/internal/ds4_agent_unit.h tests/internal/ds4_agent_unit.inc
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) $(DEPFLAGS) -DDS4_AGENT_TEST \
-DDS4_AGENT_TEST_NO_MAIN -Wno-unused-function -c -o $@ $<
$(METAL_OBJDIR)/test_q4k_dot.o: tests/test_q4k_dot.c
@mkdir -p "$(@D)"
$(CC) -O2 -Wall -Wextra -std=c99 $(DEPFLAGS) -c -o $@ $<
$(METAL_OBJDIR)/test_q4k_top8.o: tests/test_q4k_top8.c \
tests/internal/ds4_qwen_cpu_test_hooks.h ds4_qwen.h
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) $(QWEN_CFLAGS) $(DEPFLAGS) -DDS4_NO_GPU \
-DDS4_TEST_HOOKS -I. -c -o $@ $<
$(METAL_OBJDIR)/test_qwen_session.o: tests/test_qwen_session.c ds4.c ds4.h \
ds4_ssd.h ds4_profile.h ds4_gpu.h ds4_qwen.h \
ds4_qwen_unicode.h runtime/ds4_glm_graph.inc \
runtime/ds4_deepseek_cache_phase.inc
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) $(QWEN_CFLAGS) $(DEPFLAGS) -DDS4_NO_GPU \
-Wno-unused-function -Wno-unused-parameter -I. -c -o $@ $<
$(METAL_OBJDIR)/test_qwen_tokenizer.o: tests/test_qwen_tokenizer.c ds4.c \
ds4.h ds4_kvstore.h ds4_ssd.h ds4_profile.h ds4_gpu.h ds4_qwen.h \
ds4_qwen_unicode.h tests/qwen/qwen36_tokenizer_fixture.inc
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) $(QWEN_CFLAGS) $(DEPFLAGS) -DDS4_NO_GPU \
-Wno-unused-function -Wno-unused-parameter -I. -c -o $@ $<
$(METAL_OBJDIR)/test_ssd_residency.o: tests/test_ssd_residency.c \
ds4_ssd.h ds4_qwen.h
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) $(DEPFLAGS) -I. -c -o $@ $<
$(METAL_OBJDIR)/test_qwen_expert_group.o: tests/test_qwen_expert_group.c \
ds4_qwen_expert_group.h
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) $(DEPFLAGS) -I. -c -o $@ $<
$(METAL_OBJDIR)/test_expert_store.o: tests/test_expert_store.c \
ds4_expert_store.h
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) $(DEPFLAGS) -I. -c -o $@ $<
$(METAL_OBJDIR)/test_metal_ssd_profile.o: tests/test_metal_ssd_profile.c \
ds4_profile.h
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) $(DEPFLAGS) -I. -c -o $@ $<
$(METAL_OBJDIR)/test_qwen_gdn_ref.o: tests/test_qwen_gdn_ref.c ds4_qwen_ref.h \
ds4_qwen.h tests/qwen/qwen36_gdn_golden.inc
@mkdir -p "$(@D)"
$(CC) -O2 -Wall -Wextra -std=c99 $(DEPFLAGS) -I. -c -o $@ $<
$(METAL_OBJDIR)/test_qwen_attention_ref.o: tests/test_qwen_attention_ref.c \
ds4_qwen_ref.h ds4_qwen.h tests/qwen/qwen36_attention_golden.inc
@mkdir -p "$(@D)"
$(CC) -O2 -Wall -Wextra -std=c99 $(DEPFLAGS) -I. -c -o $@ $<
$(METAL_OBJDIR)/test_qwen_state.o: tests/test_qwen_state.c ds4_qwen.h
@mkdir -p "$(@D)"
$(CC) -O2 -Wall -Wextra -std=c99 $(DEPFLAGS) -I. -c -o $@ $<
$(METAL_OBJDIR)/test_qwen_unicode.o: tests/test_qwen_unicode.c \
ds4_qwen_unicode.h
@mkdir -p "$(@D)"
$(CC) -O2 -Wall -Wextra -std=c99 $(DEPFLAGS) -I. -c -o $@ $<
$(METAL_OBJDIR)/ds4_qwen_ref.o: ds4_qwen_ref.c ds4_qwen_ref.h
@mkdir -p "$(@D)"
$(CC) -O2 -Wall -Wextra -std=c99 $(DEPFLAGS) -c -o $@ $<
$(METAL_BINDIR)/ds4_test: \
$(METAL_OBJDIR)/ds4_test.o $(METAL_OBJDIR)/ds4_help.o \
$(METAL_OBJDIR)/ds4_kvstore.o $(METAL_OBJDIR)/rax.o $(METAL_CORE_OBJS)
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -o $@ $^ $(METAL_LDLIBS)
$(METAL_BINDIR)/ds4_agent_test: \
$(METAL_OBJDIR)/ds4_agent_test.o \
$(METAL_OBJDIR)/ds4_agent_test_impl.o $(METAL_OBJDIR)/ds4_help.o \
$(METAL_OBJDIR)/ds4_web.o $(METAL_OBJDIR)/ds4_kvstore.o \
$(METAL_OBJDIR)/linenoise.o $(METAL_CORE_OBJS)
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -o $@ $^ $(METAL_LDLIBS)
$(METAL_BINDIR)/test_q4k_dot: $(METAL_OBJDIR)/test_q4k_dot.o
@mkdir -p "$(@D)"
$(CC) -O2 -o $@ $^ -lm -pthread
$(METAL_BINDIR)/test_q4k_top8: \
$(METAL_OBJDIR)/test_q4k_top8.o $(METAL_OBJDIR)/ds4_test_core.o \
$(METAL_OBJDIR)/ds4_build.o \
$(METAL_OBJDIR)/ds4_ssd.o \
$(METAL_OBJDIR)/ds4_profile.o \
$(METAL_OBJDIR)/ds4_expert_store.o \
$(METAL_OBJDIR)/ds4_qwen.o $(METAL_OBJDIR)/ds4_qwen_unicode.o
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS)
$(METAL_BINDIR)/test_qwen_session: \
$(METAL_OBJDIR)/test_qwen_session.o $(METAL_OBJDIR)/ds4_build.o \
$(METAL_OBJDIR)/ds4_ssd.o \
$(METAL_OBJDIR)/ds4_profile.o \
$(METAL_OBJDIR)/ds4_expert_store.o \
$(METAL_OBJDIR)/ds4_qwen.o $(METAL_OBJDIR)/ds4_qwen_unicode.o
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS)
$(METAL_BINDIR)/test_qwen_tokenizer: \
$(METAL_OBJDIR)/test_qwen_tokenizer.o $(METAL_OBJDIR)/ds4_kvstore.o \
$(METAL_OBJDIR)/ds4_build.o \
$(METAL_OBJDIR)/ds4_ssd.o \
$(METAL_OBJDIR)/ds4_profile.o \
$(METAL_OBJDIR)/ds4_expert_store.o \
$(METAL_OBJDIR)/ds4_qwen.o $(METAL_OBJDIR)/ds4_qwen_unicode.o
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS)
$(METAL_BINDIR)/test_ssd_residency: \
$(METAL_OBJDIR)/test_ssd_residency.o $(METAL_OBJDIR)/ds4_ssd.o
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS)
$(METAL_BINDIR)/test_visible_identity: \
tests/test_visible_identity.c hebrus_identity.h
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -I. -o $@ $<
$(CPU_BINDIR)/test_visible_identity: \
tests/test_visible_identity.c hebrus_identity.h
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -DDS4_NO_GPU -I. -o $@ $<
visible-identity-test: $(METAL_BINDIR)/test_visible_identity \
$(CPU_BINDIR)/test_visible_identity
$(METAL_BINDIR)/test_visible_identity
$(CPU_BINDIR)/test_visible_identity
$(METAL_BINDIR)/test_qwen_gdn_ref: \
$(METAL_OBJDIR)/test_qwen_gdn_ref.o $(METAL_OBJDIR)/ds4_qwen_ref.o \
$(METAL_OBJDIR)/ds4_qwen.o
@mkdir -p "$(@D)"
$(CC) -O2 -o $@ $^ -lm
$(METAL_BINDIR)/test_qwen_attention_ref: \
$(METAL_OBJDIR)/test_qwen_attention_ref.o $(METAL_OBJDIR)/ds4_qwen_ref.o \
$(METAL_OBJDIR)/ds4_qwen.o
@mkdir -p "$(@D)"
$(CC) -O2 -o $@ $^ -lm
$(METAL_BINDIR)/test_qwen_state: \
$(METAL_OBJDIR)/test_qwen_state.o $(METAL_OBJDIR)/ds4_qwen.o
@mkdir -p "$(@D)"
$(CC) -O2 -o $@ $^ -lm
$(METAL_BINDIR)/test_qwen_unicode: \
$(METAL_OBJDIR)/test_qwen_unicode.o $(METAL_OBJDIR)/ds4_qwen_unicode.o
@mkdir -p "$(@D)"
$(CC) -O2 -o $@ $^
$(METAL_BINDIR)/test_qwen_expert_group: \
$(METAL_OBJDIR)/test_qwen_expert_group.o \
$(METAL_OBJDIR)/ds4_qwen_expert_group.o
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS)
$(METAL_BINDIR)/test_expert_store: \
$(METAL_OBJDIR)/test_expert_store.o \
$(METAL_OBJDIR)/ds4_expert_store.o
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS)
$(METAL_BINDIR)/test_metal_ssd_profile: \
$(METAL_OBJDIR)/test_metal_ssd_profile.o \
$(METAL_OBJDIR)/ds4_profile.o
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS)
qwen-expert-group-test: $(METAL_BINDIR)/test_qwen_expert_group
$<
expert-store-test: $(METAL_BINDIR)/test_expert_store
DS4_EXPERT_STORE_PROBE=$(METAL_BINDIR)/test_expert_store \
python3 tests/test_expert_major.py
metal-ssd-profile-test: $(METAL_BINDIR)/test_metal_ssd_profile
$<
# Preserve the documented direct test-runner commands without letting a CPU
# target publish over them.
ds4_test: $(METAL_BINDIR)/ds4_test
@rm -f "$@"
@ln -s "$<" "$@"
ds4_agent_test: $(METAL_BINDIR)/ds4_agent_test
@rm -f "$@"
@ln -s "$<" "$@"
q4k-dot-test: $(METAL_BINDIR)/test_q4k_dot
$<
qwen-metadata-test: $(METAL_BINDIR)/ds4 tests/test_qwen_metadata.py
python3 tests/test_qwen_metadata.py $(METAL_BINDIR)/ds4
qwen-reference-test: $(METAL_BINDIR)/test_qwen_gdn_ref \
$(METAL_BINDIR)/test_qwen_attention_ref \
$(METAL_BINDIR)/test_qwen_unicode
python3 tests/qwen/collect_gdn_reference.py --check
python3 tests/qwen/collect_attention_reference.py --check
python3 tests/qwen/test_v_tiling_contract.py
python3 tests/gen_qwen_unicode.py --check
$(METAL_BINDIR)/test_qwen_gdn_ref
$(METAL_BINDIR)/test_qwen_attention_ref
$(METAL_BINDIR)/test_qwen_unicode
qwen-unicode-test: $(METAL_BINDIR)/test_qwen_unicode
python3 tests/gen_qwen_unicode.py --check
$(METAL_BINDIR)/test_qwen_unicode
qwen-tokenizer-test: $(METAL_BINDIR)/test_qwen_tokenizer
$(METAL_BINDIR)/test_qwen_tokenizer
capabilities-test: metal tests/test_capabilities.py
python3 tests/test_capabilities.py --bin-dir $(METAL_BINDIR) --backend metal
command-alias-test: metal tests/test_command_aliases.py
python3 tests/test_command_aliases.py --bin-dir $(METAL_BINDIR) \
--backend metal --layout profile
model-free-test: metal ds4_test ds4_agent_test $(METAL_BINDIR)/test_q4k_dot \
$(METAL_BINDIR)/test_q4k_top8 \
$(METAL_BINDIR)/test_qwen_session \
$(METAL_BINDIR)/test_qwen_gdn_ref \
$(METAL_BINDIR)/test_qwen_attention_ref \
$(METAL_BINDIR)/test_qwen_state \
$(METAL_BINDIR)/test_qwen_unicode \
$(METAL_BINDIR)/test_qwen_tokenizer \
$(METAL_BINDIR)/test_qwen_expert_group \
$(METAL_BINDIR)/test_expert_store \
$(METAL_BINDIR)/test_metal_ssd_profile \
$(METAL_BINDIR)/test_ssd_residency download-model-test \
visible-identity-test \
server-alias-model-unit-test \
tests/test_capabilities.py tests/test_command_aliases.py
python3 tests/test_capabilities.py --bin-dir $(METAL_BINDIR) --backend metal
python3 tests/test_command_aliases.py --bin-dir $(METAL_BINDIR) \
--backend metal --layout profile
DS4_BIN_DIR=$(METAL_BINDIR) sh tests/test_retired_distributed_flags.sh
sh tests/test_benchmark_env_guard.sh
$(METAL_BINDIR)/ds4-eval --self-test-extractors
$(METAL_BINDIR)/ds4_agent_test
$(METAL_BINDIR)/ds4_test --server
$(METAL_BINDIR)/ds4_test --metal-kernels
$(METAL_BINDIR)/ds4_test --metal-expert-pack
$(METAL_BINDIR)/test_q4k_dot
$(METAL_BINDIR)/test_q4k_top8
$(METAL_BINDIR)/test_qwen_session
$(METAL_BINDIR)/test_qwen_gdn_ref
$(METAL_BINDIR)/test_qwen_attention_ref
$(METAL_BINDIR)/test_qwen_state
$(METAL_BINDIR)/test_qwen_unicode
$(METAL_BINDIR)/test_qwen_tokenizer
$(METAL_BINDIR)/test_qwen_expert_group
DS4_EXPERT_STORE_PROBE=$(METAL_BINDIR)/test_expert_store \
python3 tests/test_expert_major.py
$(METAL_BINDIR)/test_metal_ssd_profile
python3 tests/qwen/collect_gdn_reference.py --check
python3 tests/qwen/collect_attention_reference.py --check
python3 tests/qwen/test_v_tiling_contract.py
python3 tests/gen_qwen_unicode.py --check
$(METAL_BINDIR)/test_ssd_residency
python3 tests/test_qwen_metadata.py $(METAL_BINDIR)/ds4
test: model-free-test
$(METAL_BINDIR)/ds4_test
context-audit:
python3 tools/context_audit.py
doc-links:
python3 tools/check_doc_links.py
imatrix-dataset-check:
python3 gguf-tools/imatrix/dataset/build_ds4_imatrix_dataset.py --check
prompt-fixture-check:
python3 speed-bench/build_long_context_prompt.py --check
# Build isolation removes and rebuilds BUILD_ROOT, so model-free-test must start
# only after it completes even when an agent invokes `make -j premerge`.
premerge: context-audit doc-links brand-boundary-audit brand-boundary-test brand-asset-test \
release-contract release-contract-test \
imatrix-dataset-check prompt-fixture-check build-isolation-test
$(MAKE) model-free-test
$(MAKE) install-test
git diff --check
build-isolation-test: tests/test_build_isolation.sh tests/test_capabilities.py \
tests/test_command_aliases.py
MAKE="$(MAKE)" sh tests/test_build_isolation.sh
-include $(wildcard $(METAL_OBJDIR)/*.d $(CPU_OBJDIR)/*.d)
else
CFLAGS += -D_GNU_SOURCE -fno-finite-math-only
CPU_CORE_OBJS := ds4_cpu.o ds4_build_cpu.o ds4_ssd.o \
ds4_profile.o ds4_expert_store.o ds4_qwen.o ds4_qwen_unicode.o
INSTALL_SOURCE_BINDIR := .
INSTALL_BACKEND := cpu
all: cpu
help:
@echo "Hebrus build targets:"
@echo " make / make cpu Build ./hebrus* plus ./ds4* aliases"
@echo " make test Build and run tests"
@echo " make model-free-test Run all tests that do not require a GGUF"
@echo " make install Install commands under DESTDIR+$(BINDIR)"
@echo " make uninstall Remove only the ten installed command paths"
@echo " make install-test Verify staged install layout and capabilities"
@echo " make brand-boundary-audit"
@echo " Reject unclassified or increased legacy brand tokens"
@echo " make release-contract Reject Qwen release identity drift"
@echo " make server-alias-model-test QWEN_V2=/absolute/model.gguf"
@echo " Run the opt-in model-backed server alias gate"
@echo " make premerge Run repository audits and Linux CPU/model-free gates"
@echo " make clean Remove build outputs"
cpu: $(PROGRAMS)
hebrus: ds4_cli_cpu.o ds4_help.o linenoise.o $(CPU_CORE_OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS)
hebrus-server: ds4_server_cpu.o ds4_help.o ds4_kvstore.o rax.o $(CPU_CORE_OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS)
hebrus-bench: ds4_bench_cpu.o ds4_help.o $(CPU_CORE_OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS)
hebrus-eval: ds4_eval_cpu.o ds4_help.o $(CPU_CORE_OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS)
hebrus-agent: ds4_agent_cpu.o ds4_help.o ds4_web.o ds4_kvstore.o linenoise.o $(CPU_CORE_OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS)
ds4: hebrus
ds4-server: hebrus-server
ds4-bench: hebrus-bench
ds4-eval: hebrus-eval
ds4-agent: hebrus-agent
$(DS4_PROGRAMS):
@rm -f "$@"
@ln -s "$(notdir $<)" "$@"
ds4_build_cpu.o: ds4_build.c ds4.h ds4_expert_store.h FORCE
$(CC) $(CFLAGS) -DDS4_NO_GPU -c -o $@ ds4_build.c
ds4_ssd.o: ds4_ssd.c ds4_ssd.h
$(CC) $(CFLAGS) -c -o $@ ds4_ssd.c
ds4_profile.o: ds4_profile.c ds4_profile.h
$(CC) $(CFLAGS) -c -o $@ ds4_profile.c
ds4_qwen.o: ds4_qwen.c ds4_qwen.h
$(CC) $(CFLAGS) $(QWEN_CFLAGS) -c -o $@ ds4_qwen.c
ds4_qwen_unicode.o: ds4_qwen_unicode.c ds4_qwen_unicode.h \
ds4_qwen_unicode_data.inc
$(CC) $(CFLAGS) -c -o $@ ds4_qwen_unicode.c
ds4_cli.o: ds4_cli.c ds4.h ds4_ssd.h ds4_help.h hebrus_identity.h linenoise.h
$(CC) $(CFLAGS) -c -o $@ ds4_cli.c
ds4_help.o: ds4_help.c ds4_help.h hebrus_identity.h
$(CC) $(CFLAGS) -c -o $@ ds4_help.c
ds4_server.o: ds4_server.c ds4.h ds4_ssd.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_help.h hebrus_identity.h
$(CC) $(CFLAGS) -c -o $@ ds4_bench.c
ds4_eval.o: ds4_eval.c ds4.h ds4_ssd.h ds4_help.h hebrus_identity.h
$(CC) $(CFLAGS) -c -o $@ ds4_eval.c
ds4_agent.o: ds4_agent.c ds4.h ds4_ssd.h ds4_help.h hebrus_identity.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
$(CC) $(CFLAGS) -c -o $@ ds4_web.c
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_help.h ds4_kvstore.h rax.h
$(CC) $(CFLAGS) -DDS4_NO_GPU -Wno-unused-function -c -o $@ tests/ds4_test.c
ds4_agent_test.o: tests/ds4_agent_test.c tests/internal/ds4_agent_unit.h
$(CC) $(CFLAGS) -DDS4_NO_GPU -c -o $@ tests/ds4_agent_test.c
ds4_agent_test_impl.o: ds4_agent.c ds4.h ds4_ssd.h \
ds4_help.h hebrus_identity.h ds4_kvstore.h ds4_web.h linenoise.h \
tests/internal/ds4_agent_unit.h tests/internal/ds4_agent_unit.inc
$(CC) $(CFLAGS) -DDS4_NO_GPU -DDS4_AGENT_TEST \
-DDS4_AGENT_TEST_NO_MAIN -Wno-unused-function -c -o $@ ds4_agent.c
tests/test_ssd_residency: tests/test_ssd_residency.c ds4_ssd.o
$(CC) $(CFLAGS) -I. -o $@ $^ -lm -pthread
rax.o: rax.c rax.h rax_malloc.h
$(CC) $(CFLAGS) -c -o $@ rax.c
linenoise.o: linenoise.c linenoise.h
$(CC) $(CFLAGS) -c -o $@ linenoise.c
ds4_cpu.o: ds4.c ds4.h ds4_ssd.h ds4_profile.h ds4_gpu.h ds4_qwen.h \
ds4_expert_store.h ds4_qwen_unicode.h ds4_streaming_hotlist.inc
$(CC) $(CFLAGS) -DDS4_NO_GPU -c -o $@ ds4.c
ds4_test_core.o: ds4.c ds4.h ds4_ssd.h ds4_profile.h \
ds4_gpu.h ds4_qwen.h ds4_expert_store.h ds4_qwen_unicode.h \
ds4_streaming_hotlist.inc tests/internal/ds4_qwen_cpu_test_hooks.h
$(CC) $(CFLAGS) $(QWEN_CFLAGS) -DDS4_NO_GPU -DDS4_TEST_HOOKS \
-Wno-unused-function -Wno-unused-parameter -c -o $@ ds4.c
ds4_cli_cpu.o: ds4_cli.c ds4.h ds4_ssd.h ds4_help.h hebrus_identity.h linenoise.h
$(CC) $(CFLAGS) -DDS4_NO_GPU -c -o $@ ds4_cli.c
ds4_server_cpu.o: ds4_server.c ds4.h ds4_ssd.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_help.h hebrus_identity.h
$(CC) $(CFLAGS) -DDS4_NO_GPU -c -o $@ ds4_bench.c
ds4_eval_cpu.o: ds4_eval.c ds4.h ds4_ssd.h ds4_help.h hebrus_identity.h
$(CC) $(CFLAGS) -DDS4_NO_GPU -c -o $@ ds4_eval.c
ds4_agent_cpu.o: ds4_agent.c ds4.h ds4_ssd.h ds4_help.h hebrus_identity.h ds4_kvstore.h ds4_web.h linenoise.h
$(CC) $(CFLAGS) -DDS4_NO_GPU -c -o $@ ds4_agent.c
ds4_test: ds4_test.o ds4_help.o ds4_kvstore.o rax.o $(CPU_CORE_OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS)
ds4_agent_test: ds4_agent_test.o ds4_agent_test_impl.o ds4_help.o \
ds4_web.o ds4_kvstore.o linenoise.o $(CPU_CORE_OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS)
model-free-test: $(PROGRAMS) ds4_test ds4_agent_test q4k-dot-test \
tests/test_q4k_top8 \
tests/test_qwen_session \
tests/test_qwen_tokenizer \
tests/test_qwen_gdn_ref tests/test_qwen_attention_ref \
tests/test_qwen_state tests/test_qwen_unicode \
tests/test_qwen_expert_group \
tests/test_expert_store \
tests/test_metal_ssd_profile \
tests/test_ssd_residency download-model-test visible-identity-test \
server-alias-model-unit-test \
tests/test_capabilities.py \
tests/test_command_aliases.py
python3 tests/test_capabilities.py --bin-dir . --backend cpu
python3 tests/test_command_aliases.py --bin-dir . --backend cpu --layout profile
sh tests/test_retired_distributed_flags.sh
sh tests/test_benchmark_env_guard.sh
./ds4-eval --self-test-extractors
./ds4_agent_test
./ds4_test --server
./tests/test_q4k_top8
./tests/test_qwen_session
./tests/test_qwen_tokenizer
./tests/test_qwen_gdn_ref
./tests/test_qwen_attention_ref
./tests/test_qwen_state
./tests/test_qwen_unicode
./tests/test_qwen_expert_group
DS4_EXPERT_STORE_PROBE=./tests/test_expert_store \
python3 tests/test_expert_major.py
./tests/test_metal_ssd_profile
python3 tests/qwen/collect_gdn_reference.py --check
python3 tests/qwen/collect_attention_reference.py --check
python3 tests/qwen/test_v_tiling_contract.py
python3 tests/gen_qwen_unicode.py --check
./tests/test_ssd_residency
python3 tests/test_qwen_metadata.py ./ds4
capabilities-test: $(PROGRAMS) tests/test_capabilities.py
python3 tests/test_capabilities.py --bin-dir . --backend cpu
command-alias-test: $(PROGRAMS) tests/test_command_aliases.py
python3 tests/test_command_aliases.py --bin-dir . --backend cpu --layout profile
tests/test_visible_identity: tests/test_visible_identity.c hebrus_identity.h
$(CC) $(CFLAGS) -DDS4_NO_GPU -I. -o $@ $<
visible-identity-test: tests/test_visible_identity
./tests/test_visible_identity
test: model-free-test
./ds4_test
context-audit:
python3 tools/context_audit.py
doc-links:
python3 tools/check_doc_links.py
imatrix-dataset-check:
python3 gguf-tools/imatrix/dataset/build_ds4_imatrix_dataset.py --check
prompt-fixture-check:
python3 speed-bench/build_long_context_prompt.py --check
premerge: context-audit doc-links brand-boundary-audit brand-boundary-test brand-asset-test \
release-contract release-contract-test \
imatrix-dataset-check prompt-fixture-check model-free-test
$(MAKE) install-test
git diff --check
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
test_q4k_top8.o: tests/test_q4k_top8.c \
tests/internal/ds4_qwen_cpu_test_hooks.h ds4_qwen.h
$(CC) $(CFLAGS) $(QWEN_CFLAGS) -DDS4_NO_GPU -DDS4_TEST_HOOKS \
-I. -c -o $@ $<
tests/test_q4k_top8: test_q4k_top8.o ds4_test_core.o ds4_build_cpu.o \
ds4_ssd.o ds4_profile.o ds4_expert_store.o \
ds4_qwen.o ds4_qwen_unicode.o
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS)
tests/test_qwen_session: tests/test_qwen_session.c ds4.c ds4.h ds4_ssd.h ds4_profile.h \
ds4_gpu.h ds4_qwen.h ds4_qwen_unicode.h \
ds4_build.c ds4_expert_store.o ds4_ssd.c \
ds4_profile.c ds4_qwen.c \
ds4_qwen_unicode.c ds4_qwen_unicode_data.inc \
ds4_streaming_hotlist.inc runtime/ds4_glm_graph.inc \
runtime/ds4_deepseek_cache_phase.inc
$(CC) $(CFLAGS) $(QWEN_CFLAGS) -DDS4_NO_GPU \
-Wno-unused-function -Wno-unused-parameter -I. -o $@ \
$(filter-out ds4.c,$(filter %.c %.o,$^)) $(LDLIBS)
tests/test_qwen_tokenizer: tests/test_qwen_tokenizer.c ds4.c ds4.h \
ds4_kvstore.c ds4_kvstore.h ds4_ssd.h ds4_profile.c ds4_profile.h ds4_gpu.h ds4_qwen.h \
ds4_qwen_unicode.h ds4_build.c ds4_expert_store.o ds4_ssd.c \
ds4_qwen.c ds4_qwen_unicode.c ds4_qwen_unicode_data.inc \
ds4_streaming_hotlist.inc tests/qwen/qwen36_tokenizer_fixture.inc
$(CC) $(CFLAGS) $(QWEN_CFLAGS) -DDS4_NO_GPU \
-Wno-unused-function -Wno-unused-parameter -I. -o $@ \
$(filter-out ds4.c,$(filter %.c %.o,$^)) $(LDLIBS)
qwen-metadata-test: ds4 tests/test_qwen_metadata.py
python3 tests/test_qwen_metadata.py ./ds4
tests/test_qwen_gdn_ref: tests/test_qwen_gdn_ref.c ds4_qwen_ref.c ds4_qwen.c \
ds4_qwen_ref.h ds4_qwen.h tests/qwen/qwen36_gdn_golden.inc
$(CC) -O2 -Wall -Wextra -std=c99 -I. -o $@ \
tests/test_qwen_gdn_ref.c ds4_qwen_ref.c ds4_qwen.c -lm
tests/test_qwen_attention_ref: tests/test_qwen_attention_ref.c ds4_qwen_ref.c \
ds4_qwen.c ds4_qwen_ref.h ds4_qwen.h \
tests/qwen/qwen36_attention_golden.inc
$(CC) -O2 -Wall -Wextra -std=c99 -I. -o $@ \
tests/test_qwen_attention_ref.c ds4_qwen_ref.c ds4_qwen.c -lm
tests/test_qwen_state: tests/test_qwen_state.c ds4_qwen.c ds4_qwen.h
$(CC) -O2 -Wall -Wextra -std=c99 -I. -o $@ \
tests/test_qwen_state.c ds4_qwen.c -lm
tests/test_qwen_unicode: tests/test_qwen_unicode.c ds4_qwen_unicode.c \
ds4_qwen_unicode.h ds4_qwen_unicode_data.inc
$(CC) -O2 -Wall -Wextra -std=c99 -I. -o $@ \
tests/test_qwen_unicode.c ds4_qwen_unicode.c
qwen-reference-test: tests/test_qwen_gdn_ref tests/test_qwen_attention_ref \
tests/test_qwen_unicode
python3 tests/qwen/collect_gdn_reference.py --check
python3 tests/qwen/collect_attention_reference.py --check
python3 tests/qwen/test_v_tiling_contract.py
python3 tests/gen_qwen_unicode.py --check
./tests/test_qwen_gdn_ref
./tests/test_qwen_attention_ref
./tests/test_qwen_unicode
qwen-unicode-test: tests/test_qwen_unicode
python3 tests/gen_qwen_unicode.py --check
./tests/test_qwen_unicode
qwen-tokenizer-test: tests/test_qwen_tokenizer
./tests/test_qwen_tokenizer
tests/test_qwen_expert_group: tests/test_qwen_expert_group.c \
ds4_qwen_expert_group.c ds4_qwen_expert_group.h
$(CC) $(CFLAGS) -I. -o $@ tests/test_qwen_expert_group.c \
ds4_qwen_expert_group.c $(LDLIBS)
qwen-expert-group-test: tests/test_qwen_expert_group
./tests/test_qwen_expert_group
tests/test_expert_store: tests/test_expert_store.c ds4_expert_store.c \
ds4_expert_store.h
$(CC) $(CFLAGS) -I. -o $@ tests/test_expert_store.c \
ds4_expert_store.c $(LDLIBS)
expert-store-test: tests/test_expert_store
DS4_EXPERT_STORE_PROBE=./tests/test_expert_store \
python3 tests/test_expert_major.py
tests/test_metal_ssd_profile: tests/test_metal_ssd_profile.c \
ds4_profile.c ds4_profile.h
$(CC) $(CFLAGS) -I. -o $@ tests/test_metal_ssd_profile.c \
ds4_profile.c $(LDLIBS)
metal-ssd-profile-test: tests/test_metal_ssd_profile
./tests/test_metal_ssd_profile
endif
server-alias-model-unit-test: tests/test_server_alias_model.py \
tests/test_server_alias_model_unit.py docs/contracts/qwen-release.json
python3 tests/test_server_alias_model_unit.py
# Deliberately opt-in and excluded from premerge: this loads the complete
# published Qwen artifact twice and must run only on an isolated qualified host.
server-alias-model-test: $(INSTALL_SOURCE_BINDIR)/hebrus-server \
$(INSTALL_SOURCE_BINDIR)/ds4-server \
tests/test_server_alias_model.py docs/contracts/qwen-release.json
@test -n "$(QWEN_V2)" || { \
echo "server-alias-model-test: set QWEN_V2 to the absolute published artifact path" >&2; \
exit 2; \
}
@set -eu; \
set --; \
if test -n "$(SERVER_ALIAS_EVIDENCE_DIR)"; then \
set -- --evidence-dir "$(SERVER_ALIAS_EVIDENCE_DIR)"; \
fi; \
python3 tests/test_server_alias_model.py \
--model "$(QWEN_V2)" \
--bin-dir "$(INSTALL_SOURCE_BINDIR)" \
--expected-backend "$(SERVER_ALIAS_EXPECTED_BACKEND)" \
--expected-build-sha "$(SERVER_ALIAS_EXPECTED_BUILD_SHA)" \
--port "$(SERVER_ALIAS_PORT)" "$$@"
install: $(INSTALL_SOURCE_PROGRAMS)
@set -eu; \
case "$(BINDIR)" in \
/*) ;; \
*) echo "install: BINDIR must be absolute: $(BINDIR)" >&2; exit 2 ;; \
esac; \
dest="$(INSTALL_DEST_BINDIR)"; \
mkdir -p "$$dest"; \
for name in $(PROGRAMS); do \
path="$$dest/$$name"; \
if [ -d "$$path" ] && [ ! -L "$$path" ]; then \
echo "install: refusing to replace directory $$path" >&2; \
exit 2; \
fi; \
done; \
tmp=; \
trap 'test -z "$$tmp" || rm -f "$$tmp"' 0 1 2 3 15; \
for name in $(HEBRUS_PROGRAMS); do \
tmp="$$dest/.$$name.install.$$$$"; \
rm -f "$$tmp"; \
$(INSTALL) -m "$(INSTALL_MODE)" \
"$(INSTALL_SOURCE_BINDIR)/$$name" "$$tmp"; \
rm -f "$$dest/$$name"; \
mv "$$tmp" "$$dest/$$name"; \
tmp=; \
done; \
for canonical in $(HEBRUS_PROGRAMS); do \
legacy=ds4$${canonical#hebrus}; \
tmp="$$dest/.$$legacy.install.$$$$"; \
rm -f "$$tmp"; \
ln -s "$$canonical" "$$tmp"; \
rm -f "$$dest/$$legacy"; \
mv "$$tmp" "$$dest/$$legacy"; \
tmp=; \
done
uninstall:
@set -eu; \
case "$(BINDIR)" in \
/*) ;; \
*) echo "uninstall: BINDIR must be absolute: $(BINDIR)" >&2; exit 2 ;; \
esac; \