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).
The SSE4.1 tier used a Cephes polynomial for exp. On Qwen3.8 that gave code4217 a cosine of 0.998928 against llama.cpp's CPU reader, 0.00007 under the 0.999
bar. The tier now calls the C library's expf per lane (out of line, with the scalar tier's clamp [-87, 88]). No build switch is left behind and the polynomial
is gone from this tier.
Checks (p2006, Zen 4, 8 threads, 18 pictures, 1,024 tokens, forced sse41 tier; the AVX and AVX2 tiers are unchanged):
| | polynomial exp | libm exp |
|---|---|---|
| Qwen3.8 rule 1 minimum (against llama.cpp's portable AVX2 CPU reader) | 0.998928 (code4217, 1 miss) | 0.999029 (code4217, 0 misses) |
| Qwen3.6 rule 1 minimum | 0.999975 | 0.999975 |
| bytes against the scalar tier, 18 pictures, each model | all 18 differ | 18 of 18 identical |
| big1024 time, Qwen3.8 / Qwen3.6, 3 alternating pairs, median | 23,857 / 22,523 ms | 26,935 / 24,398 ms |
| shapes (260 tokens) time, Qwen3.8 / Qwen3.6 | 3,587 / 3,460 ms | 3,653 / 3,548 ms |
| peak resident memory | 1.16-1.18 GB | 1.16-1.18 GB |
Time per pair over libm, big1024: 0.82 to 0.98 (Qwen3.8), 0.90 to 0.96 (Qwen3.6); run-to-run spread on big1024 is about 10 percent.
The same code under qemu-user with the Westmere CPU model (no AVX, FMA or F16C, so the C library takes its non-FMA expf), z440, Qwen3.8, code4217, 12 threads:
the emulated sse41 output is byte-identical to the native sse41 output (and so to the native scalar output), rule 1 is 0.999029 in both.
Against llama.cpp's reader built for the same CPU class (p2006, 8 threads, medians; big1024 / shapes): sse41 against the SSE4.2 build, Qwen3.8 25,219 / 3,541 ms
against 150,800 / 37,149 ms, Qwen3.6 25,304 / 3,531 ms against 123,306 / 29,265 ms.
Two conflicts, both in the same place: f-own-3s rewrote the gfx1151 block of
tools/vision/own/vit_gpu.h (and its test lines in test_gguf_geometry.cpp), and
f-spark-s2 added its context-retry block right after the old lines of that block.
Resolved by keeping 3s's block whole and adding the retry block unchanged after it
(the base lines 3s replaced are dropped).
On gfx1151 (Strix Halo) with head size <= 96, a multiple of 8, and wave 32, k_attn_fa_gfx11 now runs
unless STRATA_VIT_FA=0 is set; STRATA_VIT_FA=1 still asks for it on other gfx11 cards. The variable
is read after the default, as the HPA16 variables are. No new setting. gfx1103 and the other gfx11
cards are unchanged (they get their own gate). The register note of STRATA_VIT_FA is marked
[DRAFT, status: research].
Measured on Strix (gfx1151, Windows, build 5 of af825339a, STRATA_VIT_FA=1 against no variable),
Qwen3.8 against mtmd-CPU:
- attention on big1024 (1,024 tokens, warm): 319.6 ms -> 158.7 ms (0.50); whole picture 383 -> 320 ms,
code4217 89 -> 80 ms;
- time against mtmd-HIP, 18 pictures, min / median / max: 0.56 / 0.66 / 0.92 -> 0.46 / 0.60 / 0.83
(Qwen3.6: 0.56 / 0.67 / 0.91 -> 0.46 / 0.61 / 0.91);
- rule 1 and rule 2 pass on 18 of 18 pictures on both models for both arms; byte-identical over 5
encodes and across two processes;
- longest launch 6 ms at 1,024 tokens, 17 ms at 65,536 patches (limit_4096x4096 reads 0.999693
against the stored mtmd-CPU embedding);
- smallest token against mtmd-CPU, fused minus default, Qwen3.8: below on 6 of 18 pictures
(code4217 -0.094 = token #47, shapes_p.gif -0.019), above on 12; token #47 of code4217 depends on
rounding in every variant measured (its length 0.74 to 2.03; the two CPU references agree on it
to 0.7600, on the whole picture to 0.999543; the fused kernel is near our CPU tower, the default
near mtmd-CPU).
Jobs strix-20261111-1620-a728, -1622-31a8, -1636-6cb1, -1644-15d4; details in
phaseA-tests/cleanup/RESULTS-OWN-3V.md part F8-F9. The gate of the build as it ships follows.
The gate of the retry on a DGX Spark (4 starts counted with STRATA_VIT_PROF=1)
needed 5, 5, 5 and 6 retries, 5.4 to 6.8 s in all, about 1.1 to 1.2 s per
retry (the 1 s pause plus the failed attempt). 8 retries left a margin of 2.
Worst case when the context never comes: 12 retries, about 13 to 14.5 s of
waiting, then the reader fails as before and falls back as before.
The retry rule's test follows the constant.
A new CUDA context on a GPU that shares the system RAM (DGX Spark GB10)
needs physically contiguous memory. When the kernel has almost no free 2 MiB
blocks, cudaSetDevice fails with "out of memory" although 20+ GiB are free,
and the same call 1 to 5 s later succeeds. On the Spark this sent the picture
reader to the CPU (or to llama.cpp's reader, which aborts) at about half of the
starts.
VitGpu::load now tries again, up to 8 times, 1 s apart, only for
cudaErrorMemoryAllocation, only when cudaDevAttrIntegrated is set, and only in
a Linux CUDA build (SPARK-CTX-RETRY guard; HIP, Metal, Windows and gfx906 are
untouched). After the last retry it fails as before and the reader falls back
as before. No new setting and no new log line (STRATA_VIT_PROF=1 shows the
retry count).
Tests: the retry rule (vit_gpu_retry_context) in test_gguf_geometry.cpp;
tools/test_vit_ctx_retry_guard.py checks the guard.
- K and V reach LDS by 128-bit global loads; the WMMA fragments leave LDS by 128-bit loads (rows
padded by 8 F16 values: 16-byte aligned, banks shifted); 64-key tiles;
- exp2f with log2(e) folded into the scores; the P exchange inside a wave (wave barrier with LDS
fences) instead of a block barrier;
- the launch cap STRATA_VIT_FA_UNITS now 2^29 query x key x head triples; the head size must be a
multiple of 8 (Qwen: 72).
780M (p2006, gfx1103, Linux), Qwen3.8, big1024 at 1,024 tokens, stage profile, warm encodes:
attention 604 ms with the fused kernel against 1,512 ms on today's path (the first version: 1,606);
the whole picture 1,202 ms against 2,151 (code4217: 290 against 351). Against our CPU tower:
big1024 0.999971 (today's path 0.999952), code4217 0.999743 (0.998636). Byte-identical over 4 encodes
and across two processes. Longest launch at 1,024 tokens 22.5 ms warm (55.6 ms on the first encode).
Job p2006-20261111-1543-5533. Strix not run yet.
k_attn_fa_gfx11 does S = Q K^T, the softmax and O = P V of a chunk of queries for every head in one launch,
flash-attention style, with the gfx11 WMMA instruction (16x16x16, F16 in, float32 accumulate, wave32):
- one block = 4 waves = 64 queries of one head; each wave walks the keys in tiles of 32;
- the scores stay in float32; the softmax is online, in float32 (running row maximum and sum, expf);
- P is rounded to F16 for the second product, as before; O accumulates in float32 and leaves in float32;
- the head size is padded with zeros to a multiple of 16 (72 -> 80); no atomics, a fixed key order.
It replaces the score product, the three-pass softmax, the P*V product and the widen of today's path, and
needs no score buffer. Device code only for gfx11 targets (__GFX11__); other targets get an empty body
and never launch it.
STRATA_VIT_FA=1 turns it on, only on a gfx11 card with 32-wide waves and a head size of at most 96.
A launch takes at most STRATA_VIT_FA_UNITS (default 2^32) query x key x head triples, planned as about
100 ms on a Radeon 8060S, so no launch comes near the Windows GPU timeout of 2 s, also at the
16,384-token limit. With STRATA_VIT_PROF the longest launch of an encode is printed.
Built for gfx1151 (owner PC, owner-20261111-1226-681f): 187 VGPRs, no spills, 14,336 bytes of LDS
for the head-size-80 instance; 84 v_wmma instructions over the six instances. Not run yet.
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).
vit_cpu.cpp and vit_ref.cpp were compiled with -mavx2 -mfma in every x86 GCC build. Setup's own build on a CPU without AVX2 (STRATA_PORTABLE=OFF)
therefore contained AVX2/FMA code in VitCpu itself and in standard-library template copies (std::vector<unsigned short>::_M_fill_assign,
std::vector<std::thread>, std::function managers) that the linker keeps for the whole program. A floor build of the whole strata-vision had
64 functions with AVX instructions outside the kernel tiers (SSE4.2 floor) and 23 with AVX2/FMA (AVX floor).
- The two loops of the tower whose result depends on multiply-add contraction (the rotary of a token row, the position table's bilinear
add) move into the tier tables (CpuOps::rope_row, pos_add), written as before, so each tier compiles them with its own flags.
- vit_cpu.cpp is compiled at the baseline.
- vit_ref.cpp (the float32 oracle) gets -march=native in native builds (STRATA_VIT_OWN_NATIVE or setup's STRATA_PORTABLE=OFF), -mavx2 -mfma
only in the portable helper (an AVX2 floor for the whole program), the floor's flags in an older-CPU test build.
- tools/vision: STRATA_ISA_FLOOR = none (SSE4.2) / avx / avx_f16c, a test build of the program a CPU without AVX2 runs (ggml-cpu and the
reference at that floor), as the engine's option of the same name. Empty changes nothing.
- check_floor_isa.py: objdump scan of a linked binary; every function with instructions above the floor must be kernel-tier code.
Checked (p2006, job p2006-20261111-1101-c643): AVX-512 and AVX2 tiers byte-identical before and after on all 18 pictures, both readers
(standalone reader), and 6 / 6 per tier through the portable helper's --tower own. The scalar tier changes (GCC no longer contracts its
rotary): global cosine old against new 0.99942 to 0.99999 (Qwen3.8), 1.000000 (Qwen3.6). cpu-test passes on every tier. Floor scan of
the whole strata-vision after the change: 0 functions outside the tiers at the SSE4.2 floor, 0 at the AVX floor.
The Windows ROCm package's rocBLAS has tuned gfx1151 kernels for 16-bit results only (Tensile
BB_HPA / HH_HPA); BF16 / F16 -> F32, which the tower asked for, has only fallback kernels.
On gfx1151 the tower now takes, by default:
- STRATA_VIT_HPA16: weight products with a 16-bit result, float32 accumulation, widened after;
- STRATA_VIT_HPA16_ATT: the same for the attention's P*V product;
- STRATA_VIT_BF16_AS_F16: BF16 matrices held as F16 (the Pascal path), so every product gives an F16
result (HH_HPA, 10-bit mantissa) and not a BF16 one.
Each variable set to 0 turns its part off. No other card changes; no user setting.
Strix (Radeon 8060S, Windows), 18 pictures at 1,024 tokens against mtmd-CPU, medians of 5 encodes:
- Qwen3.8 (BF16 file): 0.54-0.83 of mtmd-HIP's time, median 0.66; rule 1 and rule 2 pass on all 18
(lowest global cosine 0.999285); byte-identical within a process and across two processes.
- Qwen3.6 (F16 file): 0.57-0.91, median 0.67; rule 1 and rule 2 pass on all 18 (lowest 0.999760).
- With BF16 results (no BF16_AS_F16) Qwen3.8 missed rule 1 on 3 pictures and rule 2 on 3.
- Before: 1.72-3.06 of mtmd-HIP's time with float32 results.
Jobs strix-20261111-1135-3669 (R2) and strix-20261111-1147-cbbb (R2b); RESULTS-OWN-3V.md PART F2/F3.
Until now, under `auto` a cc 6.0 card used llama.cpp's reader for F16 reader files (Qwen3.6, Unsloth's Qwen3.8 F16 file) at 1,024 picture tokens or fewer, because ours is slower there. It now uses our reader, as it already did for BF16 files and above 1,024 tokens. This follows the owner's rule of 11-11: our own code is the default where its accuracy gates pass, even where it is somewhat slower.
P100, Qwen3.6 F16 reader file, 18 pictures, against the x86 llama.cpp CPU references:
- ours: rule 1 0.999865 / 0.999969 (min / mean), smallest single token 0.9962;
- llama.cpp's GPU reader: 0.982913 / 0.994036, single tokens down to 0.19.
- time: 1,064 / 263 / 194 ms against 916 / 224 / 160 ms at 1,024 / 350 / 260 tokens.
llama.cpp's reader stays selectable through the Picture reader setting (STRATA_VISION_TOWER=mtmd) and stays the start fallback.
Pascal 6.1 / 6.2 (GTX 10xx, Jetson TX2) are not measured. They keep llama.cpp's reader up to the default limit, as before.
The unit test lines in test_gguf_geometry.cpp now match the new rule. The reason the reader gives on 6.1 / 6.2 says "not measured".
On compute capability 6.x the CUDA picture reader already used a 32M-score attention chunk for BF16 files, which it holds as F16. F16 files (Qwen3.6, and Unsloth's Qwen3.8 F16 file) kept the 16 MB chunk. They now take the 32M chunk as well.
P100, Qwen3.6 F16 reader file, median of 5 encodes:
- big1024 (1,024 tokens): 1,243 -> 1,064 ms
- code4217 (350 tokens): 270 -> 263 ms
- shapes (260 tokens): 200 -> 194 ms
- rule 1 against the x86 llama.cpp CPU references: 0.999865 / 0.999969 (min / mean over 18 pictures), unchanged
- 48 MB more GPU memory than the 16 MB chunk
Host code only (load()); no device code changes, and other card classes are unaffected.
Lane COVER (phaseA-tests\par\RESULTS-COVER.md, 11-11) read the Windows ROCm package: its rocBLAS has tuned
kernels for gfx110x and gfx1151 for BF16 -> BF16 and F16 -> F16 with float32 accumulation (Tensile
BB_HPA, HH_HPA, every transposition), and only the generic fallback kernels for BF16 / F16 -> F32
(BS_HPA, HS_HPA), which our products ask for. mtmd's reader asks for the 16-bit result on RDNA3 and
RDNA3.5 (ggml-cuda.cu, prefer_f32_output).
- STRATA_VIT_HPA16=1: the 16-bit weight products ask rocBLAS for a result in the weight's type (BF16 or
F16) with HIPBLAS_COMPUTE_32F, into a 16-bit buffer, then a kernel widens it to float32 for the rest of
the layer. The result is the float32 sum rounded once to 16 bits, as mtmd's GPU reader keeps it.
- STRATA_VIT_HPA16_ATT=1: the same for the attention's P*V product (F16 -> F16). The score product
S = K Q^T is already F16 -> F16 with float32 accumulation (HH_HPA).
- The 16-bit buffers are taken only when a switch is on. HIP builds only; the CUDA device code is unchanged.
- With no switch set the reader runs exactly as before.
Owner, 11-11: "For Strix - use our reader, even if its a bit slower. We can always tune it better
afterwards. Our priority is to get off ggml and llama.cpp."
- vit_gpu_slower_amd is gone: gfx1151 no longer keeps llama.cpp's reader. On Strix our reader takes
1.95 / 2.61 of llama.cpp's time on big1024 / code4217 (hipBLAS products; RESULTS-OWN-3V.md PART F),
and passes rule 1 and rule 2 on 18 pictures with both models (12.14).
- The Windows HIP hold now leaves out gfx1151, the one card measured with the Windows HIP package:
vit_gpu_hip_windows_not_measured(windows, gfx). Every other Windows HIP card keeps llama.cpp's reader
under auto as before; Linux HIP is unchanged.
- llama.cpp's reader stays selectable (the Picture reader setting, --tower mtmd) and still takes over by
itself when ours does not start.
- Unit test: gfx1151 (with and without a feature suffix) on Windows takes ours; gfx1201, gfx1100 and
gfx1150 on Windows keep llama.cpp's reader; Linux takes ours.
On gfx1151 (Strix Halo) the Windows package's rocBLAS has only its generic fallback kernels, and the
tower's hipBLAS products made it 1.7 to 3.0 times mtmd-HIP's time (RESULTS-OWN-3V.md 12.14, section 14).
HIP builds that find hipBLASLt now carry a second path for the products:
- STRATA_VIT_LT=1: the 16-bit weight products (y = x W^T, F32 out, F32 compute)
- STRATA_VIT_LT_ATT=1: the two batched attention products (S = K Q^T, O = V P)
- STRATA_VIT_LT_SOL=<id>: that solution for the weight products instead of hipBLASLt's first heuristic answer
- STRATA_VIT_LT_VERBOSE=1: the solution of every new shape and a summary on stderr
Each call shape gets its solution once per process, by id or as the first heuristic answer that fits a
32 MB workspace, never by timing, so two processes run the same kernels. A shape hipBLASLt cannot run, or
a launch that fails, goes to hipBLAS as before. The float32 patch product stays on hipBLAS. With no
switch set the reader runs exactly as before; the rule that keeps mtmd on gfx1151 is unchanged.
- 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)
The MSVC-built CPU reader was 1.057 of mtmd-CPU's time on a 1,024-token picture (Ryzen 5 7600, 6 threads); level at 1 thread and ahead at 12, so the loss was the attention at 4,096 patches: every task (one head, 48 query rows) streamed all of the head's K and V again, V was read in place from the qkv rows (a 3,456-float stride), and the P*V product's last 8 columns (head size 72) went through a 32-wide tile and a buffer.
- V is packed per head (VP[h][j][d]) in the same pass as K^T.
- A task takes 96 query rows (kQBDefault), so K and V are streamed half as often.
- The raw-vector tiers (AVX2, AVX-512) compute a last column tile of one vector or less with a one-vector micro-kernel (the same FMA chain per lane as the two-vector one).
Every change moves only addresses, row grouping or tile width, never the order of a sum: outputs are byte-identical to 88fc47ccf. Diagnostics: STRATA_VIT_CPU_VPACK=0, STRATA_VIT_CPU_QB=<multiple of 48>, STRATA_VIT_CPU_TAIL1=0; and STRATA_VIT_PROF=1 prints the CPU tower's stage times (stderr, off by default).
Identity, old 88fc47ccf against new, 6 pictures:
- MSVC (owner PC): AVX-512 and AVX2 tiers, Qwen3.8: 12 of 12 identical
- GCC 13.3 (Ryzen 5 5600X): scalar and AVX2 tiers, Qwen3.6 and Qwen3.8: all identical; strata-vision-own-cpu-test passes
- Apple clang (M5 Max): NEON and scalar tiers, both readers: all identical; the unit test passes
Speed, 5 alternating pairs:
- MSVC against mtmd-CPU, 6 threads: big1024 0.986 (pairs 0.968-0.998; was 1.057, pairs 1.049-1.079), code4217 0.903, tiny_64x48 0.851
- NEON new against old: big1024 0.987, code4217 0.993, tiny 1.000; 96 against 48 query rows: 1.001 (level)
- GCC AVX2 new against old (3 runs, before the 96 default): about 0.95
`--tower auto` is unchanged (it keeps mtmd for an MSVC-built x86 reader until the numbers are confirmed).
vit_metal.mm implements VitGpu for Metal, the counterpart of vit_gpu.cu (CUDA / HIP) and vit_sycl.cpp (Intel): the same host flow and the same numbers (weights as stored, BF16 or F16; 16-bit product inputs of the weight's type with float32 accumulation; q / k / v and the scores in F16; the same chunk rules), its own small Metal host (one device, one queue, shared buffers, one command buffer per layer), and the kernels in vit_metal.metal / vit_metal_mpp.metal embedded into the program at build time and compiled when the reader starts, so strata-vision stays one file that links only Apple's frameworks.
The weight products, the scores and the P*V product run on the Metal 4 tensor ops (MetalPerformancePrimitives matmul2d) where they compile and a self-test against the exact product passes, decided per product at load and logged once; else on a plain simdgroup kernel (STRATA_VIT_NO_MPP=1 asks for that; STRATA_VIT_NO_MPP_W / _S / _PV per product). The float32 patch product is a one-output-per-thread kernel: the first run of the tiled simdgroup kernel costs the process about 136 MB of GPU-owned memory on an M5 Max, which a Mac with the tensor ops then never pays. Diagnostics: STRATA_VIT_PROF (stage times), STRATA_VIT_MEM (footprint per load step and per first kernel run).
Built with STRATA_VISION_METAL on Apple (the helper) or STRATA_VIT_OWN_METAL (standalone); gate_gpu.py reads the reader's memory on macOS from `footprint`. `--tower auto` still reads with mtmd on a Mac (VitGpu::prefer_mtmd returns true on Metal until the numbers are confirmed); `--tower own --gpu` runs this tower.
Gate on an M5 Max (macOS 27.2), 18 pictures at 1,024 tokens, 5 repeats:
- rule 1 against x86 mtmd-CPU references of the same pictures and reader files: Qwen3.6 min 0.999943 mean 0.999984, Qwen3.8 min 0.999717 mean 0.999902 (mtmd-Metal: 0.999599 / 0.999895 and 0.998006 / 0.999694); rule 2 18/18 on both
- speed 0.47 to 0.79 of mtmd-Metal (big1024 222 against 362 ms, Qwen3.6)
- memory (footprint) 1,235 against 1,313 MiB (Qwen3.6), 1,228 against 1,329 (Qwen3.8)
- byte-identical over 6 encodes and in a second process
- answers (Qwen3.8, replayed through a CUDA engine): 67 of 72 identical to mtmd-Metal's, wrong answers 0 against mtmd-Metal's 1
strata-vision-own-test passes; no warning in the tower's files.
NOT MEASURED YET: the build, the unit test and the ROUND speed pairs on the vectorised code are still queued on p2006 and l620 at the time of this commit.