Skip to content

ggml-openvino: enable NPU L0 host tensors and fast prefill mask by default - #368

Merged
ravi9 merged 2 commits into
ravi9:dev_backend_openvinofrom
zhaixuejun1993:xuejun/enable_npu_fast_mask_default
Oct 29, 2026
Merged

ravi9 merged 2 commits into
ravi9:dev_backend_openvinofrom
zhaixuejun1993:xuejun/enable_npu_fast_mask_default

Conversation

@zhaixuejun1993

Copy link
Copy Markdown
Collaborator

ggml-openvino: enable NPU L0 host tensors and fast prefill mask by default

GGML_OPENVINO_NPU_L0_HOST_TENSORS and GGML_OPENVINO_NPU_FAST_MASK now default to 1; set
either to 0 to disable it.

  • L0 host tensors: the NPU plugin imports Level Zero host buffers without a copy each infer.
    On phi-4-mini Q4_0 (pp3072+tg512) decode goes from 7.2 to 10.6-10.8 t/s. Allocation
    failures still fall back to plain host memory.
  • Fast mask: build each static prefill mask chunk directly in the OV input tensor, with no
    temporary vector and no full-tensor copy. The result is identical to pad_input() +
    set_zero_diagonal().

@wine99 wine99 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If fast_mask always works and l0_host_tensor can always fallback automatically, can we simply remove the env var and use them by default?

@ravi9
ravi9 force-pushed the dev_backend_openvino branch 2 times, most recently from be796d8 to 25e3135 Compare October 29, 2026 17:37
Back NPU buffers with Level Zero host memory unless GGML_OPENVINO_NPU_L0_HOST_TENSORS=0.
The plugin imports these buffers without a host-to-device copy each infer; on phi-4-mini
Q4_0 (pp3072+tg512) decode goes from 7.2 to 10.6-10.8 t/s. Allocation failures still fall
back to plain host memory.
GGML_OPENVINO_NPU_FAST_MASK now defaults to 1; set it to 0 to fall back to pad_input() + set_zero_diagonal().

The fast path builds each static prefill mask chunk directly in the OpenVINO input tensor (row memcpy of the valid prefix, -inf padding, zero diagonal), avoiding a temporary chunk_size x context_size vector and a full-tensor copy per chunk. The result is bit-identical to the fallback path.
@ravi9

ravi9 commented Oct 29, 2026

Copy link
Copy Markdown
Owner

We can leave the ENV vars as opt-outs for now, and remove/deprecate them in the upcoming releases..

@ravi9
ravi9 force-pushed the xuejun/enable_npu_fast_mask_default branch from 489e77b to d0eacda Compare October 29, 2026 19:11
@ravi9
ravi9 merged commit b1d8ce7 into ravi9:dev_backend_openvino Oct 29, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants