Repository navigation
Description
Owner-requested review (2026-11-17) of oxe speed and efficiency on the Snapdragon lab laptop, the NPU result, and a Mac (Asahi/Omarchy and macOS Metal/MLX) path. Read-only by a reviewer model; [C]=confirmed, [M]=measured, otherwise inferred. Items for v0.2.2/v0.2.3/v0.3, one issue per item linked from here, sized for DeepSeek worker lanes. Nothing here changes v0.2.1.
oxe on the laptop and on Mac: speed review, 2026-11-17
Read-only. Nothing was built, run or benchmarked; hardware was inspected through sysfs only. [M] = measured (receipt named), [C] = confirmed by reading code or sysfs, [I] = inferred, [O] = open. Code was read from a local clone at origin/main 7d45b88 because the GitHub REST quota was exhausted; the eleven files cited here were checked byte-identical against main 69a8151.
1. Why the NPU lost to the CPU
Two separate questions with different answers.
1a. Memory throughput on the NPU path is lower than on the CPU
| Path | Rate | Receipt |
|---|---|---|
| CPU streaming read, 8 cores | 110-111 GB/s (roof 116) | W2b-CPU-DMA |
| CPU decode, useful weight bytes | 89-90 GB/s | W2-CPU-BASELINE |
| NPU pure DMA, 1 queue sequential | 61.9 GB/s | W8-DDR-READ-CONTROL |
| NPU pure DMA, gather, 1 / 2 / 4 queues | 51.8 / 56.0 / 56.2 GB/s | NPU-BW-1 |
| NPU real 4-bit matvec, 4 workers, useful | 36.8 (Q4_0), 26.5 (MXFP4) GB/s | W8-K1 |
Ranked causes:
- One shared DMA path on the NPU side ([M] shape, [I] mechanism). Four queues give +8.6% over one, double block size +0.3%, output writes -1.2% (NPU-BW-1): the limit is neither per queue nor per descriptor. The CPU reaches its roof with 8-12 cores each driving the memory controller; the NPU moves everything through one DMA engine into an 8 MiB working buffer. This is the owner's "not the same memory path" hypothesis: confirmed.
- In the real kernel the limit is compute, not memory [M]. DMA wait is 3.3% (MXFP4) and 11.8% (Q4_0) of cycles (W8-K1); most vector packets re-order 4-bit nibbles (O-71). The planar layout meant to fix this (NPU-BW-2) has no result file: its projection is unverified.
- Memory-bus clock votes [O]. DDR/LLCC devfreq use a
remotegovernor [C], which appears to follow CPU load [I]. In NPU-only runs DDR reported maximum in 7-24% of samples, against 100% during CPU decode (T31). A sysfs minimum pin did not hold (+0.09%); a light CPU keep-alive gave +0.15%. Not refuted: no arm ever held the bus at maximum. - Accounting [M]. NPU figures are padded transfer bytes (useful = 0.9 x for Q4_0), CPU figures logical payload; neither is a DRAM counter. The 0.24 GB/s
DMATESTlines in NPU-LIMITS are unexplained [O] and should not be read as bandwidth. - Refuted [M]: mapping cost of the shared buffer (the CPU reads it at 99.1% of anonymous memory, W2b-CPU-DMA), and NPU compute throttling (10.44 TFLOP/s flat for 100 s, NPU-LIMITS).
1b. The NPU path was slower end to end
| Workload | Result [M] | Cause |
|---|---|---|
| Dense prefill, serial (W2-A) | 293 vs 334 tok/s (-12%); -6.4% with tile transfers | Host marshalling: ~2.6 s per prefill to convert, pack, unpack and commit activations, against 0.59 s in the NPU call (W2-A-HOST) [M] |
| Dense prefill, overlapped (W2-OVERLAP) | 1.0016x | The offloaded set is small. The NPU arm spent ~3.2 s of mutex-owned projection wall and ran 1.7 s longer, so the CPU does the same work in ~1.5 s of 12.3 s [I]. Zero-cost removal gives at most ~1.14x, below the 1.2x bar. The "31% dense share" in W2-CPU-BASELINE is thread-time including waits, and attention projections stayed serial |
| Routed experts in native quant (W2b) | 77x slower | 99.7% of NPU cycles expand Q3_K/Q4_K to fp16; the matrix unit computes in fp16 [M]. Format hypothesis: confirmed |
| Batch-1 decode | not built | Bandwidth-bound: 37 useful GB/s against 89 on CPU [M] |
| Long-context attention, PV (NPU-ATTN-1) | 3.8 TOPS, killed; QK passed at 7.8 | The 8 MiB buffer forces 8 calls plus a host sum (3.6 of 18 ms) [M] |
| Image DiT linears (W1) | 31 s to 12.7 s | Large fp16 GEMMs with resident fp16 weights: the case that fits [M] |
Remaining owner hypotheses: per-call FastRPC cost is confirmed for small ops (echo 0.077 ms; 16-64-row calls reach 0.3-1.0 TOPS at 84-90% DMA wait) and minor for large ones; op granularity is confirmed (64-row batch 2.8 TOPS, 512-row 8.6, NPU-LIMITS); synchronous dispatch is confirmed (call wall ~50% of roof while the active GEMM is at 85%); measurement method mixes units (TOPS, TFMA, GMAC, padded and useful GB/s) but no verdict reverses.
Top hypothesis: the NPU arithmetic is healthy (85-94% of its fp16 roof). It lost because the work that suits it (large fp16 GEMMs on resident fp16 weights) is about an eighth of MoE prefill wall time, and each call pays host conversion and a synchronous round trip larger than the saving.
Cheapest decisive experiments
NPU-LLM work is stopped (O-76) and rule R1 requires a paper price before device time.
| # | Experiment | Cost | Confirms | Refutes |
|---|---|---|---|---|
| E1 | Recompute the 1.5 s figure from the per-phase wall timers in the W2-A-HOST and W2-OVERLAP logs | Paper | Offloaded CPU wall <= 2 s: dense offload is closed for MoE (ceiling < 1.2x) | > 2.5 s: a fused whole-ubatch call is worth one pricing run |
| E2 | Convert the NPU-LIMITS MIX DMA rows to GB/s and add the CPU stream rate (70 alone, 37.4 with DMA) |
Paper | Sum near the CPU-alone roof: DRAM is shared, the NPU is port-limited | Sum well above: separate headroom |
| E3 | One 3 s pure-DMA arm while idle cores run a cache-missing, low-bandwidth load that holds DDR at maximum in >= 90% of samples | <= 5 min device | <= 2% change: clock closed | >= 10%: a bus-vote problem |
| E4 | NPU-BW-2 as specified, simulator identity first | <= 15 min device | <= 40 pcycles per tile: compute was the limit | > 55: stop kernel work |
E3 and E4 only if the owner reopens the NPU, each as one pre-registered session.
2. Getting more out of the laptop
Read today [C]: 12 Oryon cores, cpu_capacity 1024 on all, three cpufreq policies (0-3, 4-7, 8-11), schedutil under the performance profile, no EPP knob (driver scmi), THP always.
| Topic | Status and expected gain | Effort | Risk |
|---|---|---|---|
| Core pinning, prefill threads | No big/little here. The asymmetry is thermal per cluster: sustained medians 2.97 / 2.71 / 2.26 GHz at 97.7 °C. Twelve threads still win long prefill: 70.4 tok/s vs 64.8 (10) and 53.6 (8) at 40K, flat over 442 s (V013-THERMAL) [M]. Keep 12 | Done | - |
| Decode threads | Default 0-7 packed (main.rs:127) [C]; packed beats spread, 99.6 vs 85 GB/s (T32) [M]. Ten threads at 32K: +4.2% Ornith, +3.5% Qwen, provisional (V013-DECODE) [M] |
One warm HTTP row, then a context-length rule | Low; token hashes matched |
| Cooling | Passive cool-down to 60 °C: 1.05x on the next long append, one pair (V013-THERMAL) [M]. A stand or fan curve is worth ~5% on long prefills | Docs / user setting | None |
| THP for the V cache | Off saves 1.24-1.41 GiB RSS at ~1% Ornith decode (M3 5T) [M]. Decided in oxstack/ox-llm#858 | In progress | Low |
| Weight arena pages | Read-only file mapping; thp_collapse defaults off (weights.rs) [C], so weights are probably on 4 KiB pages [I]. An anonymous THP arena exists for A/B. No current receipt: [I] 0-3% decode |
One A/B row | Memory headroom for Qwen |
| MTP | Sampled depth 1 installed: +8.6% Ornith, +30.5% Qwen (M2) [M]; by context 1.08-1.38x (V013-DECODE) [M] | - | - |
| Battery | No receipt; all [I]. Decode is bandwidth-bound, so 6 threads should keep most of the speed at lower power | One row with a power readout | None; opt-in |
| Cold reload | 37-43 s [M]. Disk encryption costs 2.41 vs 3.74 GB/s (T33) [M]; arena cache on the plain volume plus parallel fault-in: [I] 20-40% of a cold load. Keep-warm already avoids most reloads | Small-medium | Low |
| Idle cost | Workers park on a futex (sched/lib.rs) [C]; a 20/s signal poll and a 4/s watcher remain [I]: oxstack/ox-llm#878 |
Small | Watcher interval is an owner call |
Measured and closed, do not reopen: int8 K/V cache (QC-4b/4c/4d), MTP depth >= 2 (M3), governor (+0.4% / +0.7%, O-191), DDR pin (T31), Adreno via Vulkan (8.9-49 GMAC/s against ~1,500 on CPU, gpu-micro), fused decode and fa2 (M3), static cluster partitioning.
Top five: (1) V-cache THP off, then requalify the admission budget so Qwen is not refused at 23.4 GiB; (2) ten decode threads at long context; (3) weight-arena page A/B; (4) cooling guidance; (5) cold-reload path with the battery profile. Each should go default-on as soon as its row is neutral or better.
3. Mac
No matched Mac measurement exists (#241; mac_reproduce.py has never run on a Mac). Every gap below is [I].
3a. Linux on Apple silicon (Asahi, Omarchy)
- omarchy-mlx (https://github.com/joshuaswarren/omarchy-mlx, linked from oxstack/ox-llm#293): the
mlxPython module with a Vulkan backend on Mesa's Honeykrisp driver, "no Metal and no CPU fallback"; Core ML models on the Neural Engine through its own driver; a chat UI andmlx-omarchy-serve(catalog, plan, serve). Its README documents no HTTP API. Its M1 Max rows: Linux reaches 62% of macOS MLX decode (37.1 vs 59.4 tok/s, Qwen3.5-9B) and 88% of prefill; Qwen3.6-35B-A3B runs 13.6 tok/s decode, 116 tok/s prefill. - oxe there (
PORTABILITY-PROBE-ARM2.md, Apple M2) [M]: builds unchanged, model-free tests pass, kernels at the instruction roof, all-core tile rate 0.43 of the Snapdragon. No model was run. Needed: per-machinetarget-cpu, P-core-only placement, a small smoke model; 1-2 weeks by the probe's estimate. - Plan: CPU engine with correct placement, plus an adapter that fronts an external accelerated server. No own Vulkan kernels.
3b. macOS with Metal / MLX
- Expected gap [I]: prefill 3-10x for the GPU (compute-bound; 4-12 performance cores on the CPU side); decode 1.2-2x (both bandwidth-bound, but CPU cores cannot draw the whole unified-memory bandwidth on Pro/Max chips). The repo's only Mac row is unmatched: M4 Max, MLX, 45.0 tok/s, 90.1 with MTP (
RESULTS.md). - Minimal architecture:
- Backends sit at the server's
Enginetrait (the stub implements it [C]), not at the kernel level. ExternalEngine: HTTP client to any OpenAI-compatible local server (mlx-lm, llama.cpp with Metal); 1-2 weeks (x86 probe). oxa and the serving layer work on Mac at once, and the macOS: CI now, oxa on macOS in 0.2.2 (Seatbelt sandbox), local engine later oxa#35 measurement becomes possible.MlxEngine:mlx-rs(0.34.0, unofficial, bindsmlx-cthroughmlx-sys, featuresmetalandaccelerate, Rust >= 1.88) ormlx-cdirectly (CMake; the base of MLX Swift). MLX does not load GGUF: the catalog needs MLX-format entries and the MTP head must be rebuilt as an MLX graph.- Unified memory [I]: KV snapshot and restore stay memory copies, so prefix cache and state store carry over once tensors can be exported.
- Packaging: Homebrew tap and install script as decided in macOS: CI now, oxa on macOS in 0.2.2 (Seatbelt sandbox), local engine later oxa#35; the Metal shader library ships beside the binary [I].
- Backends sit at the server's
- What a Rust-native suite offers on Mac: not kernels. One small binary for agent, gateway and engine supervision (idle 10 MB RSS on a Linux helper [M], oxa developer-love scorecard (measured every release) oxa#34), prefix and state caching with session restore, memory admission and idle unload, a native sandbox, local and cloud routing with a spend ledger.
4. Roadmap
| Release | Engine items (CI-only unless marked) |
|---|---|
| v0.2.2 | Existing oxstack/ox-llm#858, oxstack/oxa#50-#885. New: N1 build guards, N2 per-machine CPU target and placement, N3 hardware report |
| v0.2.3 | N4 ExternalEngine; N5 Mac volunteer receipt; N6 decode team by context (laptop row); N7 weight-arena page A/B (laptop row); N8 cold-reload path; N9 battery profile |
| v0.3 | MlxEngine; kernel interface with a generic backend (#293 option a). NPU: the recorded reopen condition for long-context prefill attention is met (O-159) and QK passed, but PV needs a fused kernel without the host split, built only if priced >= 3x the best CPU kernel (O-106); dense prefill stays closed unless E1 says otherwise |
Worker lanes. oxa work is a deterministic runner that spends no model tokens: it claims issues, runs workers in worktrees, checks acceptance, publishes and queues review; the lead session brings only decisions to the owner (lead-agent design, 2026-11-16).
- Cheap lanes (DeepSeek on Go): model-free issues with files, spec and an acceptance test that runs on hosted CI against the stub engine or fixture trees. N1-N5, N8 and N9 fit.
- Hard tier (orchestrator review): anything under
kernels-sys,modelnumerics orsched. The worker writes code and bit-identity tests; the orchestrator reviews and pre-registers thresholds. - Hardware: workers never touch the laptop. Qualified changes queue into one pre-registered batch, like M1-M4; loops and builds run on the helper machine.
- Lab-only ticket, not a public issue: E1 and E2 above, from private receipts.
Proposed issue updates
(i) Replacement for "Step 3" of oxstack/oxa#35
Step 3 (0.2.3 to 0.3): local engine on macOS
No matched Mac measurement exists yet (#241), so this step starts with one.
- 0.2.3, engine adapter: implement the server's
Enginetrait as an HTTP client to an external OpenAI-compatible local server (mlx-lm or llama.cpp with Metal). oxa and the serving layer (prefix reuse, session restore, admission, idle unload) then work on macOS without our kernels.- 0.2.3, measurement: on one Apple silicon Mac, same model family and prompts: (a) CPU-only oxe-server on performance cores, (b) llama.cpp with Metal, (c) MLX, (d) the adapter in front of (b) or (c). Prefill and decode reported separately, with receipts. The CPU engine already builds and passes its model-free tests on an Apple M2 under Linux (
engine/docs/PORTABILITY-PROBE-ARM2.md).- Decision rule (proposed thresholds, owner to confirm): if CPU-only is within 1.3x of Metal/MLX on decode and 2x on prefill, ship the CPU engine with performance-core placement. Otherwise build a native MLX backend behind the same trait in 0.3 (
mlx-rsormlx-c), with MLX-format model entries and KV export for the state store.- Linux on Apple silicon (#293): CPU engine plus the adapter in front of an existing accelerated server; no own GPU kernels.
Distribution stays as decided: Homebrew tap and install script.
(ii) New issues
- engine: architecture guards in the
int8-gemmandqwen4expbuild scripts.cargo check --workspacefails off aarch64 because both pass ARM-marchflags to the host compiler. Mirror the early return inkernels-sys/build.rs. Done when the workspace check passes on x86_64 and macOS runners. - engine: per-machine CPU target and hybrid-aware default placement. Replace the fixed
target-cpu=oryon-1with a documented per-target setting. Default--oxe-cpusto the highest-capacity cores when capacities differ; unchanged when equal. Tests with fake sysfs trees. - oxe: read-only hardware report.
oxe doctor --hardware --json: cores, capacities, cpufreq policies and governor, THP mode, thermal zones, memory. No writes, no benchmark. Golden tests on fixture trees. - engine:
ExternalEngineadapter.Enginetrait over HTTP to an OpenAI-compatible server: streaming, cancel, token counts. Tested against the stub server. Prefix-cache behaviour documented as pass-through. - benchmarks: Mac volunteer run. Make
mac_reproduce.pyrunnable in one command, add a CPU-only oxe arm, publish the receipt format. Closes the Mac half of benchmarks: matched stock-versus-now baselines with JSON receipts, and a Mac volunteer run #8. - engine: decode team size by context length. Optional rule selecting the decode thread count from the active context length; default unchanged. Token-identity test across team sizes. One laptop row decides the default.
- engine: weight-arena page-size switch. Expose the existing anonymous-THP and file-collapse options as one switch; record backing and huge-page coverage in the load receipt. One laptop row: decode tok/s, RSS, load time.
- engine: cold-reload path. Parallel fault-in of the arena after mapping; documented cache location. Load-phase timings in the receipt. One laptop row for cold and warm reload.
- oxa: battery profile (opt-in). Setting that selects a smaller decode team on battery; default unchanged. AC/battery detection tested with fixtures. One laptop row with a power readout before any default change.
Activity
n0rpan commentedon Nov 17, 2026
O389 nine-item helper index (all tracked in v0.2.2,
after-0.2.1; no v0.2.1 implementation):N1–N3 retain proposed v0.2.2 scope; N4–N9 retain proposed v0.2.3 implementation/hardware gates. Native MLX remains v0.3 and outside these filings. Existing #8/#293/#796/#858 and oxstack/oxa#50–#885 retain their owners/scopes. Defaults, thresholds and engine/scheduler hard changes still require recorded owner/identity review. Specs only; no implementation or device work.
n0rpan commentedon Nov 19, 2026
Triage 2026-11-19: this issue is now tracked in #28 (Cluster: Engine performance and hardware, priority P2), planned PR 2: "Hardware report and selectors". It will be fixed there together with its related issues, not one by one.