<|start|>system<|message|>You are ChatGPT, a large language model trained by OpenAI.
Knowledge cutoff: 2024-06
Current date: 2026-10-15

Reasoning: low

# Valid channels: analysis, commentary, final. Channel must be included for every message.<|end|><|start|>developer<|message|># Instructions

Answer concisely.<|end|><|start|>user<|message|>What are the main risks described in this document?

# Intel NPU prefill through a separate OpenVINO service (STRA-207, experimental)

Status: experimental. Opt-in through `leleka-npu-worker`; the CPU worker (`leleka-cpu-worker`) is unchanged and
never loads OpenVINO.

## Decision

The NPU is reached through OpenVINO. The owner chose a **separate service process**: `leleka-npu-service` loads
the OpenVINO C API (`openvino_c.dll`, dynamically, via `libloading`), memory-maps the same GGUF, and answers matrix
product requests. The worker (`leleka-npu-worker`) does everything else on the CPU (RMSNorm, RoPE, attention,
router, SwiGLU, combine) and only offloads the large matrix products of **prefill**. Decoding stays on the CPU.
No Python is involved at any point.

If the service cannot start, the worker serves from the CPU only. If an NPU prefill fails it is redone on the
CPU and the NPU is not used again in that session. Before each prefill the worker checks free memory
(`NpuPrefill::estimate_bytes`) and falls back to the CPU when it is short.

## Crates

| crate | role |
|---|---|
| `leleka-shm` | shared file mapping between worker and service (Windows + unix) |
| `leleka-openvino` | minimal dynamic binding of the OpenVINO C API (core, compile, infer request, tensors, `CACHE_DIR`) |
| `leleka-npu-service` | the service: weight expansion, hand-written IR graphs, protocol, prefetch |
| `leleka-gptoss-npu` | client of the service and the NPU-assisted prefill (`PrefillAccelerator`) |
| `leleka-npu-worker` | the worker binary |

Unsafe exceptions (raw OS mapping, FFI into OpenVINO, pointer-backed tensors) are recorded in the code next to
each block and are due for review on 2027-01-14.

## How a product runs

* Graph: `x[M,K] f16`, int8 weights `[N,K/32,32]` and f16 scales `[N,K/32,1]` as **runtime inputs** →
  Convert → Multiply → Reshape → MatMul. Group scales are exact for Q8_0 and MXFP4 block scales; this is about
  2x slower than per-channel scales and was kept for exactness.
* The NPU rejects `f4e2m1`, so MXFP4 is expanded to int8 (doubled E2M1 table, scale `2^(e-128)` as f16; exact).
* The NPU **flushes f16 subnormals to zero**. Real gpt-oss scales include subnormals, which first produced wrong
  results (KL about 0.1). Fix: per-row scale boost by `2^shift` (`normalize_scales`); the service returns per-column
  shifts after the result and the client divides them out. Exact.
* Static shape buckets 32…4096 rows; compiled graphs are cached with OpenVINO `CACHE_DIR`
  (cold compile of the buckets about 26 s, cached start-up is a few seconds).
* Protocol: lines on stdin/stdout plus a shared region for tensors. `<|end|><|start|>assistant<|channel|>final<|message|>