Skip to content

ggml-openvino: one output in the decode model of a static NPU pair - #445

Merged
cavusmustafa merged 1 commit into
ravi9:dev_backend_openvinofrom
yzhou51:qwen3.6_kld
Nov 20, 2026
Merged

cavusmustafa merged 1 commit into
ravi9:dev_backend_openvinofrom
yzhou51:qwen3.6_kld

Conversation

@yzhou51

@yzhou51 yzhou51 commented Nov 20, 2026 •

Copy link
Copy Markdown

Overview

We meet this issue when doing the KLD measurement.

On the NPU, a static graph is compiled as a pair: a prefill model and a decode model. The decode model is built with a copy of the prefill graph's compute params, including output_len, the size of the output-ids input.

For generation, output_len is 1, so the copy is harmless. llama-perplexity asks for many outputs per batch (128 at -c 256), so the decode model of its pair gathers 128 rows from its single token in the last layer.

  • Dense models: the oversized decode model still compiles. OpenVINO checks shapes, not index values, and nothing runs that decode model during prefill perplexity. So nothing fails: Qwen3.5-4B, for example, measures fine with -b 512. With -b 1 (decode KLD) every graph has one output, so the decode model is correct either way.
  • MoE models (see PR C): the last layer's MoE block then differs from the others, and NPUW fails to compile the model:
NPUW could not lower the isolated expert partition to sparse execution: Model1_FCEW002__0

Additional information

Change

The decode model of a pair now always gets output_len = 1. A decode step outputs one token, and the model-cache key of the decode model already assumed this (decode_signature is static-1 out=1).

The change is in ov_graph_compute_static, which runs only for static graphs (the NPU, or GGML_OPENVINO_FORCE_STATIC). Dynamic graphs are not affected.

Testing

It depends on the PR443 and PR444 if using the Qwen3.6-35B-A3B model for the KLD testing.

In the windows

set GGML_OPENVINO_DEVICE=NPU
set GGML_OPENVINO_PREFILL_CHUNK_SIZE=128
set GGML_OPENVINO_NPU_CONFIG=NPUW_WEIGHTS_BANK_ALLOC=CPU,NPUW_FUNCALL_ASYNC=NO,COMPILATION_NUM_THREADS=1
  • Generation and decode KLD (-b 1): unchanged. output_len was already 1.
  • Dense models with prefill perplexity: the decode model of the pair is now the normal 1-output model instead of one with an LM head over all the output rows. It saves compile time and memory. The perplexity results cannot change, because that model is not run (not measured on a dense model with this change).
  • Qwen3.6-35B-A3B Q4_0, with PR444, on the PTL NPU: llama-perplexity -c 256 -b 256 --kl-divergence failed in the decode model before the change. After it, all 40 chunks run (results in PR C).
  • Other multi-output batches take the same path. Qwen3.6-35B-A3B Q4_0, with PR444, on the PTL NPU: llama-server -c 512 -np 1 --spec-type ngram-simple --spec-ngram-simple-size-n 3 --spec-ngram-simple-size-m 4, greedy, 48 tokens.
    • The verification batches (up to 5 outputs) compile and run.
    • Draft acceptance is 0.947 (36 / 38).
    • The output is identical to the same request without speculative decoding.
    • Speculative decoding is slow on the NPU, for reasons outside this PR: see the known limitations of PR444.

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure:
    YES, I use the AI to do the debug and analysis.

The decode model of a static prefill/decode pair copied the compute params of the
prefill graph, including output_len. With llama-perplexity the prefill graph has many
outputs (128 at -c 256), so the decode model gathered 128 rows from its one token in
the last layer. For a MoE model that layer then differs from the others and NPUW fails
to lower its experts ("could not lower the isolated expert partition"). A decode step
outputs one token; the model cache key already assumes it (decode_signature out=1).
@cavusmustafa
cavusmustafa merged commit 80ea1c8 into ravi9:dev_backend_openvino Nov 20, 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.

2 participants