Run frontier MoE models on hardware you already own β pure C, zero deps, experts streamed from disk. Tiny engine, immense model. π¦
C
refactor(quant): move FP8_BLOCK/fp8_nblk into fp8_format.h
monotophic6826c00a6dc2
diff --git a/c/Makefile b/c/Makefileindex 4842b9fd..9fedfa79 100644--- a/c/Makefile+++ b/c/Makefile@@ -765,7 +765,7 @@ $(file >.build-config,$(BUILD_CONFIG))endif.build-config: ;-colibri$(EXE): colibri.c oracle.h pin_pool.h cli_args.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h quant.h idot.h sample.h kv_persist.h telemetry.h route_trace.h omp_tune.h kv_fp8.h kv_tq.h abl.h backend_cuda.h backend_metal.h backend_vulkan.h decode_batch.h edge_adapters.h edge_runtime.h edge_tok_internal.h schema_gbnf.h segment_adapter_internal.h segment_adapters.h segment_runtime.h tier.h $(CUDA_OBJ) $(METAL_OBJ) $(VK_OBJ) $(VK_SPV) .build-config+colibri$(EXE): colibri.c oracle.h pin_pool.h cli_args.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h route_trace.h omp_tune.h kv_fp8.h kv_tq.h abl.h backend_cuda.h backend_metal.h backend_vulkan.h decode_batch.h edge_adapters.h edge_runtime.h edge_tok_internal.h schema_gbnf.h segment_adapter_internal.h segment_adapters.h segment_runtime.h tier.h $(CUDA_OBJ) $(METAL_OBJ) $(VK_OBJ) $(VK_SPV) .build-config$(CC) $(CFLAGS) colibri.c $(CUDA_OBJ) $(METAL_OBJ) $(VK_OBJ) -o colibri$(EXE) $(LDFLAGS)# Vulkan backend object (plain C + vulkan headers) and its SPIR-V shaders.@@ -1123,7 +1123,7 @@ qwen36$(EXE): qwen36.c decode_batch.h serve_poll.h cli_args.h qwen36_tier.h expe# DeepSeek V4.1 Flash: one file, like every other portable engine. The fp4 experts# stream from the official checkpoint and quant.h's mxfp4 kernel reads them as they# are, so there is no conversion target here to go with it.-deepseek_v41$(EXE): deepseek_v41.c cli_args.h st.h json.h tok.h tok_unicode.h compat.h omp_tune.h kv_prefix.h pin_pool.h quant.h idot.h \+deepseek_v41$(EXE): deepseek_v41.c cli_args.h st.h json.h tok.h tok_unicode.h compat.h omp_tune.h kv_prefix.h pin_pool.h quant.h fp8_format.h idot.h \sparse_attn.h hyper_connections.h serve_codec.h serve_poll.h .build-config$(CC) $(CFLAGS) deepseek_v41.c -o deepseek_v41$(EXE) $(LDFLAGS)@@ -1131,7 +1131,7 @@ deepseek_v41$(EXE): deepseek_v41.c cli_args.h st.h json.h tok.h tok_unicode.h co# loader and SERVE=1 protocol. With CUDA=1 it links the same expert tier as# qwen36 (fp8 streaming mode: hot experts get VRAM copies, the RAM LRU stays);# without it the tier header's inline stubs keep the build toolkit-free.-qwen38$(EXE): qwen38.c pin_pool.h cli_args.h qwen38_core.h kv_prefix.h qwen38_nfc.h qwen38_nfc_tables.h st.h json.h compat.h omp_tune.h quant.h idot.h route_trace.h tok.h tok_unicode.h tok_unicode_o200k.h serve_codec.h edge_adapter_internal.h edge_adapters.h edge_runtime.h qwen38_vision.h segment_adapter_internal.h segment_adapters.h segment_runtime.h qwen36_tier.h $(QWEN36_TIER_SRC) $(CUDA_OBJ)+qwen38$(EXE): qwen38.c pin_pool.h cli_args.h qwen38_core.h kv_prefix.h qwen38_nfc.h qwen38_nfc_tables.h st.h json.h compat.h omp_tune.h quant.h fp8_format.h idot.h route_trace.h tok.h tok_unicode.h tok_unicode_o200k.h serve_codec.h edge_adapter_internal.h edge_adapters.h edge_runtime.h qwen38_vision.h segment_adapter_internal.h segment_adapters.h segment_runtime.h qwen36_tier.h $(QWEN36_TIER_SRC) $(CUDA_OBJ)$(CC) $(QWEN36_CFLAGS) qwen38.c $(QWEN36_TIER_SRC) $(CUDA_OBJ) -o qwen38$(EXE) $(QWEN36_LDFLAGS).PHONY: qwen38-tiny-generate qwen38-tiny-check@@ -1242,10 +1242,10 @@ NOCUDA_LDFLAGS = $(filter-out -lcudart -lstdc++ -lcuda -L$(CUDA_HOME)/lib64 \# GLM-5.3-Flash: routed experts stream from the int4-gs64 container.# METAL=1 accelerates resident matrices and routed MoE; CPU remains fallback.-glm53$(EXE): glm53.c decode_batch.h pin_pool.h cli_args.h st.h json.h stop_ids.h tok.h tok_unicode.h tok_unicode_o200k.h compat.h omp_tune.h serve_poll.h route_trace.h quant.h idot.h hyper_connections.h delta_attention.h sparse_index.h vision_tower.h backend_metal.h backend_vulkan.h edge_adapter_internal.h edge_adapters.h edge_runtime.h segment_adapter_internal.h segment_adapters.h segment_runtime.h $(METAL_OBJ) $(VK_OBJ) $(VK_SPV)+glm53$(EXE): glm53.c decode_batch.h pin_pool.h cli_args.h st.h json.h stop_ids.h tok.h tok_unicode.h tok_unicode_o200k.h compat.h omp_tune.h serve_poll.h route_trace.h quant.h fp8_format.h idot.h hyper_connections.h delta_attention.h sparse_index.h vision_tower.h backend_metal.h backend_vulkan.h edge_adapter_internal.h edge_adapters.h edge_runtime.h segment_adapter_internal.h segment_adapters.h segment_runtime.h $(METAL_OBJ) $(VK_OBJ) $(VK_SPV)$(CC) $(CFLAGS) glm53.c $(METAL_OBJ) $(VK_OBJ) -o glm53$(EXE) $(LDFLAGS)-kimi_k3$(EXE): kimi_k3.c cli_args.h st.h json.h tok.h tok_unicode.h tok_unicode_o200k.h compat.h quant.h idot.h omp_tune.h route_trace.h kv_prefix.h pin_pool.h serve_codec.h backend_cuda.h backend_metal.h backend_vulkan.h edge_adapters.h edge_runtime.h edge_tok_internal.h hybrid_split.h segment_adapter_internal.h segment_adapters.h segment_runtime.h $(CUDA_OBJ) $(VK_OBJ) $(VK_SPV) $(METAL_OBJ)+kimi_k3$(EXE): kimi_k3.c cli_args.h st.h json.h tok.h tok_unicode.h tok_unicode_o200k.h compat.h quant.h fp8_format.h idot.h omp_tune.h route_trace.h kv_prefix.h pin_pool.h serve_codec.h backend_cuda.h backend_metal.h backend_vulkan.h edge_adapters.h edge_runtime.h edge_tok_internal.h hybrid_split.h segment_adapter_internal.h segment_adapters.h segment_runtime.h $(CUDA_OBJ) $(VK_OBJ) $(VK_SPV) $(METAL_OBJ)$(CC) $(CFLAGS) kimi_k3.c $(CUDA_OBJ) $(VK_OBJ) $(METAL_OBJ) -o kimi_k3$(EXE) $(LDFLAGS)# Use a baseline that matches the compiler target. macOS already targets a@@ -1273,7 +1273,7 @@ iobench$(EXE): iobench.c compat.htests/test_serve_sentinel$(EXE): tests/test_serve_sentinel.c compat.h serve_codec.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_cluster_protocol$(EXE): tests/test_cluster_protocol.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h route_trace.h+tests/test_cluster_protocol$(EXE): tests/test_cluster_protocol.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h route_trace.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)tests/test_ue8m0$(EXE): tests/test_ue8m0.c st.h json.h compat.h@@ -1288,10 +1288,10 @@ tests/test_tok_o200k$(EXE): tests/test_tok_o200k.c tok.h tok_unicode.h tok_unicotests/test_tok_gpt2$(EXE): tests/test_tok_gpt2.c tok.h tok_unicode.h tok_unicode_o200k.h json.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_k3_ram_budget$(EXE): tests/test_k3_ram_budget.c kimi_k3.c st.h tok.h quant.h idot.h compat.h omp_tune.h route_trace.h kv_prefix.h serve_codec.h+tests/test_k3_ram_budget$(EXE): tests/test_k3_ram_budget.c kimi_k3.c st.h tok.h quant.h fp8_format.h idot.h compat.h omp_tune.h route_trace.h kv_prefix.h serve_codec.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_k3_mmap$(EXE): tests/test_k3_mmap.c kimi_k3.c st.h tok.h quant.h idot.h compat.h omp_tune.h route_trace.h kv_prefix.h serve_codec.h+tests/test_k3_mmap$(EXE): tests/test_k3_mmap.c kimi_k3.c st.h tok.h quant.h fp8_format.h idot.h compat.h omp_tune.h route_trace.h kv_prefix.h serve_codec.h$(CC) $(NOCUDA_CFLAGS) $< $(VK_OBJ) -o $@ $(NOCUDA_LDFLAGS)tests/test_tok_kimi_tiny$(EXE): tests/test_tok_kimi_tiny.c tok.h tok_unicode.h tok_unicode_o200k.h json.h@@ -1302,19 +1302,19 @@ tests/test_st_pread$(EXE): tests/test_st_pread.c st.h json.h compat.htests/test_st_slice$(EXE): tests/test_st_slice.c st.h json.h compat.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_qwen38_tokenizer$(EXE): tests/test_qwen38_tokenizer.c qwen38.c qwen38_core.h kv_prefix.h qwen38_nfc.h qwen38_nfc_tables.h edge_runtime.c edge_runtime.h edge_adapters.h edge_adapter_internal.h st.h json.h compat.h quant.h idot.h route_trace.h tok_unicode.h tok_unicode_o200k.h+tests/test_qwen38_tokenizer$(EXE): tests/test_qwen38_tokenizer.c qwen38.c qwen38_core.h kv_prefix.h qwen38_nfc.h qwen38_nfc_tables.h edge_runtime.c edge_runtime.h edge_adapters.h edge_adapter_internal.h st.h json.h compat.h quant.h fp8_format.h idot.h route_trace.h tok_unicode.h tok_unicode_o200k.h$(CC) $(NOCUDA_CFLAGS) $< edge_runtime.c -o $@ $(NOCUDA_LDFLAGS)-tests/test_qwen38_config$(EXE): tests/test_qwen38_config.c qwen38.c qwen38_core.h kv_prefix.h qwen38_nfc.h qwen38_nfc_tables.h st.h json.h compat.h quant.h idot.h route_trace.h tok_unicode.h tok_unicode_o200k.h+tests/test_qwen38_config$(EXE): tests/test_qwen38_config.c qwen38.c qwen38_core.h kv_prefix.h qwen38_nfc.h qwen38_nfc_tables.h st.h json.h compat.h quant.h fp8_format.h idot.h route_trace.h tok_unicode.h tok_unicode_o200k.h$(CC) $(NOCUDA_CFLAGS) $< -o $@ $(NOCUDA_LDFLAGS)-tests/test_dsv41_serve_budget$(EXE): tests/test_dsv41_serve_budget.c deepseek_v41.c cli_args.h st.h json.h tok.h tok_unicode.h compat.h omp_tune.h kv_prefix.h pin_pool.h quant.h idot.h sparse_attn.h hyper_connections.h serve_codec.h serve_poll.h+tests/test_dsv41_serve_budget$(EXE): tests/test_dsv41_serve_budget.c deepseek_v41.c cli_args.h st.h json.h tok.h tok_unicode.h compat.h omp_tune.h kv_prefix.h pin_pool.h quant.h fp8_format.h idot.h sparse_attn.h hyper_connections.h serve_codec.h serve_poll.h$(CC) $(NOCUDA_CFLAGS) $< -o $@ $(NOCUDA_LDFLAGS)-tests/test_qwen38_idot$(EXE): tests/test_qwen38_idot.c qwen38.c qwen38_core.h kv_prefix.h qwen38_nfc.h qwen38_nfc_tables.h st.h json.h compat.h quant.h idot.h route_trace.h tok_unicode.h tok_unicode_o200k.h+tests/test_qwen38_idot$(EXE): tests/test_qwen38_idot.c qwen38.c qwen38_core.h kv_prefix.h qwen38_nfc.h qwen38_nfc_tables.h st.h json.h compat.h quant.h fp8_format.h idot.h route_trace.h tok_unicode.h tok_unicode_o200k.h$(CC) $(NOCUDA_CFLAGS) $< -o $@ $(NOCUDA_LDFLAGS)-tests/test_qwen38_serve_framing$(EXE): tests/test_qwen38_serve_framing.c qwen38.c qwen38_core.h kv_prefix.h qwen38_nfc.h qwen38_nfc_tables.h st.h json.h compat.h quant.h idot.h route_trace.h serve_codec.h tok_unicode.h tok_unicode_o200k.h+tests/test_qwen38_serve_framing$(EXE): tests/test_qwen38_serve_framing.c qwen38.c qwen38_core.h kv_prefix.h qwen38_nfc.h qwen38_nfc_tables.h st.h json.h compat.h quant.h fp8_format.h idot.h route_trace.h serve_codec.h tok_unicode.h tok_unicode_o200k.h$(CC) $(NOCUDA_CFLAGS) $< -o $@ $(NOCUDA_LDFLAGS)tests/test_qwen38_vision$(EXE): tests/test_qwen38_vision.c qwen38_vision.h st.h json.h compat.h@@ -1336,13 +1336,13 @@ qwen38-vision-serve-check: qwen38$(EXE)$(PYTHON) tools/make_edge_tiny_tokenizer.py --vocab-size 64 ./qwen38_mm_tiny$(PYTHON) tests/test_qwen38_vision_serve.py --binary ./qwen38$(EXE) --fixture ./qwen38_mm_tiny-tests/test_qwen38_prefix$(EXE): tests/test_qwen38_prefix.c qwen38.c qwen38_core.h kv_prefix.h qwen38_nfc.h qwen38_nfc_tables.h st.h json.h compat.h quant.h idot.h route_trace.h serve_codec.h tok_unicode.h tok_unicode_o200k.h+tests/test_qwen38_prefix$(EXE): tests/test_qwen38_prefix.c qwen38.c qwen38_core.h kv_prefix.h qwen38_nfc.h qwen38_nfc_tables.h st.h json.h compat.h quant.h fp8_format.h idot.h route_trace.h serve_codec.h tok_unicode.h tok_unicode_o200k.h$(CC) $(NOCUDA_CFLAGS) $< -o $@ $(NOCUDA_LDFLAGS)-tests/test_qwen38_metrics$(EXE): tests/test_qwen38_metrics.c qwen38.c qwen38_core.h kv_prefix.h qwen38_nfc.h qwen38_nfc_tables.h st.h json.h compat.h quant.h idot.h route_trace.h serve_codec.h tok_unicode.h tok_unicode_o200k.h+tests/test_qwen38_metrics$(EXE): tests/test_qwen38_metrics.c qwen38.c qwen38_core.h kv_prefix.h qwen38_nfc.h qwen38_nfc_tables.h st.h json.h compat.h quant.h fp8_format.h idot.h route_trace.h serve_codec.h tok_unicode.h tok_unicode_o200k.h$(CC) $(NOCUDA_CFLAGS) $< -o $@ $(NOCUDA_LDFLAGS)-tests/test_qwen38_native_weights$(EXE): tests/test_qwen38_native_weights.c qwen38.c qwen38_core.h kv_prefix.h qwen38_nfc.h qwen38_nfc_tables.h segment_runtime.c segment_runtime.h segment_adapters.h segment_adapter_internal.h st.h json.h compat.h quant.h idot.h route_trace.h serve_codec.h tok_unicode.h tok_unicode_o200k.h+tests/test_qwen38_native_weights$(EXE): tests/test_qwen38_native_weights.c qwen38.c qwen38_core.h kv_prefix.h qwen38_nfc.h qwen38_nfc_tables.h segment_runtime.c segment_runtime.h segment_adapters.h segment_adapter_internal.h st.h json.h compat.h quant.h fp8_format.h idot.h route_trace.h serve_codec.h tok_unicode.h tok_unicode_o200k.h$(CC) $(NOCUDA_CFLAGS) $< segment_runtime.c -o $@ $(NOCUDA_LDFLAGS)tests/test_st_map$(EXE): tests/test_st_map.c st.h json.h compat.h@@ -1388,12 +1388,12 @@ tests/test_grammar$(EXE): tests/test_grammar.c grammar.h# equivalence under the shipping flags is covered by the differential dump# (old vs new rope_interleave are byte-identical); this test guards the# source-level formula equivalence and must not depend on contraction luck.-tests/test_rope_invfreq$(EXE): tests/test_rope_invfreq.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h route_trace.h+tests/test_rope_invfreq$(EXE): tests/test_rope_invfreq.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h route_trace.h$(CC) $(CFLAGS) -ffp-contract=off $< -o $@ $(LDFLAGS)# schema->GBNF compile cache (#7): grammar_reset must equal a fresh setup, and# the GrDraft.src ownership must not leak/double-free. Includes colibri.c.-tests/test_grammar_cache$(EXE): tests/test_grammar_cache.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h route_trace.h+tests/test_grammar_cache$(EXE): tests/test_grammar_cache.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h route_trace.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)# Standalone: drives a faithful miniature of moe()'s routing+accumulate and links@@ -1409,7 +1409,7 @@ tests/test_degrade_zero$(EXE): tests/test_degrade_zero.ctests/test_schema_gbnf$(EXE): tests/test_schema_gbnf.c schema_gbnf.h grammar.h json.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_spec_decode_state$(EXE): tests/test_spec_decode_state.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h route_trace.h+tests/test_spec_decode_state$(EXE): tests/test_spec_decode_state.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h route_trace.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)tests/test_decode_batch$(EXE): tests/test_decode_batch.c decode_batch.h@@ -1441,13 +1441,13 @@ tests/bench_inkling_shared_batch$(EXE): tests/bench_inkling_shared_batch.c inklitests/test_inkling_cache_index$(EXE): tests/test_inkling_cache_index.c inkling.c st.h json.h tok.h tok_unicode.h tok_unicode_o200k.h compat.h omp_tune.h route_trace.h kv_prefix.h serve_codec.h $(INK_CUDA_OBJ) $(METAL_OBJ)$(CC) $(CFLAGS) $< $(INK_CUDA_OBJ) $(METAL_OBJ) -o $@ $(LDFLAGS)-tests/test_kimi_serve_framing$(EXE): tests/test_kimi_serve_framing.c kimi_k3.c kv_prefix.h serve_codec.h st.h json.h tok.h tok_unicode.h tok_unicode_o200k.h compat.h quant.h idot.h omp_tune.h route_trace.h+tests/test_kimi_serve_framing$(EXE): tests/test_kimi_serve_framing.c kimi_k3.c kv_prefix.h serve_codec.h st.h json.h tok.h tok_unicode.h tok_unicode_o200k.h compat.h quant.h fp8_format.h idot.h omp_tune.h route_trace.h$(CC) $(NOCUDA_CFLAGS) $< $(VK_OBJ) -o $@ $(NOCUDA_LDFLAGS)-tests/test_kimi_cache_index$(EXE): tests/test_kimi_cache_index.c kimi_k3.c kv_prefix.h serve_codec.h st.h json.h tok.h tok_unicode.h tok_unicode_o200k.h compat.h quant.h idot.h omp_tune.h route_trace.h+tests/test_kimi_cache_index$(EXE): tests/test_kimi_cache_index.c kimi_k3.c kv_prefix.h serve_codec.h st.h json.h tok.h tok_unicode.h tok_unicode_o200k.h compat.h quant.h fp8_format.h idot.h omp_tune.h route_trace.h$(CC) $(NOCUDA_CFLAGS) $< $(VK_OBJ) -o $@ $(NOCUDA_LDFLAGS)-tests/test_k3_chat_tools$(EXE): tests/test_k3_chat_tools.c kimi_k3.c kv_prefix.h serve_codec.h st.h json.h tok.h tok_unicode.h tok_unicode_o200k.h compat.h quant.h idot.h omp_tune.h route_trace.h+tests/test_k3_chat_tools$(EXE): tests/test_k3_chat_tools.c kimi_k3.c kv_prefix.h serve_codec.h st.h json.h tok.h tok_unicode.h tok_unicode_o200k.h compat.h quant.h fp8_format.h idot.h omp_tune.h route_trace.h$(CC) $(NOCUDA_CFLAGS) $< $(VK_OBJ) -o $@ $(NOCUDA_LDFLAGS)# olmoe's matmul_q, not colibri's: compares the IDOT path against FP32@@ -1465,33 +1465,33 @@ tests/test_olmoe_cache_index$(EXE): tests/test_olmoe_cache_index.c olmoe.c st.htests/test_qwen36_cache_index$(EXE): tests/test_qwen36_cache_index.c qwen36.c expert_ffn.h st.h json.h compat.h sample.h tok.h tok_unicode.h tok_unicode_o200k.h omp_tune.h route_trace.h serve_codec.h qwen36_tier.h $(QWEN36_TIER_SRC) $(CUDA_OBJ)$(CC) $(QWEN36_CFLAGS) $< $(QWEN36_TIER_SRC) $(CUDA_OBJ) -o $@ $(QWEN36_LDFLAGS)-tests/test_idot$(EXE): tests/test_idot.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h route_trace.h+tests/test_idot$(EXE): tests/test_idot.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h route_trace.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_i4_grouped$(EXE): tests/test_i4_grouped.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h route_trace.h+tests/test_i4_grouped$(EXE): tests/test_i4_grouped.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h route_trace.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_stops$(EXE): tests/test_stops.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h route_trace.h+tests/test_stops$(EXE): tests/test_stops.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h route_trace.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_cfg_topk$(EXE): tests/test_cfg_topk.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h route_trace.h+tests/test_cfg_topk$(EXE): tests/test_cfg_topk.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h route_trace.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_topp$(EXE): tests/test_topp.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h route_trace.h+tests/test_topp$(EXE): tests/test_topp.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h route_trace.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)# bench_topp is a microbenchmark (old qsort vs new heap partial-select, #335), NOT a test# gate -- intentionally absent from TEST_BINS. Build on demand: make tests/bench_topp-tests/bench_topp$(EXE): tests/bench_topp.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h route_trace.h+tests/bench_topp$(EXE): tests/bench_topp.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h route_trace.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_sample_nan$(EXE): tests/test_sample_nan.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h route_trace.h+tests/test_sample_nan$(EXE): tests/test_sample_nan.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h route_trace.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_temp_env$(EXE): tests/test_temp_env.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h route_trace.h+tests/test_temp_env$(EXE): tests/test_temp_env.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h route_trace.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_kv_alloc$(EXE): tests/test_kv_alloc.c colibri.c oracle.h st.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h route_trace.h kv_fp8.h kv_tq.h+tests/test_kv_alloc$(EXE): tests/test_kv_alloc.c colibri.c oracle.h st.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h route_trace.h kv_fp8.h kv_tq.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)tests/test_kv_fp8$(EXE): tests/test_kv_fp8.c kv_fp8.h decode_batch.h@@ -1500,15 +1500,15 @@ tests/test_kv_fp8$(EXE): tests/test_kv_fp8.c kv_fp8.h decode_batch.htests/test_kv_tq$(EXE): tests/test_kv_tq.c kv_tq.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_kv_disk$(EXE): tests/test_kv_disk.c colibri.c oracle.h st.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h route_trace.h kv_fp8.h kv_tq.h+tests/test_kv_disk$(EXE): tests/test_kv_disk.c colibri.c oracle.h st.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h route_trace.h kv_fp8.h kv_tq.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)# fmt=6 kernel oracle: needs the generated grid table, and its fixture comes from# the reference codec (tools/make_e8_fixture.py) β regenerate if the layout moves.-tests/test_e8_kernel$(EXE): tests/test_e8_kernel.c quant.h idot.h+tests/test_e8_kernel$(EXE): tests/test_e8_kernel.c quant.h fp8_format.h idot.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_e4m3_vector$(EXE): tests/test_e4m3_vector.c quant.h idot.h+tests/test_e4m3_vector$(EXE): tests/test_e4m3_vector.c quant.h fp8_format.h idot.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)tests/test_stop_ids$(EXE): tests/test_stop_ids.c stop_ids.h json.h@@ -1535,13 +1535,13 @@ fuzz-rans: tests/fuzz_rans.c rans.htests/fuzz_rans.c -o tests/fuzz_rans -lm./tests/fuzz_rans-tests/test_int3$(EXE): tests/test_int3.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h route_trace.h+tests/test_int3$(EXE): tests/test_int3.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h route_trace.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_int3_load$(EXE): tests/test_int3_load.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h route_trace.h+tests/test_int3_load$(EXE): tests/test_int3_load.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h route_trace.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_fp8_passthrough$(EXE): tests/test_fp8_passthrough.c quant.h idot.h+tests/test_fp8_passthrough$(EXE): tests/test_fp8_passthrough.c quant.h fp8_format.h idot.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)# Host-only: backend_cuda.h's format predicate is plain C, so its truth table is@@ -1550,10 +1550,10 @@ tests/test_fp8_passthrough$(EXE): tests/test_fp8_passthrough.c quant.h idot.htests/test_cuda_fmt_guard$(EXE): tests/test_cuda_fmt_guard.c backend_cuda.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_fp8_load$(EXE): tests/test_fp8_load.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h+tests/test_fp8_load$(EXE): tests/test_fp8_load.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_qt_addrow$(EXE): tests/test_qt_addrow.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h+tests/test_qt_addrow$(EXE): tests/test_qt_addrow.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)tests/test_logit_nan$(EXE): tests/test_logit_nan.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h@@ -1571,7 +1571,7 @@ tests/test_compat_direct$(EXE): tests/test_compat_direct.c compat.htests/test_expert_store_ops$(EXE): tests/test_expert_store_ops.c expert_store.h tensor.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_native_quant$(EXE): tests/test_native_quant.c deepseek_v4.c native_quant.h tensor.h quant.h idot.h+tests/test_native_quant$(EXE): tests/test_native_quant.c deepseek_v4.c native_quant.h tensor.h quant.h fp8_format.h idot.h$(CC) $(CFLAGS) -DCOLI_V4_UNIT_NATIVE_QUANT deepseek_v4.c $< -o $@ $(LDFLAGS)tests/test_edge_runtime$(EXE): tests/test_edge_runtime.c edge_runtime.c edge_runtime.h@@ -1616,7 +1616,7 @@ $(SEGMENT_BUILD_DIR)/glm.o: colibri.c oracle.h segment_runtime.h edge_runtime.h$(SEGMENT_BUILD_DIR)/glm53.o: glm53.c segment_runtime.h edge_runtime.h \segment_adapters.h edge_adapters.h segment_adapter_internal.h \- edge_adapter_internal.h st.h quant.h tok.h hyper_connections.h \+ edge_adapter_internal.h st.h quant.h fp8_format.h tok.h hyper_connections.h \delta_attention.h sparse_index.h vision_tower.h | $(SEGMENT_BUILD_DIR)$(CC) $(SEGMENT_CPU_CFLAGS) -DGLM53_NO_MAIN -c glm53.c -o $@@@ -1642,7 +1642,7 @@ $(SEGMENT_BUILD_DIR)/qwen36.o: qwen36.c segment_runtime.h edge_runtime.h \$(SEGMENT_BUILD_DIR)/qwen38.o: qwen38.c qwen38_core.h kv_prefix.h segment_runtime.h \segment_adapters.h segment_adapter_internal.h edge_runtime.h \- edge_adapters.h edge_adapter_internal.h st.h json.h compat.h quant.h \+ edge_adapters.h edge_adapter_internal.h st.h json.h compat.h quant.h fp8_format.h \qwen38_nfc.h qwen38_nfc_tables.h route_trace.h tok_unicode.h \tok_unicode_o200k.h | $(SEGMENT_BUILD_DIR)$(CC) $(SEGMENT_CPU_CFLAGS) -DQWEN38_NO_MAIN -c qwen38.c -o $@@@ -1808,7 +1808,7 @@ $(V4_OWN_DIR)/COLI_V4_UNIT_CONFIG.o: deepseek_v4.c deepseek_v4.h deepseek_v4_int$(V4_OWN_DIR)/COLI_V4_UNIT_ST.o: deepseek_v4.c deepseek_v4.h deepseek_v4_internal.h st.h | $(V4_OWN_DIR)$(CC) $(V4_OWN_CFLAGS) -DCOLI_V4_UNIT_ST -c deepseek_v4.c -o $@-$(V4_OWN_DIR)/COLI_V4_UNIT_NATIVE_QUANT.o: deepseek_v4.c deepseek_v4.h deepseek_v4_internal.h quant.h idot.h | $(V4_OWN_DIR)+$(V4_OWN_DIR)/COLI_V4_UNIT_NATIVE_QUANT.o: deepseek_v4.c deepseek_v4.h deepseek_v4_internal.h quant.h fp8_format.h idot.h | $(V4_OWN_DIR)$(CC) $(V4_OWN_CFLAGS) -DCOLI_V4_UNIT_NATIVE_QUANT -c deepseek_v4.c -o $@# The engine (RUNTIME unit) opens its expert store through the pluggable@@ -1937,7 +1937,7 @@ tests/test_qwen36_tier_int8_decode$(EXE): tests/test_qwen36_tier_int8_decode.c t# The qwen38 engine through its own main() on the fake backend: tier start# from the FP8 fixture, reduced CPU list, qt_note on recycled slots, oracle# tokens unchanged. Needs the fixture (qwen38-tiny-fp8-generate).-tests/test_qwen38_tier_engine$(EXE): tests/test_qwen38_tier_engine.c tests/qwen36_fake_cuda.h qwen38.c qwen38_core.h kv_prefix.h qwen36_tier.c qwen36_tier.h backend_cuda.h cli_args.h st.h json.h compat.h quant.h idot.h route_trace.h+tests/test_qwen38_tier_engine$(EXE): tests/test_qwen38_tier_engine.c tests/qwen36_fake_cuda.h qwen38.c qwen38_core.h kv_prefix.h qwen36_tier.c qwen36_tier.h backend_cuda.h cli_args.h st.h json.h compat.h quant.h fp8_format.h idot.h route_trace.h$(CC) $(CFLAGS) -DCOLI_CUDA $< -o $@ $(LDFLAGS)tests/test_serve_poll$(EXE): tests/test_serve_poll.c serve_poll.h@@ -1956,15 +1956,15 @@ tests/test_mem_available$(EXE): tests/test_mem_available.c compat.htests/test_798_guards$(EXE): tests/test_798_guards.c st.h json.h compat.h route_trace.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_dsa_select$(EXE): tests/test_dsa_select.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h route_trace.h+tests/test_dsa_select$(EXE): tests/test_dsa_select.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h route_trace.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_corpus_draft$(EXE): tests/test_corpus_draft.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h route_trace.h+tests/test_corpus_draft$(EXE): tests/test_corpus_draft.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h route_trace.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_cap_precedence$(EXE): tests/test_cap_precedence.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h+tests/test_cap_precedence$(EXE): tests/test_cap_precedence.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_mirror_stripe_split$(EXE): tests/test_mirror_stripe_split.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h+tests/test_mirror_stripe_split$(EXE): tests/test_mirror_stripe_split.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)tests/test_v4_hybrid_policy$(EXE): tests/test_v4_hybrid_policy.c deepseek_v4_hybrid.h hybrid_split.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)@@ -1975,29 +1975,29 @@ tests/test_k3_fill_budget$(EXE): tests/test_k3_fill_budget.c hybrid_split.htests/test_v4_bank_pair$(EXE): tests/test_v4_bank_pair.c deepseek_v4_bank_pair.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_ram_clamp$(EXE): tests/test_ram_clamp.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h+tests/test_ram_clamp$(EXE): tests/test_ram_clamp.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_cap_mixed_width$(EXE): tests/test_cap_mixed_width.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h route_trace.h+tests/test_cap_mixed_width$(EXE): tests/test_cap_mixed_width.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h route_trace.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_eslot_inflight$(EXE): tests/test_eslot_inflight.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h route_trace.h+tests/test_eslot_inflight$(EXE): tests/test_eslot_inflight.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h route_trace.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_glm_cache_index$(EXE): tests/test_glm_cache_index.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h route_trace.h+tests/test_glm_cache_index$(EXE): tests/test_glm_cache_index.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h route_trace.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_ssd_probe$(EXE): tests/test_ssd_probe.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h+tests/test_ssd_probe$(EXE): tests/test_ssd_probe.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)# bench_dsa_select is a microbenchmark (old qsort vs new quickselect partial-select, #356),# NOT a test gate -- intentionally absent from TEST_BINS. Build on demand: make tests/bench_dsa_select-tests/bench_dsa_select$(EXE): tests/bench_dsa_select.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h route_trace.h+tests/bench_dsa_select$(EXE): tests/bench_dsa_select.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h route_trace.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)# bench_router_select is a microbenchmark (duplicate-prefix scan vs marked-score scan),# not a test gate. Build on demand: make tests/bench_router_select.-tests/bench_router_select$(EXE): tests/bench_router_select.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h route_trace.h+tests/bench_router_select$(EXE): tests/bench_router_select.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h route_trace.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)# bench_indexer_allocations: microbenchmark (DeepSeek V4 indexer malloc vs persistent arena scratch), NOT a test gate.@@ -2007,34 +2007,34 @@ tests/bench_indexer_allocations$(EXE): tests/bench_indexer_allocations.c# bench_idot: microbenchmark (single-acc vs independent-acc AVX-VNNI idot), NOT a test gate.# Build on demand on an AVX-VNNI CPU: make tests/bench_idot ARCH=native-tests/bench_idot$(EXE): tests/bench_idot.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h route_trace.h+tests/bench_idot$(EXE): tests/bench_idot.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h route_trace.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)# bench_i4p_gidot: microbenchmark (per-row vs multi-row/AMX K1b grouped planar IDOT), NOT a test gate.# Build on demand: make tests/bench_i4p_gidot ARCH=native-tests/bench_i4p_gidot$(EXE): tests/bench_i4p_gidot.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h route_trace.h+tests/bench_i4p_gidot$(EXE): tests/bench_i4p_gidot.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h route_trace.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)# bench_gemv_stream: microbenchmark (decode-regime GEMV bandwidth vs the read ceiling;# frozen-baseline + deinterleaved-x candidate A/B), NOT a test gate.# Build on demand: make tests/bench_gemv_stream ARCH=native-tests/bench_gemv_stream$(EXE): tests/bench_gemv_stream.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h route_trace.h+tests/bench_gemv_stream$(EXE): tests/bench_gemv_stream.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h route_trace.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)# bench_mla_simd: microbenchmark (scalar vs AVX2/NEON MLA-absorb reductions, #442),# NOT a test gate. Build on demand: make tests/bench_mla_simd-tests/bench_mla_simd$(EXE): tests/bench_mla_simd.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h route_trace.h+tests/bench_mla_simd$(EXE): tests/bench_mla_simd.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h route_trace.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_uring$(EXE): tests/test_uring.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h route_trace.h+tests/test_uring$(EXE): tests/test_uring.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h route_trace.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)tests/test_pipe_block$(EXE): tests/test_pipe_block.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_pilot_ring$(EXE): tests/test_pilot_ring.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h+tests/test_pilot_ring$(EXE): tests/test_pilot_ring.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_moe_gs_guard$(EXE): tests/test_moe_gs_guard.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h+tests/test_moe_gs_guard$(EXE): tests/test_moe_gs_guard.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)tests/test_omp_tune$(EXE): tests/test_omp_tune.c omp_tune.h compat.h@@ -2043,7 +2043,7 @@ tests/test_omp_tune$(EXE): tests/test_omp_tune.c omp_tune.h compat.htests/test_compat_env$(EXE): tests/test_compat_env.c compat.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)-tests/test_kvb_notice$(EXE): tests/test_kvb_notice.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h idot.h sample.h kv_persist.h telemetry.h+tests/test_kvb_notice$(EXE): tests/test_kvb_notice.c colibri.c oracle.h st.h uring.h json.h tok.h tok_unicode.h compat.h grammar.h tier.h quant.h fp8_format.h idot.h sample.h kv_persist.h telemetry.h$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)# Standalone: proves the group-scaled int8 GEMV keeps every row's float@@ -2216,7 +2216,7 @@ bench: iobench$(EXE)tests/test_kv_prefix$(EXE): tests/test_kv_prefix.c kv_prefix.h$(CC) $(CFLAGS) tests/test_kv_prefix.c -o tests/test_kv_prefix$(EXE) $(LDFLAGS)-tests/test_kimi_request_state$(EXE): tests/test_kimi_request_state.c kimi_k3.c kv_prefix.h serve_codec.h st.h json.h tok.h tok_unicode.h tok_unicode_o200k.h compat.h quant.h idot.h omp_tune.h route_trace.h+tests/test_kimi_request_state$(EXE): tests/test_kimi_request_state.c kimi_k3.c kv_prefix.h serve_codec.h st.h json.h tok.h tok_unicode.h tok_unicode_o200k.h compat.h quant.h fp8_format.h idot.h omp_tune.h route_trace.h$(CC) $(NOCUDA_CFLAGS) tests/test_kimi_request_state.c $(VK_OBJ) -o tests/test_kimi_request_state$(EXE) $(NOCUDA_LDFLAGS)# Kimi CUDA dispatch/fallback with a fake backend; no CUDA toolkit required.diff --git a/c/Makefile.deepseek-v4 b/c/Makefile.deepseek-v4index a7858363..5426cecd 100644--- a/c/Makefile.deepseek-v4+++ b/c/Makefile.deepseek-v4@@ -246,20 +246,20 @@ $(REGISTRY_OBJ): expert_store_registry.c expert_store_registry.h expert_store.h$(CC) $(CFLAGS) -c expert_store_registry.c -o $@$(TARGET_OBJS) $(TEST_UNIT_OBJS): %.o: deepseek_v4.c deepseek_v4.h \- deepseek_v4_internal.h deepseek_v4_dspark.inc st.h json.h compat.h tensor.h quant.h \+ deepseek_v4_internal.h deepseek_v4_dspark.inc st.h json.h compat.h tensor.h quant.h fp8_format.h \route_trace.h \native_quant.h native_quant_batch.h native_quant_dual.h \native_quant_fp4_rows16.h expert_store_registry.h$(CC) $(CFLAGS) -D$* -c deepseek_v4.c -o $@$(V4_HOT_TEST_OBJ): deepseek_v4.c deepseek_v4.h deepseek_v4_internal.h \- st.h json.h compat.h tensor.h quant.h route_trace.h \+ st.h json.h compat.h tensor.h quant.h fp8_format.h route_trace.h \native_quant.h native_quant_fp4_rows16.h expert_store_registry.h$(CC) $(CFLAGS) -DCOLI_V4_TEST_HOOKS \-DCOLI_V4_UNIT_EXPERT_STORE_HOT_ROWS16 -c deepseek_v4.c -o $@$(V4_BATCH_TEST_OBJ): deepseek_v4.c deepseek_v4.h deepseek_v4_internal.h \- tensor.h quant.h native_quant.h native_quant_batch.h+ tensor.h quant.h fp8_format.h native_quant.h native_quant_batch.h$(CC) $(CFLAGS) -DCOLI_V4_TEST_HOOKS \-DCOLI_V4_UNIT_NATIVE_QUANT_BATCH -c deepseek_v4.c -o $@diff --git a/c/backend_metal.mm b/c/backend_metal.mmindex e3497320..3b767e2b 100644--- a/c/backend_metal.mm+++ b/c/backend_metal.mm@@ -767,7 +767,7 @@ static size_t fmt_bytes(int fmt, int I, int O) {// Grouped-int4 (fmt=4) scale-array size: one f32 per gsz-element group, per row -> O*ceil(I/gsz).// fp8 (fmt=8) scale-array size: one f32 per 128x128 BLOCK -> ceil(O/128)*ceil(I/128) (2D,// not per-row -- quant.h isn't included here, so the ceil-div is inlined rather than sharing-// colibri.c's qt_scale_bytes/quant.h's fp8_nblk). The block is a fixed 128x128, so gs is+// colibri.c's qt_scale_bytes/fp8_format.h's fp8_nblk). The block is a fixed 128x128, so gs is// ignored for fmt==8. f32 is this build's implemented scale// ENCODING for fmt=8 (see quant.h/colibri.c) -- this file has no reason to know that a// UE8M0 encoding exists at all: qt_resolve_fmt refuses it on the CPU read path before anydiff --git a/c/colibri.c b/c/colibri.cindex a96ccba4..64bf3680 100644--- a/c/colibri.c+++ b/c/colibri.c@@ -286,9 +286,10 @@ static int64_t qt_bytes(const QT *t){ /* byte residenti del tensore */return (int64_t)t->O*(((int64_t)t->I+255)/256)*98 + 4;if(t->fmt==8){ /* fp8-e4m3 passthrough: O*I raw e4m3 bytes (n, byte-identical layout* to fmt=1's weight bytes) + one f32 scale per 128x128 block- * (FP8_BLOCK in quant.h, included below qt_bytes -- keep the- * arithmetic literal here, same discipline as fmt=5's comment- * above). Missing this branch would fall through to the fmt=2+ * (FP8_BLOCK in fp8_format.h via quant.h, included below+ * qt_bytes -- keep the arithmetic literal here, same+ * discipline as fmt=5's comment above). Missing this branch would+ * fall through to the fmt=2* default below (packed-nibble formula, ~half the real weight* bytes) and undercount a resident fp8 tensor's byte footprint --* feeds AUTOPIN/RAM-budget math, so this branch is load-bearingdiff --git a/c/fp8_format.h b/c/fp8_format.hnew file mode 100644index 00000000..4c465c2b--- /dev/null+++ b/c/fp8_format.h@@ -0,0 +1,30 @@+/* fmt=8 (fp8-e4m3-b128) block geometry -- the single definition site for the+ * 128x128 scale-block edge. Every consumer reaches these symbols through+ * quant.h, which includes this header where the definitions used to live:+ * matmul_fp8 and the e4m3 dequant plumbing (quant.h), the qt_addrow /+ * qt_matvec_rows / qt_from_disk paths (colibri.c), and the native-FP8+ * reduction (qwen38.c / qwen38_core.h). Kept deliberately tiny (no LUTs, no+ * functions with OpenMP pragmas, no intrinsics) so a translation unit that+ * cannot include quant.h itself can still name the block edge instead of+ * restating 128 / >>7 as literals.+ *+ * The in-repo FP8 tests are NOT independent of this constant: the reference+ * decoders in test_fp8_passthrough.c, test_fp8_load.c, test_fp8_e2e_loader.c+ * and test_qwen38_native_weights.c all index with FP8_BLOCK/fp8_nblk via+ * quant.h, so they move in lockstep with an edit here (only+ * test_backend_metal.mm's ref_fp8_nblk keeps its own literal, on purpose).+ * An edit to FP8_BLOCK is a format change, not a tunable -- those tests+ * cannot catch a wrong edit on their own. */+#ifndef COLI_FP8_FORMAT_H+#define COLI_FP8_FORMAT_H++#include <stdint.h>++#define FP8_BLOCK 128++/* Blocks covering n elements: ceil(n/FP8_BLOCK). Plain C on purpose --+ * nothing in this header may need decoration or a special front end, so it+ * stays includable from any translation unit. */+static inline int64_t fp8_nblk(int n){ return ((int64_t)n + FP8_BLOCK - 1) / FP8_BLOCK; }++#endif /* COLI_FP8_FORMAT_H */diff --git a/c/quant.h b/c/quant.hindex 91cf7549..2c648678 100644--- a/c/quant.h+++ b/c/quant.h@@ -518,8 +518,10 @@ static inline __m256 bf16_decode8(const uint16_t *p) {}#endif-#define FP8_BLOCK 128-static inline int64_t fp8_nblk(int n){ return ((int64_t)n + FP8_BLOCK - 1) / FP8_BLOCK; }+/* FP8_BLOCK / fp8_nblk moved to fp8_format.h so the CUDA backend shares the+ * same named constant instead of restating 128 as literals (see that header's+ * comment for the drift hazard this closes). */+#include "fp8_format.h"/* y[S,O] = x[S,I] @ W^T, W raw e4m3 bytes (byte-identical layout to fmt=1) +* per-128x128-BLOCK f32 scale [ceil(O/128),ceil(I/128)]. Scalar reference pathdiff --git a/c/tests/test_makefile_deps.py b/c/tests/test_makefile_deps.pyindex be1c48e5..cfb2903a 100644--- a/c/tests/test_makefile_deps.py+++ b/c/tests/test_makefile_deps.py@@ -84,6 +84,58 @@ class MakefileHeaderDepsTest(unittest.TestCase):f"{family.id}: registered family whose build target is not "f"a checkable `{family.build_target}$(EXE):` rule")+ def test_every_engine_rule_lists_fp8_format_h_if_it_reaches_it(self):+ """A prerequisite reached THROUGH another header is still a prerequisite.++ The check below walks only an engine's own `#include "..."` lines, so a+ header pulled in transitively is invisible to it. fp8_format.h is+ exactly that shape: quant.h includes it, no engine .c does, so the+ direct check stays green whether or not a rule lists it -- while+ `touch fp8_format.h; make colibri` would report success and leave a+ stale binary carrying the previous FP8_BLOCK. That is the drift the+ header's own comment says it exists to prevent, so it is pinned here.++ Bite: delete `fp8_format.h` from `colibri$(EXE):` and this fails naming+ colibri; the direct check above still passes.++ Scoped to fp8_format.h ON PURPOSE. Running the same closure over every+ header reports seven rules that predate this change and are unrelated+ to it -- colibri and deepseek_v41 do not list tok_unicode_o200k.h,+ five engines do not list decode_batch.h or edge_adapter_internal.h,+ qwen36 does not list sse41_kernels.h. Those are real instances of the+ same hazard and worth a separate fix; widening this test to cover them+ here would make it fail on arrival for reasons this change did not+ cause.+ """+ problems = []+ for target, (source, prereqs) in sorted(_engine_rules().items()):+ seen, stack = set(), [source]+ while stack:+ cur = stack.pop()+ try:+ text = cur.read_text(encoding="utf-8")+ except (OSError, UnicodeDecodeError):+ continue+ for h in INCLUDE_RE.findall(text):+ if h in seen:+ continue+ path = C_DIR / h+ # Only headers that exist in c/ are ours to track; system+ # headers and generated files are not prerequisites.+ if path.exists():+ seen.add(h)+ stack.append(path)+ if "fp8_format.h" in seen and "fp8_format.h" not in prereqs:+ problems.append(f"{target} ({source.name}) reaches fp8_format.h "+ f"through its include graph but does not list it")+ self.assertEqual(+ problems, [],+ "fp8_format.h is reachable from these engines but absent from their "+ "Makefile prerequisites. Editing it alone will NOT relink them -- "+ "make reports success and leaves a stale artifact:\n "+ + "\n ".join(problems),+ )+def test_every_engine_rule_lists_the_headers_its_source_includes(self):problems = []for target, (source, prereqs) in sorted(_engine_rules().items()):diff --git a/docs/FORMATS.md b/docs/FORMATS.mdindex c7724d8a..b52e90c8 100644--- a/docs/FORMATS.md+++ b/docs/FORMATS.md@@ -104,29 +104,29 @@ allowlist, :3379), consulted by both gate sites β `attention_rows` (:3448) andSources for all rows (`c/quant.h`/`c/colibri.c` line numbers at this PRpair's current restack, base dev `292ed4c`):-- **fmt=0/1/2/3** β allocation policy: `qt_alloc`, `c/colibri.c:1105`+- **fmt=0/1/2/3** β allocation policy: `qt_alloc`, `c/colibri.c`(`bits>=16βfmt=0`, `bits>=5βfmt=1`, `bits>=4βfmt=2`, else `fmt=3`).- Kernels: `matmul_q` (`quant.h:105`, fmt=1), `matmul_i4` (`quant.h:125`,- fmt=2), `matmul_i2` (`quant.h:251`, fmt=3); pack/quantize helpers- `quantize_rows` (`quant.h:928`, fmt=1) and `pack_int2` (`quant.h:980`,- fmt=3). Byte-count formulas: `qt_bytes`, `c/colibri.c:183`.-- **fmt=4** (`int4-grouped`) β kernel `matmul_i4_grouped`, `quant.h:168`;+ Kernels: `matmul_q` (`quant.h`, fmt=1), `matmul_i4` (`quant.h`,+ fmt=2), `matmul_i2` (`quant.h`, fmt=3); pack/quantize helpers+ `quantize_rows` (`quant.h`, fmt=1) and `pack_int2` (`quant.h`,+ fmt=3). Byte-count formulas: `qt_bytes`, `c/colibri.c`.+- **fmt=4** (`int4-grouped`) β kernel `matmul_i4_grouped`, `quant.h`;group size `gs` is per-tensor, not fixed at 64 (contrast fmt=5). Byte-count:- `qt_bytes`'s `fmt==4` branch (inside `c/colibri.c:183`); scale-count split:- `qt_scale_bytes`, `c/colibri.c:263`.+ `qt_bytes`'s `fmt==4` branch (inside `c/colibri.c`); scale-count split:+ `qt_scale_bytes`, `c/colibri.c`.- **fmt=5** (`int3-g64`) β group size is fixed (`I3_GROUP=64`,- `quant.h:293`; `I3_GBYTES=24`, `quant.h:294`); helpers `i3_groups`- (`quant.h:295`), `i3_rowbytes` (`quant.h:296`); kernel `matmul_i3`- (`quant.h:354`); pack helper `pack_int3_g64` (`quant.h:956`). Allocation:- `qt_alloc`'s `bits==3` branch (inside `c/colibri.c:1105`).+ `quant.h`; `I3_GBYTES=24`, `quant.h`); helpers `i3_groups`+ (`quant.h`), `i3_rowbytes` (`quant.h`); kernel `matmul_i3`+ (`quant.h`); pack helper `pack_int3_g64` (`quant.h`). Allocation:+ `qt_alloc`'s `bits==3` branch (inside `c/colibri.c`).- **fmt=6** (`e8-iq3-lattice`) β upstream's merged code: format section header- precedes `quant.h:1008`; constants `E8_QK=256` (`quant.h:1008`),- `E8_SUB=32` (`quant.h:1009`), `E8_BBYTES=98` (`quant.h:1010`); row-byte- helpers `e8_blocks`/`e8_rowbytes` (`quant.h:1011-1012`); rotation contract- documented at `quant.h:1305` ("fmt=6 stores W@Q, so activations must be+ precedes `quant.h`; constants `E8_QK=256` (`quant.h`),+ `E8_SUB=32` (`quant.h`), `E8_BBYTES=98` (`quant.h`); row-byte+ helpers `e8_blocks`/`e8_rowbytes` (`quant.h`); rotation contract+ documented at `quant.h` ("fmt=6 stores W@Q, so activations must betransformed before"). Loader discriminator, upstream form (dev, ns==4 tagcheck at the top of `qt_resolve_fmt`): this branch's SECOND DESIGN- LANDMINE comment (`qt_resolve_fmt`, `c/colibri.c:1356`) hardens that check+ LANDMINE comment (`qt_resolve_fmt`, `c/colibri.c`) hardens that checkagainst the degenerate collisions below without changing any genuine-fmt=6outcome.- **fmt=7** (`mxfp4`, upstream's merged code) β Vulkan-only decode: shader@@ -139,27 +139,27 @@ pair's current restack, base dev `292ed4c`):CPU (`quant.h`) or Metal kernel exists for it, and `qt_resolve_fmt` hasno byte-arithmetic branch that returns 7.- **fmt=8** (`fp8-e4m3-b128`, this branch) β decode table `E4M3_LUT`- (`quant.h:446`) / `e4m3_decode` (`quant.h:480`), block size- `FP8_BLOCK=128` (`quant.h:482`), kernel `matmul_fp8` (`quant.h:491`).+ (`quant.h`) / `e4m3_decode` (`quant.h`), block size+ `FP8_BLOCK=128` (`fp8_format.h`), kernel `matmul_fp8` (`quant.h`).Disambiguation from fmt=1 ("THE DESIGN LANDMINE" β the two formats'weight bytes are byte-identical and can only be told apart byscale-array geometry, which is ambiguous for some small shapes) and thefmt=6 collision ("SECOND DESIGN LANDMINE") both live in `qt_resolve_fmt`- (`c/colibri.c:1356`), which now also consults an optional `stamped_name`+ (`c/colibri.c`), which now also consults an optional `stamped_name`parameter (this PR): for the fmt=6 collision, a stamp resolves what anabsent stamp still refuses; for the fmt=1-vs-fmt=8 collision, an absentstamp already resolves to `int8-row` since the #528 INVERSION, and astamp's role there is instead letting a genuinely-stamped `fmt=8` tensoroverride that default β see "The metadata stamp" below for the exactrule in both cases. FMT_NAMES table (`name string` to `fmt int`):- `c/colibri.c:1316`.+ `c/colibri.c`.- **no ordinal** (`int4-rans256-g0`, merged tools-only tier β line numbersat dev `7fb1159`, post-#671 merge `a3a5a75`, not at this PR pair'srestack base) β codec + record reader/writer: `c/rans.h`- (`RANS_NSTREAMS 256`, `c/rans.h:93`; the record layout in the file-header- comment, `c/rans.h:17-34`; that same header names its engine consumer- "a future engine decode stage", `c/rans.h:4` β the format's own statement- that none exists yet). Identity constants: `c/tools/rans_format.py:40-46`+ (`RANS_NSTREAMS 256`, `c/rans.h`; the record layout in the file-header+ comment, `c/rans.h`; that same header names its engine consumer+ "a future engine decode stage", `c/rans.h` β the format's own statement+ that none exists yet). Identity constants: `c/tools/rans_format.py`(`FORMAT_NAME = "int4-rans256-g0"`; `METADATA_KEY = "colibri.fmt"` β thesame key/shape as the fmt=8 stamp convention below, but MANDATORY hererather than a cross-check, because there is no byte arithmetic to fall@@ -169,15 +169,15 @@ pair's current restack, base dev `292ed4c`):named refusal classes in its module docstring). Full specification:`docs/int4-rans256-g0.md`. Engine-interaction status, stated precisely(why the ordinal column is empty, and what still runs): `qt_resolve_fmt`- (`c/colibri.c:1374`) has no branch that returns this format, and+ (`c/colibri.c`) has no branch that returns this format, and`c/colibri.c`/`c/quant.h`/`c/st.h` contain no reference to it β nodecode path, hence no ordinal. But a repacked shard is not invisible to- the engine: `st_fmt_stamp_ingest` (`c/st.h:317`, called from+ the engine: `st_fmt_stamp_ingest` (`c/st.h`, called from`st_init_multi`'s discovery loop) parses its mandatory `colibri.fmt`stamp map at container-discovery time, and the three routed-expert loadsites β exactly this format's target population β resolve formats by- byte arithmetic alone with `stamped_name=NULL` (`c/colibri.c:2217`,- `c/colibri.c:2386`, `c/colibri.c:2580`, each marked+ byte arithmetic alone with `stamped_name=NULL` (`c/colibri.c`,+ `c/colibri.c`, `c/colibri.c`, each marked`/* routed expert: never stamped */`), so the stamp is never consultedwhere it would matter most. A future consumer must wire stamp-gateddispatch AHEAD of that inference β `docs/int4-rans256-g0.md`'s