Hy4 hand-written build lines compile hy4_cpu_k512.cpp (PLAN-0224 item 12)

The CMake target builds hy4_cpu_k512.cpp (the AVX-512 CPU expert kernels); the B70 Hy4 job in .github/workflows/intel-runner.yml and tools/hy4/build_hy4_hip_linux.sh list the host files by hand and missed it. The file carries its own target pragmas, so it needs no -m flag; the intel-runner line skips it for the old v0.2.19 base tree, which does not have it. A source-scan test pins that every host source of the CMake target is in every hand-written build (CI, HIP, SYCL).
This commit is contained in:
Niko1221 committed 2026-12-02 12:53:43 +01:00
1 parent 3fe4a1c7a7
commit 946ecbf049
3 files changed
+55 -2

No files matched your search

+5 -1
View File
@@ -79,8 +79,12 @@ jobs:
g++ -O3 -std=c++17 -fPIC $INC -c "$SRC/engine/src/ngram/hy4_engram_reader.cpp" -o "$OUT/obj/hy4_engram_reader.o" &
g++ -O3 -std=c++17 -fPIC $INC -c "$SRC/engine/src/hy4flash/run/hy4_engram.cpp" -o "$OUT/obj/hy4_engram.o" &
g++ -O3 -std=c++17 -fPIC -pthread $INC -c "$SRC/engine/src/hy4flash/run/hy4_cpu_experts.cpp" -o "$OUT/obj/hy4_cpu_experts.o" &
# hy4_cpu_k512.cpp (the AVX-512 expert kernels) carries its own target pragmas, so it needs no -m flag; the old v0.2.19 base tree does not have the file
local K512="$SRC/engine/src/hy4flash/run/hy4_cpu_k512.cpp"
if [ -f "$K512" ]; then g++ -O3 -std=c++17 -fPIC -pthread $INC -c "$K512" -o "$OUT/obj/hy4_cpu_k512.o" & fi
wait
local HOBJS="$OUT/obj/strata_reader.o $OUT/obj/sk_codecs.o $OUT/obj/hy4_engram_reader.o $OUT/obj/hy4_engram.o $OUT/obj/hy4_cpu_experts.o"
if [ -f "$K512" ]; then HOBJS="$HOBJS $OUT/obj/hy4_cpu_k512.o"; fi
icpx -O3 -std=c++17 -fiopenmp $SYCL_FLAGS $MKL_FLAGS $INC \
"$SRC/engine/src/hy4flash/sycl/sy_main.cpp" \
"$SRC/engine/src/hy4flash/sycl/sy_mla.cpp" \
@@ -93,7 +97,7 @@ jobs:
echo "== Build sy_opt_test (bmg_g31 GPU) =="
INC_OPT="-I$PWD/engine/include -I$PWD/engine/src/hy4flash/sycl -I$PWD/engine/src/hy4flash/run -I$PWD/engine/third_party/stb -I$PWD/engine/third_party/zstd-dec"
HOBJS_OPT="$BUILD/opt/obj/strata_reader.o $BUILD/opt/obj/sk_codecs.o $BUILD/opt/obj/hy4_engram_reader.o $BUILD/opt/obj/hy4_engram.o $BUILD/opt/obj/hy4_cpu_experts.o"
HOBJS_OPT="$BUILD/opt/obj/strata_reader.o $BUILD/opt/obj/sk_codecs.o $BUILD/opt/obj/hy4_engram_reader.o $BUILD/opt/obj/hy4_engram.o $BUILD/opt/obj/hy4_cpu_experts.o $BUILD/opt/obj/hy4_cpu_k512.o"
icpx -O3 -std=c++17 -fiopenmp $SYCL_FLAGS $MKL_FLAGS $INC_OPT \
"$PWD/engine/src/hy4flash/sycl/sy_opt_test.cpp" \
"$PWD/engine/src/hy4flash/sycl/sy_mla.cpp" \
@@ -0,0 +1,49 @@
"""0.2.25 (PLAN-0224 item 12): the hand-written Hy4 build lines name every host source file the CMake target builds.
`hy4_cpu_k512.cpp` (the AVX-512 CPU expert kernels) was added to the CMake target but not to the lines of `.github/workflows/intel-runner.yml` (the B70 Hy4 job) and
`tools/hy4/build_hy4_hip_linux.sh`, which list the host objects by hand. This pins that no host source of the target can be missing from them again.
"""
from __future__ import annotations
import re
import unittest
from pathlib import Path
REPO = Path(__file__).resolve().parents[3]
CMAKE = REPO / "engine" / "src" / "hy4flash" / "run" / "CMakeLists.txt"
HAND_BUILDS = [REPO / ".github" / "workflows" / "intel-runner.yml", REPO / "tools" / "hy4" / "build_hy4_hip_linux.sh", REPO / "engine" / "src" / "hy4flash" / "sycl" / "build_hy4_sycl.sh"]
# the two that carry the engine-side files (reader, codecs) are compiled by their own lines; what matters is the hy4flash/run host sources
HOST_SOURCES_OF_THE_TARGET = re.compile(r"add_executable\(strata-hy4 ([^)]*)\)", re.S)
def target_host_sources() -> list[str]:
text = CMAKE.read_text(encoding="utf-8")
body = HOST_SOURCES_OF_THE_TARGET.search(text).group(1)
names = [tok for tok in re.findall(r"[\w./-]+\.cpp", body) if "/" not in tok and not tok.endswith(".hip.cpp")]
return names
class Hy4HandBuildLines(unittest.TestCase):
def test_the_target_has_the_host_sources_the_test_expects(self):
names = target_host_sources()
self.assertIn("hy4_cpu_experts.cpp", names)
self.assertIn("hy4_cpu_k512.cpp", names)
def test_every_host_source_of_the_target_is_compiled_by_each_hand_written_build(self):
names = target_host_sources()
for path in HAND_BUILDS:
text = path.read_text(encoding="utf-8")
for name in names:
self.assertIn(name, text, f"{path.relative_to(REPO)} does not compile {name}, which the CMake target builds")
def test_the_k512_object_is_linked_not_only_compiled(self):
for path in HAND_BUILDS:
text = path.read_text(encoding="utf-8")
if path.suffix == ".sh" and path.name == "build_hy4_hip_linux.sh":
self.assertIn("hy4_cpu_k512.cpp", text) # its loop compiles every listed file into objs[] that the link line takes
else:
self.assertGreaterEqual(text.count("hy4_cpu_k512.o"), 2, f"{path.name}: the object is made but never listed for the link")
if __name__ == "__main__":
unittest.main()
+1 -1
View File
@@ -23,7 +23,7 @@ for c in "$Z"/common/*.c "$Z"/decompress/*.c; do
[ "$o" -nt "$c" ] || "$CC" -O3 -DZSTD_DISABLE_ASM=1 -DXXH_NAMESPACE=ZSTD_ $INC -c "$c" -o "$o" &
objs+=("$o")
done
for c in "$E/src/artifact/strata_reader.cpp" "$E/src/quant/sk_codecs.cpp" "$RUN/hy4_engram.cpp" "$RUN/hy4_cpu_experts.cpp"; do
for c in "$E/src/artifact/strata_reader.cpp" "$E/src/quant/sk_codecs.cpp" "$RUN/hy4_engram.cpp" "$RUN/hy4_cpu_experts.cpp" "$RUN/hy4_cpu_k512.cpp"; do # hy4_cpu_k512.cpp (AVX-512 expert kernels): its own target pragmas, no -m flag
o="$OUT/obj/$(basename "$c" .cpp).o"
[ "$o" -nt "$c" ] || "$CXX" -std=c++17 -O3 -pthread $INC -c "$c" -o "$o" &
objs+=("$o")