[NPUW]MoE optimization - RoPE cache and unfold infer request.#36887
Conversation
Signed-off-by: intelgaoxiong <xiong.gao@intel.com>
Signed-off-by: intelgaoxiong <xiong.gao@intel.com>
Signed-off-by: intelgaoxiong <xiong.gao@intel.com>
|
@AsyaPronina @AlexanderKalistratov Could you please take a look? Thanks! |
| } | ||
| } | ||
|
|
||
| if (is_moe) { |
There was a problem hiding this comment.
Moved MoE transformation after RoPE caching, so that it does not break ROPE pattern matching.
There was a problem hiding this comment.
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_ROUTEDmode 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_HEADandNPUW_LLM_GENERATE_HINTwere removed. This changes MoE defaults fromshared_head=trueandgenerate_hint=FAST_COMPILE(pernpuw_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"}});
}
}
CI Doctor — Merge Queue failure on this PRPipeline: Windows (VS 2022, Python 3.11, Release) Possible remedy
What happenedThe This is the 4th recorded occurrence of this exact pattern (first seen 2026-07-09). Prior runs: 29268143021, 29072781821, 29010970383.
|
337f0f6
Details:
Tickets:
AI Assistance: