Commit Graph
15 Commits
Author SHA1 Message Date
Niko1221 971bff01ad strata-vision: auto picks Strata's own CPU picture reader on x86 CPUs without AVX2 too (no more exception for the scalar, SSE4.1 and AVX tiers)
Until now `auto` kept llama.cpp's reader whenever the CPU's best kernel tier was below AVX2, because the only tier there was the slow portable one. The SSE4.1 and AVX
tiers (0991006d2, 117473f64) and the run-time dispatch (0c83610e5) change that, and the owner asked for ours as the default on these CPUs ("Yes make ours the default").
`auto` now gives our tower on every CPU tier for a tower it can run (both public reader files: Qwen3.8 BF16, Qwen3.6 F16). The setting that picks llama.cpp's reader
(STRATA_VISION_TOWER=mtmd, or --tower mtmd) works as before, and --tower own as before. No new setting, no new line in a log.

What a user on such a CPU gets (p2006, Zen 4 running the forced tier, 8 threads, medians, ours / llama.cpp's reader built for the same CPU class; big1024 = 1,024 tokens,
shapes = 260 tokens; rule 1 = the lowest cosine over 18 pictures against llama.cpp's portable AVX2 reader, the bar is 0.999):

| CPU class (our tier / llama.cpp build) | model | big1024 | shapes | rule 1 minimum |
|---|---|---|---|---|
| no AVX (sse41 / SSE4.2 build) | Qwen3.8 | 25.2 s / 150.8 s (0.167) | 3.5 s / 37.1 s (0.095) | 0.999029 |
| no AVX | Qwen3.6 | 25.3 s / 123.3 s (0.205) | 3.5 s / 29.3 s (0.121) | 0.999975 |
| AVX, no F16C (avx / avx build) | Qwen3.8 | 11.8 s / 35.7 s (0.331) | 1.37 s / 8.2 s (0.167) | 0.999674 |
| AVX, no F16C | Qwen3.6 | 12.2 s / 123.1 s (0.099) | 1.41 s / 30.4 s (0.046) | 0.999975 |
| AVX with F16C (avx / avx_f16c build) | Qwen3.8 | 12.1 s / 34.8 s (0.346) | 1.34 s / 8.0 s (0.166) | 0.999674 |
| AVX with F16C | Qwen3.6 | 12.1 s / 11.6 s (1.040) | 1.39 s / 2.17 s (0.643) | 0.999975 |

The one slower cell is Qwen3.6 on a CPU with AVX and F16C, on the large picture: 1.04 of llama.cpp's time (pair ratios 1.024 to 1.056); on the 260-token picture the same
pair is 0.643. Everywhere else below AVX2 ours takes 0.05 to 0.35 of llama.cpp's time. The AVX2 and AVX-512 CPUs are not affected: they already took our tower.

The code: own_reader_supported() loses the "best tier below AVX2" rule; the CPU half is own_cpu_reader_supported(geometry, tier) (true for every tier when the tower's
operations are implemented) and the reader a setting gives is vision_tower_resolve(setting, own_ok), so the selection is unit tested for the CPU classes no AVX, AVX without F16C,
AVX with F16C, AVX2 and AVX-512 (and a CPU older than SSE4.1), for both reader files' geometry, and for the explicit setting both ways (strata-vision-own-test). cpu_caps.h gets
isa_ok_for / best_isa_for (the same two functions for a given feature set); best_isa() and isa_ok() are unchanged.

Checks run for this commit are in phaseA-tests/cleanup/RESULTS-OWN-3V.md PART H (unit and Python suites on p1006; a default start with the tier set by STRATA_FORCE_ISA on p2006;
a default start under qemu-user with the Westmere CPU model on z440).
2026-11-11 22:22:51 +01:00
Niko1221 0991006d2c strata-vision own CPU tower: SSE4.1 and AVX kernel tiers for x86 CPUs without AVX2
Two new tiers on the CpuOps contract (cpu_tier.h: no standard-library code in the tier files), for the CPUs below AVX2 that setup builds for
(STRATA_ISA_FLOOR none / avx): Nehalem / Westmere and the Pentium / Celeron / Atom parts without AVX (sse41), Sandy / Ivy Bridge and AMD's AVX
CPUs before Excavator (avx).

- cpu_kernels_sse41.cpp: 6 x 8 register tile on __m128; cpu_kernels_avx.cpp: 6 x 16 on __m256 (-msse4.1 / -mavx; MSVC /arch:AVX).
- No FMA on these CPUs: every product term is a multiply then an add, in the k order of every tier. The SSE4.1 tier's products are bit-identical
  to the scalar tier's on x86 (unit test).
- F16 weights are converted in integer code, bit exact, without F16C (Sandy Bridge has none); the 16-bit rounding equals the scalar tier's bit
  for bit; exp is the Cephes polynomial of the AVX2 tier with separate multiply and add; the one-vector tail product as in AVX2 / AVX-512.
- Dispatch: Isa ranks scalar < sse41 < avx < avx2 < avx512 (Neon apart); the probe reads SSE4.1 and AVX (with the OS ymm state);
  STRATA_FORCE_ISA takes sse41 and avx.
- own_reader_supported keeps `auto` on mtmd for every x86 tier below AVX2 (the line reads `< Avx2` instead of `== Scalar`): behaviour unchanged
  until the gate.
- strata-vision-own-cpu-test runs every tier the CPU has, capped by STRATA_FORCE_ISA, and adds the rotary / position-add kernels and the SSE4.1 =
  scalar product check.

Checked: cpu-test on z440 (Haswell-EP) with each tier forced (scalar, sse41, avx, avx2): all passed; under qemu-user -cpu Westmere the cpu-test
picks sse41 and passes, and strata-vision --tower own / mtmd / auto and strata-vision-own read Qwen3.8 and Qwen3.6 pictures with no illegal
instruction (z440 job z440-20261111-1105-4195).
2026-11-11 12:29:51 +01:00
Niko1221 59e0758810 tools/vision: our picture reader is the default (owner 11-11: "Our tower, the other selectable"); llama.cpp's mtmd reader stays selectable and takes over by itself where ours was measured slower or does not start
- the default tower is `auto` (was mtmd); without --tower, STRATA_VISION_TOWER=mtmd|own|auto decides (the run config's env carries it when someone picks llama.cpp's reader; an older strata-vision ignores it); an explicit --tower wins
- `auto` now takes ours on Metal (gate passed on the M5 Max, RESULTS-OWN-3V.md D1/D4-D8) and on MSVC x86 builds (rule cab87a2e8 removed: 0.986 of mtmd-CPU since 54f9cc3c0, D2)
- kept: gfx1151, Pascal with F16 matrices at <= 1,024 tokens, x86 without AVX2; new hold: every card on Windows HIP (not measured with the Windows ROCm package; remove when one RX 9000 / RX 7000 run on Windows is in)
- under `auto`, a failure of ours before READY (no GPU, the load, the warm-up) writes nothing on stdout; strata-vision logs the reason and starts mtmd's reader in the same process; `--tower own` keeps its hard failure
- READY names the reader: "READY <n> own", "READY <n> mtmd", "READY <n> mtmd fallback" (servers read only the start)
- test hook STRATA_VIT_TEST_FAIL=gpu|load|warmup; unit tests for the default, the Windows HIP hold, the soft start and the hook (p2006 job p2006-20261111-0743-7d3b: strata-vision-own-test ok, cpu-test all passed)
2026-11-11 07:44:24 +01:00
Niko1221 88fc47ccf0 tools/vision: --tower auto uses our GPU tower on every CUDA class when the reader starts with --max-tokens above 1,024 (the default GPU limit), whatever the speed: at 16,384 tokens mtmd-GPU reads 0.81 to 0.83 against mtmd-CPU (A4000 0.813, RTX PRO 5000 0.834, P100 0.834), ours 0.9996 to 0.99998, at a time cost on Pascal (P100, Qwen3.8, 16,384 tokens: 196.6 s against mtmd-GPU 129.0 s); at or below 1,024 the speed rules stay (Pascal with F16 matrices and cc 6.1 / 6.2 keep mtmd); AMD gfx1151 and Metal unchanged; own_reader_supported and prefer_mtmd take max_tokens; unit test 2026-11-10 12:20:55 +01:00
Niko1221 e83138654b tools/vision/own: Pascal (cc 6.x) holds BF16 matrices as F16 (cuBLAS has only a slow BF16 kernel there: 645 against 497 ms of a 1,024-token picture on a P100) and, with them, takes a 32M-score attention chunk; auto now reads with our tower on cc 6.0 when the mmproj's matrices are BF16 (Qwen3.8: P100 gate PASS, rule 1 min 0.999636, 0.32 to 1.00 of mtmd-GPU's time, 1,362 against 1,364 MiB) and keeps mtmd with F16 matrices (Qwen3.6: mtmd's F16-accumulating products stay faster, ours 0.75 to 1.37) and on cc 6.1 / 6.2 (not measured); STRATA_VIT_BF16_AS_F16 diagnostic 2026-11-10 11:17:34 +01:00
Niko1221 cab87a2e8f 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 2026-11-10 04:10:04 +01:00
Niko1221 9e5f5a5ed7 tools/vision/own: --tower auto uses our CPU tower on Arm (NEON gate on the DGX Spark: rule 1 PASS on both models, 0.57 to 0.81 of mtmd-CPU's time on F16 and 0.08 to 0.13 on BF16); the scalar-only rule stays for x86 without AVX2 only 2026-11-10 02:24:39 +01:00
Niko1221 92d379070d tools/vision/own: the Arm NEON kernel tier of the CPU tower (cpu_kernels_neon.cpp, baseline AArch64, 12 x 8 tile, on the cpu_tier.h contract; quant::Isa::Neon is the best tier on AArch64, STRATA_FORCE_ISA=scalar still forces the portable one); --tower auto keeps mtmd on Arm until the gate is accepted 2026-11-10 02:05:15 +01:00
Niko1221 aa2a3f956c tools/vision/own: --tower auto keeps mtmd on a CPU that has only the portable kernel tier (x86 without AVX2, Arm until a NEON tier exists), where the own CPU tower is 2.1 to 3.7 times slower than mtmd-CPU; --tower own unchanged 2026-11-10 00:58:41 +01:00
Niko1221 1f74860fa2 tools/vision/own: --tower auto keeps mtmd on NVIDIA Pascal (compute capability 6.x), where the own GPU tower is slower than mtmd (P100 gate); --tower own unchanged 2026-11-09 23:57:41 +01:00
Niko1221 423225d879 tools/vision/own: the CPU path of --tower own is the fast tower (VitCpu); STRATA_VIT_CPU=ref selects the float32 reference 2026-11-09 20:02:02 +01:00
Niko1221 f5db05f106 tools/vision/own: GPU tower speed on small pictures (short-row softmax kernel sized by row length, score rows padded to 8), STRATA_VIT_PROF stage timings, STRATA_VIT_CPU=fast switch in the reader; fork-join team: the task count carries the run tag (one task ran twice in 31 of 60 test runs), team-only test mode 2026-11-09 19:27:35 +01:00
Niko1221 47b5f88fd5 tools/vision/own: GPU tower memory (chunked products, F16 scores softmaxed in place, one patch matrix), long-row softmax so no picture is refused, limit pictures and --skip-cpu for the gate, bench tool 2026-11-09 18:14:44 +01:00
Niko1221 ef108d84c3 tools/vision/own: step 4, the Qwen tower on a CUDA GPU (cuBLAS GemmEx on BF16/F16 weights, float32 activations, tiled online-softmax attention), strata-vision-own for quick builds 2026-11-09 17:25:01 +01:00
Niko1221 290896d804 tools/vision/own: step 3, the float32 CPU reference of the Qwen tower, strata-vision --tower own|mtmd|auto (mtmd stays the default), the comparison harness against mtmd 2026-11-09 17:15:51 +01:00