tools/vision/own: --tower auto keeps mtmd on an MSVC-built x86 CPU reader (owner PC, Zen 4: 33.4 s against mtmd-CPU's 18.5 s at 1,024 tokens, while the GCC build is 0.80 to 0.95 of mtmd-CPU); keyed on the compiler, not the OS; unit test; --tower own unchanged

This commit is contained in:
Niko1221 committed 2026-11-10 04:10:04 +01:00
1 parent dd04305efd
commit cab87a2e8f
3 files changed
+22

No files matched your search

+4
View File
@@ -52,6 +52,10 @@ bool own_reader_supported(const std::string& mmproj, bool gpu, std::string& why)
return false;
}
#endif
else if (vit_cpu_build_slower_than_mtmd()) {
why = "this build of the own CPU tower (MSVC, x86) is slower than mtmd's CPU reader";
return false;
}
Gguf gg;
VitGeometry g;
if (!gg.open(mmproj, why) || !vit_geometry_from_gguf(gg, g, why)) return false;
+6
View File
@@ -224,6 +224,12 @@ static void test_round_choice() {
bool ok = true;
for (const Case& c : cs) ok = ok && vit_cpu_round_kind(c.kind, c.env) == c.want;
check(ok, "rounding default per weight type and its override", "-", 0, 0);
// `--tower auto` keeps mtmd on an MSVC x86 build of the CPU tower (vit_cpu.h); any other compiler or CPU family uses ours
#if defined(_MSC_VER) && !defined(__clang__) && (defined(_M_X64) || defined(_M_IX86))
check(vit_cpu_build_slower_than_mtmd(), "an MSVC x86 build is marked slower than mtmd", "-", 0, 0);
#else
check(!vit_cpu_build_slower_than_mtmd(), "a non-MSVC build is not marked slower than mtmd", "-", 0, 0);
#endif
}
int main(int argc, char** argv) {
+12
View File
@@ -23,6 +23,18 @@ namespace strata_vit {
// 2 F16, anything else: none). Default: on for BF16 weights, off for F16; env (STRATA_VIT_REF_ROUND's value, may be null) "0" / "1" overrides.
int vit_cpu_round_kind(int weight_kind, const char* env);
// True when this build of the CPU tower is known to be slower than mtmd's CPU reader, so `--tower auto` keeps mtmd (`--tower own` still runs ours): an x86 build
// compiled by MSVC. Measured (owner PC, Ryzen 5 7600, MSVC 19.44 /O2): 33.4 s against mtmd-CPU's 18.5 s for a 1,024-token picture (1.46 to 1.82 over the pictures),
// while the same kernels built by GCC take 0.80 to 0.95 of mtmd-CPU's time on Zen 4 (RESULTS-OWN-3V.md 12.14). Keyed on the compiler, not the OS: a GCC or clang
// build for Windows does not have the problem.
constexpr bool vit_cpu_build_slower_than_mtmd() {
#if defined(_MSC_VER) && !defined(__clang__) && (defined(_M_X64) || defined(_M_IX86))
return true;
#else
return false;
#endif
}
class VitCpu {
public:
VitCpu();