Build the engine for ARM64 (DGX Spark / GB10) without changing the x86 build (#3622)
The engine did not build on aarch64: the CPU expert path assumed the x86 AVX kernels, the CPUID probes and the x86 spin/fence intrinsics. After this change the strata target compiles on aarch64 (CUDA host code, native GGUF packs). On x86 nothing is selected differently. What changed: - CMake: STRATA_CPU_X86 is decided from CMAKE_SYSTEM_PROCESSOR (an unset processor stays the x86 build). On aarch64 src/kernels/cpu/portable.cpp stands in for the AVX kernel sources; native experts run on ggml-cpu's NEON dot products. -ffp-contract=off on aarch64. STRATA_ISA_FLOOR is ignored with a warning there. - include/strata/platform/cpu_relax.hpp: strata_cpu_pause / strata_store_fence map to _mm_pause / _mm_sfence on x86 and to yield / dmb oshst on aarch64. verify.cpp, pool.cpp, session.cpp, mtp.cpp and graph.cpp use them. - expert_layout.cpp: the CPUID/XCR0 probes compile on x86 only and report no AVX on other CPUs. - generate.cpp: --cpu-oracle-q8-0 is rejected on a non-x86 CPU. - setup.py: nvidia-smi's "[N/A]" memory on GB10 (unified memory) takes the pool size from /proc/meminfo on ARM64 only; the CPU probe no longer needs the x86 "flags" line; setup warns that the ARM64 engine is compiled on the PC and which packs work. Changes to the contributor's patch, found while moving it onto the 0.2.7 line: - portable.cpp had no iq512x_rows / iq512x_supported / iq512_gather_on (added to the x86 kernels after the PR was written): the aarch64 link would fail. - The Metal build (Apple silicon) shares these files. It keeps its barrier (dmb ishst), its plain router loop (its bf16_rows_dot_multi is a stub), its Metal start-up block in generate.cpp and its "unknown" CPU name. - The CPU side of the GPU doorbell: strata_load_fence() after the spins that wait for a flag the GPU raised (dmb ishld on ARM, nothing on x86 and on Apple silicon), so the data written before the flag is not read early. - A card whose memory nvidia-smi does not report stays unlisted on x86 (the new fallback is for ARM64 only). - tests/terminal/test_setup_arm64.py. Checked: with the x86 CUDA build (sm_86, gcc 13 -O3, z440) the objects of verify, session, mtp, graph, expert_source, pool, expert_layout and generate are byte-identical before and after (the x86 wrappers are macros for the same intrinsics). Every C++ file of the strata target compiles for aarch64 with clang, and the symbols of the CPU kernel library link up (syntax and symbols only: no ARM machine, no ARM run). The Metal-shared files compile for aarch64-macos with STRATA_GPU_METAL. Not covered: no ARM hardware here. The tests that include x86 headers (iq_avx2_parity and the other AVX parity tools) and the DeepSeek target do not build on aarch64; the strata target does not need them. Memory ordering on ARM is reasoned, not run. The Q2_0 and Gyro packs need the x86 kernels.
This commit is contained in:
1 parent
a8c1d4b7f8
commit
a4c41a92ee
13 files changed
+472
-53
No files matched your search
@@ -3184,6 +3184,10 @@ void RouterLookahead::run() {
|
||||
// one (kq_avx1.cpp) or, without AVX, the same sums in plain C++. From the Strata_Dirigo fork (rwkeyes): an
|
||||
// AVX-only Xeon E5-2687W died here (vpmovzxwd) on its first request. An estimate only (which experts to
|
||||
// prefetch); the order of the additions differs between the three, the output does not depend on it.
|
||||
#if defined(__aarch64__) && !defined(STRATA_GPU_METAL) // Metal (Apple silicon) keeps the plain loop below: its bf16_rows_dot_multi is a stub
|
||||
strata::kernels::cpu::bf16_rows_dot_multi(routers_[(size_t) layer].data(), (int) n_expert_, (int) n_embd_,
|
||||
x_.data(), (int) nt, logits.data());
|
||||
#else
|
||||
if (strata::kernels::cpu::cpu_avx2_ok()) {
|
||||
strata::kernels::cpu::bf16_rows_dot_multi(routers_[(size_t) layer].data(), (int) n_expert_, (int) n_embd_,
|
||||
x_.data(), (int) nt, logits.data());
|
||||
@@ -3209,6 +3213,7 @@ void RouterLookahead::run() {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
const int kmax = stats_on_ ? (int) std::min<int64_t>(k_ + 10, n_expert_) : k_;
|
||||
const int ks[3] = {k_, (int) std::min<int64_t>(k_ + 4, n_expert_), kmax};
|
||||
std::vector<uint64_t> sm;
|
||||
|
||||
Reference in new issue
Block a user