Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LLM] [NPU] StaticLLMPipeline: Compiler DQ update #1515

Merged
merged 8 commits into from
Jan 14, 2025
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions src/cpp/src/llm_pipeline_static.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,11 +475,10 @@ std::optional<NPUDesc> extract_npu_descriptor(ov::Core& core) {
}
const auto arch = core.get_property("NPU", ov::device::architecture);
const auto max_tiles = core.get_property("NPU", ov::intel_npu::max_tiles);

bool compiler_dq = false;
const auto device_caps = core.get_property("NPU", ov::device::capabilities);
if (std::find(device_caps.begin(), device_caps.end(),
"COMPILER_DYNAMIC_QUANTIZATION") != device_caps.end()) {
const auto supported_properties = core.get_property("NPU", ov::supported_properties);
if (std::find(supported_properties.begin(), supported_properties.end(),
lmielick marked this conversation as resolved.
Show resolved Hide resolved
"NPU_COMPILER_DYNAMIC_QUANTIZATION") != supported_properties.end()) {
compiler_dq = true;
}
return std::make_optional(NPUDesc{arch, max_tiles, compiler_dq});
Expand Down Expand Up @@ -516,6 +515,10 @@ ov::AnyMap get_default_prefill_config(const std::shared_ptr<ov::Model>& model,
auto config = get_default_common_config(model);
if (is_cw_compressed(model)) {
config.emplace("NPUW_DQ", "YES");
if (npudesc.has_value() && npudesc->compiler_dq) {
config.emplace("NPUW_DQ_FULL", "NO");
config.emplace("NPU_COMPILER_DYNAMIC_QUANTIZATION", true);
}
Copy link
Contributor

@dmatveev dmatveev Jan 13, 2025

Choose a reason for hiding this comment

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

Why do you enable it for CW compressed models only? The whole point of this feature was to make it for group-quantized prefill.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

} else {
config.emplace("NPUW_PMM", "NO");
}
Expand All @@ -524,9 +527,6 @@ ov::AnyMap get_default_prefill_config(const std::shared_ptr<ov::Model>& model,
npudesc->max_tiles != -1) {
config.emplace("NPU_DPU_GROUPS", npudesc->max_tiles);
}
if (npudesc.has_value() && npudesc->compiler_dq) {
config.emplace("NPUW_DQ_FULL", "NO");
}
return config;
}

Expand All @@ -539,15 +539,16 @@ ov::AnyMap get_default_generate_config(const std::shared_ptr<ov::Model>& model,
}
// NB: Unconditionally set for generation model
config.emplace("NPUW_DQ", "YES");
if (npudesc.has_value() && npudesc->compiler_dq) {
config.emplace("NPUW_DQ_FULL", "NO");
config.emplace("NPU_COMPILER_DYNAMIC_QUANTIZATION", true);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

You certainly don't need to make it twice, just do this in the shared section of the config (so it goes to both prefill and kvcache).

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, when you switch to compiler DQ, you'll have to disable DCOFF since otherwise DCOFF will be applied to this model and it will run in FP16.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

if (npudesc.has_value() && npudesc->arch == "4000") {
config.emplace("NPU_DPU_GROUPS", 4);
}
if (hint == GenerateHint::FAST_COMPILE) {
config.emplace("NPUW_UNFOLD_IREQS", "YES");
}
if (npudesc.has_value() && npudesc->compiler_dq) {
config.emplace("NPUW_DQ_FULL", "NO");
}
return config;
}

Expand Down
Loading