Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
215 lines (176 loc) · 7.48 KB
/
Copy pathMakefile
File metadata and controls
215 lines (176 loc) · 7.48 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
CC := clang
AR := ar
CFLAGS := -std=c11 -O3 -MMD -MP -Wall -Wextra -Wpedantic -Wshadow \
-Wconversion -Wno-sign-conversion -D_DARWIN_C_SOURCE
OBJCFLAGS := $(CFLAGS) -fobjc-arc
FRAMEWORKS := -framework Foundation -framework Metal \
-framework MetalPerformanceShaders -framework MetalPerformanceShadersGraph \
-framework Accelerate
LDLIBS := $(FRAMEWORKS) -licucore -lm
LIB_C := h3.c h3_host.c h3_safetensors.c h3_weights.c h3_text_encoder.c \
h3_dit_schedule.c h3_dit.c
LIB_C += h3_video_vae.c h3_video_encoder.c h3_audio_vae.c h3_ffmpeg.c \
h3_terminal.c h3_vision_encoder.c h3_multimodal.c
LIB_M := h3_metal.m h3_gpu.m h3_tokenizer.m
LIB_OBJ := $(LIB_C:.c=.o) $(LIB_M:.m=.o)
CLI_OBJ := main.o h3_cli.o linenoise.o
.PHONY: all test parity real-parity clean
all: h3 libh3.a
h3: $(CLI_OBJ) $(LIB_OBJ)
$(CC) -o $@ $^ $(LDLIBS)
libh3.a: $(LIB_OBJ)
$(AR) rcs $@ $^
h3_tests: tests/test_h3.o $(LIB_OBJ)
$(CC) -o $@ $^ $(LDLIBS)
h3_metal_tests: tests/test_metal.o $(LIB_OBJ)
$(CC) -o $@ $^ $(LDLIBS)
h3_bf16_tests: tests/test_bf16.o $(LIB_OBJ)
$(CC) -o $@ $^ $(LDLIBS)
h3_tokenizer_tests: tests/test_tokenizer.o $(LIB_OBJ)
$(CC) -o $@ $^ $(LDLIBS)
h3_text_tests: tests/test_text_metal.o $(LIB_OBJ)
$(CC) -o $@ $^ $(LDLIBS)
h3_audio_gpu_tests: tests/test_audio_gpu.o $(LIB_OBJ)
$(CC) -o $@ $^ $(LDLIBS)
h3_real_audio_vae_test: tests/test_real_audio_vae.o $(LIB_OBJ)
$(CC) -o $@ $^ $(LDLIBS)
h3_real_audio_encoder_test: tests/test_real_audio_encoder.o $(LIB_OBJ)
$(CC) -o $@ $^ $(LDLIBS)
h3_av_mux_test: tests/test_av_mux.o $(LIB_OBJ)
$(CC) -o $@ $^ $(LDLIBS)
h3_real_video_encoder_test: tests/test_real_video_encoder.o $(LIB_OBJ)
$(CC) -o $@ $^ $(LDLIBS)
h3_real_qwen_vision_test: tests/test_real_qwen_vision.o $(LIB_OBJ)
$(CC) -o $@ $^ $(LDLIBS)
h3_real_multimodal_text_test: tests/test_real_multimodal_text.o $(LIB_OBJ)
$(CC) -o $@ $^ $(LDLIBS)
h3_real_ref_video_text_test: tests/test_real_ref_video_text.o $(LIB_OBJ)
$(CC) -o $@ $^ $(LDLIBS)
h3_real_prompt_test: tests/test_real_prompt.o $(LIB_OBJ)
$(CC) -o $@ $^ $(LDLIBS)
h3_real_dit_block_test: tests/test_real_dit_block.o $(LIB_OBJ)
$(CC) -o $@ $^ $(LDLIBS)
h3_real_dit_schedule_test: tests/test_real_dit_schedule.o $(LIB_OBJ)
$(CC) -o $@ $^ $(LDLIBS)
h3_real_dit_test: tests/test_real_dit.o $(LIB_OBJ)
$(CC) -o $@ $^ $(LDLIBS)
h3_semantic_dit_test: tests/test_semantic_dit.o $(LIB_OBJ)
$(CC) -o $@ $^ $(LDLIBS)
h3_dit_bench: tests/bench_dit.o $(LIB_OBJ)
$(CC) -o $@ $^ $(LDLIBS)
h3_dit_bench_864: tests/bench_dit_864.o $(LIB_OBJ)
$(CC) -o $@ $^ $(LDLIBS)
tests/bench_dit_864.o: tests/bench_dit.c
$(CC) $(CFLAGS) -I. -DH3_BENCH_LATENT_H=30 \
-DH3_BENCH_LATENT_W=54 -c $< -o $@
h3_real_video_vae_test: tests/test_real_video_vae.o $(LIB_OBJ)
$(CC) -o $@ $^ $(LDLIBS)
h3_semantic_vae_test: tests/test_semantic_vae.o $(LIB_OBJ)
$(CC) -o $@ $^ $(LDLIBS)
test: h3_tests h3_metal_tests h3_bf16_tests h3_tokenizer_tests h3_text_tests \
h3_audio_gpu_tests h3_real_audio_vae_test h3_real_audio_encoder_test \
h3_av_mux_test \
h3_real_video_encoder_test h3_real_qwen_vision_test \
h3_real_multimodal_text_test h3_real_ref_video_text_test
./h3_tests
@if test -f misc/fixtures/h3_dit.safetensors && \
test -f misc/fixtures/h3_dit_bf16.safetensors; then \
./h3_metal_tests misc/fixtures/h3_dit.safetensors; \
./h3_bf16_tests misc/fixtures/h3_dit_bf16.safetensors; \
else \
echo "skip: MLX toy-block fixtures are not installed"; \
fi
@if test -f MiniMax-H3/tokenizer/tokenizer.json; then \
./h3_tokenizer_tests MiniMax-H3/tokenizer/tokenizer.json; \
else \
echo "skip: released tokenizer is not installed"; \
fi
@if test -f misc/fixtures/h3_text_bf16.safetensors; then \
./h3_text_tests misc/fixtures/h3_text_bf16.safetensors; \
else \
echo "skip: MLX Qwen fixture is not installed"; \
fi
./h3_audio_gpu_tests
@if test -f MiniMax-H3/FL2VA/audio_vae/model.safetensors && \
test -f misc/fixtures/h3_real_audio_vae_37.safetensors; then \
./h3_real_audio_vae_test; \
else \
echo "skip: released AudioVAE weights/fixture are not installed"; \
fi
@if test -f MiniMax-H3/FL2VA/audio_vae/model.safetensors && \
test -f misc/fixtures/h3_real_audio_encoder_64000.safetensors; then \
./h3_real_audio_encoder_test; \
else \
echo "skip: released audio encoder weights/fixture are not installed"; \
fi
@if command -v ffmpeg >/dev/null 2>&1; then \
./h3_av_mux_test; \
else \
echo "skip: FFmpeg is not installed"; \
fi
@if test -f MiniMax-H3/FL2VA/video_vae/source/model.safetensors && \
test -f misc/fixtures/h3_real_video_encoder_256.safetensors; then \
./h3_real_video_encoder_test; \
else \
echo "skip: released visual encoder weights/fixture are not installed"; \
fi
@if test -f MiniMax-H3/Ref2VA/video_vae/source/model.safetensors && \
test -f misc/fixtures/h3_real_video_encoder_video_22x64.safetensors; then \
./h3_real_video_encoder_test MiniMax-H3 \
misc/fixtures/h3_real_video_encoder_video_22x64.safetensors; \
else \
echo "skip: released reference-video encoder fixture is not installed"; \
fi
@if test -f MiniMax-H3/FL2VA/text_encoder/model-00014-of-00014.safetensors && \
test -f misc/fixtures/h3_real_qwen_vision_64.safetensors; then \
./h3_real_qwen_vision_test; \
else \
echo "skip: released Qwen vision weights/fixture are not installed"; \
fi
@if test -f MiniMax-H3/Ref2VA/text_encoder/model-00014-of-00014.safetensors && \
test -f misc/fixtures/h3_real_qwen_vision_video2x64.safetensors; then \
./h3_real_qwen_vision_test MiniMax-H3 \
misc/fixtures/h3_real_qwen_vision_video2x64.safetensors; \
else \
echo "skip: released Qwen video-pair fixture is not installed"; \
fi
@if test -f MiniMax-H3/FL2VA/text_encoder/model-00001-of-00014.safetensors && \
test -f misc/fixtures/h3_real_multimodal_text_64.safetensors; then \
./h3_real_multimodal_text_test; \
else \
echo "skip: released multimodal Qwen weights/fixture are not installed"; \
fi
@if test -f MiniMax-H3/Ref2VA/text_encoder/model-00001-of-00014.safetensors && \
test -f misc/fixtures/h3_real_ref_video_text_64.safetensors; then \
./h3_real_ref_video_text_test; \
else \
echo "skip: Ref2VA video presentation fixture is not installed"; \
fi
parity: h3_metal_tests h3_bf16_tests h3_text_tests
./h3_metal_tests misc/fixtures/h3_dit.safetensors
./h3_bf16_tests misc/fixtures/h3_dit_bf16.safetensors
./h3_text_tests misc/fixtures/h3_text_bf16.safetensors
real-parity: h3_real_prompt_test h3_real_dit_block_test
./h3_real_prompt_test MiniMax-H3 misc/fixtures/h3_real_prompt_bf16.safetensors
./h3_real_dit_block_test MiniMax-H3 misc/fixtures/h3_real_dit_block0_bf16.safetensors
%.o: %.c
$(CC) $(CFLAGS) -I. -c $< -o $@
%.o: %.m
$(CC) $(OBJCFLAGS) -I. -c $< -o $@
tests/%.o: tests/%.c
$(CC) $(CFLAGS) -I. -c $< -o $@
# Vendored from Iris. Keep the main project strict without rewriting this small
# terminal editor for conversion diagnostics unrelated to H3.
linenoise.o: CFLAGS += -Wno-conversion -Wno-variadic-macro-arguments-omitted
-include $(wildcard *.d tests/*.d)
clean:
rm -f h3 h3_tests h3_metal_tests h3_bf16_tests h3_tokenizer_tests \
h3_text_tests h3_real_prompt_test h3_real_dit_block_test \
h3_audio_gpu_tests h3_real_audio_vae_test h3_real_audio_encoder_test \
h3_av_mux_test \
h3_real_video_encoder_test h3_real_qwen_vision_test \
h3_real_multimodal_text_test h3_real_ref_video_text_test \
h3_real_dit_schedule_test h3_real_dit_test h3_semantic_dit_test \
h3_real_video_vae_test h3_semantic_vae_test \
h3_dit_bench h3_dit_bench_864 \
libh3.a *.o *.d tests/*.o tests/*.d