Skip to content

[NPUW]MoE optimization - RoPE cache and unfold infer request.#36887

Merged
AlexanderKalistratov merged 3 commits into
openvinotoolkit:masterfrom
intelgaoxiong:xiong/moe-opt
Jul 15, 2026
Merged

[NPUW]MoE optimization - RoPE cache and unfold infer request.#36887
AlexanderKalistratov merged 3 commits into
openvinotoolkit:masterfrom
intelgaoxiong:xiong/moe-opt

Conversation

@intelgaoxiong

@intelgaoxiong intelgaoxiong commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Details:

  • Extend to support RoPE caching for GPT-OSS-20B-A3B and Qwen3-30B-A3B
  • Use unfold infer for DEVICE_ROUTED mode.

Tickets:

AI Assistance:

  • AI assistance used: no / yes
  • If yes, summarize how AI was used and what human validation was performed (build/tests/manual checks).

Signed-off-by: intelgaoxiong <xiong.gao@intel.com>
Signed-off-by: intelgaoxiong <xiong.gao@intel.com>
Signed-off-by: intelgaoxiong <xiong.gao@intel.com>
@intelgaoxiong
intelgaoxiong requested review from a team as code owners July 15, 2026 02:46
@github-actions github-actions Bot added category: NPU OpenVINO NPU plugin category: NPUW NPUW plugin labels Jul 15, 2026
@intelgaoxiong

Copy link
Copy Markdown
Contributor Author

@AsyaPronina @AlexanderKalistratov Could you please take a look? Thanks!

}
}

if (is_moe) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved MoE transformation after RoPE caching, so that it does not break ROPE pattern matching.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates Intel NPUW LLM MoE/RoPE pre-compute handling to support additional RoPE graph variants (including non-duplicated/GPT-style frequency layouts) and adjusts MoE DEVICE_ROUTED execution defaults.

Changes:

  • Extend RoPE cache generation to optionally avoid frequency duplication, and make the RoPE matcher accept an optional Concat between Transpose and Sin/Cos.
  • Add unit tests covering both LLama2-style (duplicated) and GPT-style (non-duplicated) RoPE subgraphs.
  • Enable unfold infer-requests for MoE DEVICE_ROUTED mode and reorder/apply MoE-stage transforms later in the compiled model setup.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/plugins/intel_npu/tests/unit/npuw/pre_compute_test.cpp Adds minimal RoPE models + tests validating Sin/Cos replacement for both duplicated and non-duplicated RoPE patterns.
src/plugins/intel_npu/src/plugin/npuw/partitioning/patterns/pre_compute.hpp Extends RoPE pattern descriptor with a duplicate_freqs flag used during cache creation.
src/plugins/intel_npu/src/plugin/npuw/partitioning/patterns/pre_compute.cpp Implements optional duplication in LUT generation and updates the RoPE pattern to handle optional Concat and infer duplication from the matched graph.
src/plugins/intel_npu/src/plugin/npuw/llm_compiled_model.cpp Switches DEVICE_ROUTED to use unfolded infer-requests and refactors where MoE configs/transforms are applied.
Comments suppressed due to low confidence (1)

src/plugins/intel_npu/src/plugin/npuw/llm_compiled_model.cpp:745

  • [HIGH] The MoE-specific default overrides for NPUW_LLM_SHARED_HEAD and NPUW_LLM_GENERATE_HINT were removed. This changes MoE defaults from shared_head=true and generate_hint=FAST_COMPILE (per npuw_option_defs.inc / NPUWStringEnumOptionTraits<GenerateHint>::defaultValue()) to being applied for MoE models as well, which is a significant behavioral/perf change and doesn’t seem related to the PR’s stated goals.

If the intent is to keep the previous MoE behavior unless the user explicitly sets these options, please restore the conditional overrides inside the if (is_moe) block.

    // Auto-detect MoE model by scanning for router/expert nodes
    const bool is_moe = is_moe_model(model);
    if (is_moe) {
        // Enable DEVICE_ROUTED mode by default for MoE models on newer compiler versions, as it's more efficient than
        // HOST_ROUTED
        if (npuw_llm_props.find("NPUW_LLM_GENERATE_MOE_HINT") == npuw_llm_props.end() && npudesc->arch == "5010" &&
            npudesc->compiler_ver >= ONEAPI_MAKE_VERSION(7, 29)) {
            m_cfg.update({{"NPUW_LLM_GENERATE_MOE_HINT", "DEVICE_ROUTED"}});
        }
    }

@AlexanderKalistratov
AlexanderKalistratov added this pull request to the merge queue Jul 15, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 15, 2026
@AlexanderKalistratov
AlexanderKalistratov added this pull request to the merge queue Jul 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

CI Doctor — Merge Queue failure on this PR

Pipeline: Windows (VS 2022, Python 3.11, Release)
Failure: JS API E2E Electron cleanup fails on Windows - Permission denied removing locked electron.exe/dll
Automatic restart: ❌ Not triggered — this is a known recurring flaky cleanup issue (4th occurrence); a restart would hit the same Windows file-locking problem. A code fix is needed.

Possible remedy

  1. In the JS E2E Electron test after all hook, replace rm -rf demo-electron-app-project with Node.js cross-platform removal: fs.rmSync('demo-electron-app-project', { recursive: true, force: true }) — this uses Windows APIs and handles locked files.
  2. Alternatively, use the rimraf npm package (add to devDependencies), which implements retry logic for Windows-locked files.
  3. Add a short delay (500–1000 ms) before cleanup to allow Electron to fully release file handles after process exit.
  4. As a quick workaround, wrap the cleanup in a try/catch so a cleanup failure does not fail the test suite (if cleanup is not critical to test correctness).

What happened

The JS API (26) job ran the E2E Electron test suite — both functional tests passed (should install dependencies, should run electron package and verify output). The after all cleanup hook then failed because rm -rf demo-electron-app-project could not delete electron.exe and d3dcompiler_47.dll in the node_modules/electron/dist/ directory, which Windows had locked.

This is the 4th recorded occurrence of this exact pattern (first seen 2026-07-09). Prior runs: 29268143021, 29072781821, 29010970383.

Generated by CI Failure Doctor — Merge Queue · 113.8 AIC · ⌖ 7.1 AIC · ⊞ 18.6K ·

Merged via the queue into openvinotoolkit:master with commit 337f0f6 Jul 15, 2026
201 of 203 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: NPU OpenVINO NPU plugin category: NPUW NPUW plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants