Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion ggml/src/ggml-openvino/dev_doc/OpenVINO-ENV-VARS.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ Most of these options are off by default. They are not validated for general use
| `GGML_OPENVINO_GDN_NATIVE_STATE` | NPU | Boolean | `0` | Keep the `GATED_DELTA_NET` state in the layout of the OpenVINO op instead of the GGML layout. Every `GATED_DELTA_NET` must then run on the OpenVINO backend; the load aborts if one would run on the CPU backend. Saved states and `GGML_OPENVINO_DEBUG_NODE` dumps hold the OpenVINO layout. `test-backend-ops` fails with it. |
| `GGML_OPENVINO_FORCE_STATIC` | CPU, GPU | Boolean | `0` | Run the static-shape path of the NPU on the CPU or the GPU, to separate translation bugs from NPU plugin or driver problems. This includes the NPU translation of MoE blocks, which computes every expert on the CPU or the GPU and is slow. Cannot be used with `GGML_OPENVINO_COMPILED_MODEL_CACHE_ONLY`. |
| `GGML_OPENVINO_ENABLE_FALLBACK` | all | Boolean | `0` | Detect graphs that the scheduler splits between OpenVINO and another backend, and translate them as partial graphs, without the compiled model cache. By default every graph is treated as a complete model graph. Cannot be used with `GGML_OPENVINO_COMPILED_MODEL_CACHE_ONLY`. |
| `GGML_OPENVINO_NATIVE_SOFTPLUS` | all | Boolean | `0` | Translate `SOFTPLUS` to the OpenVINO `SoftPlus` op instead of the default `relu(x) + log1p(exp(-abs(x)))`. |
| `GGML_OPENVINO_KV_SCATTER_ELEMENTS` | all | Boolean | `0` | Use `ScatterElementsUpdate` instead of `ScatterUpdate` for single-row KV writes in stateless execution. |

## Memory optimization
Expand Down
2 changes: 1 addition & 1 deletion ggml/src/ggml-openvino/dev_doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Cache-only mode (`GGML_OPENVINO_COMPILED_MODEL_CACHE_ONLY=1`):

Settings that must stay exactly the same between the runs, including set versus unset. A different value selects another cache entry, and cache-only mode then fails. Source: `cache_settings[]` in `model-cache.cpp`.

- `GGML_OPENVINO_GPU_CONFIG`, `GGML_OPENVINO_CPU_CONFIG`, `GGML_OPENVINO_REQUANT_KQUANT`, `GGML_OPENVINO_EXACT_ZERO_POINT`, `GGML_OPENVINO_NATIVE_SOFTPLUS`, `GGML_OPENVINO_MANUAL_GQA_ATTN`
- `GGML_OPENVINO_GPU_CONFIG`, `GGML_OPENVINO_CPU_CONFIG`, `GGML_OPENVINO_REQUANT_KQUANT`, `GGML_OPENVINO_EXACT_ZERO_POINT`, `GGML_OPENVINO_MANUAL_GQA_ATTN`
- `GGML_OPENVINO_STATEFUL_EXECUTION`, `GGML_OPENVINO_DISABLE_KV_STATE_RELAYOUT`, `GGML_OPENVINO_KV_SCATTER_ELEMENTS`
- `GGML_OPENVINO_GDN_NATIVE_STATE`, `GGML_OPENVINO_GDN_DECOMPOSE`, `GGML_OPENVINO_GDN_DECOMPOSE_CHUNK`
- `GGML_OPENVINO_REDUCE_COMPILE_MEM`, `GGML_OPENVINO_MEMORY_OPTIMIZE`, `GGML_OPENVINO_DISABLE_SHAPE_FROM_MASK`
Expand Down
1 change: 0 additions & 1 deletion ggml/src/ggml-openvino/ggml-openvino-extra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ constexpr env_var env_vars[] = {
{"GGML_OPENVINO_LOG_SUPPORTS_OP", env_type::INT},
{"GGML_OPENVINO_DIAG_GRAPH_IO", env_type::BOOL},
{"GGML_OPENVINO_LOG_SWA_LAYERS", env_type::BOOL},
{"GGML_OPENVINO_NATIVE_SOFTPLUS", env_type::BOOL},
{"GGML_OPENVINO_DISABLE_REMOTE_OUTPUTS", env_type::BOOL},
{"GGML_OPENVINO_DISABLE_KV_STATE_RELAYOUT", env_type::BOOL},
{"GGML_OPENVINO_NPU_FAST_MASK", env_type::BOOL},
Expand Down
1 change: 0 additions & 1 deletion ggml/src/ggml-openvino/model-cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ static const char * cache_settings[] = {
"GGML_OPENVINO_GPU_CONFIG",
"GGML_OPENVINO_CPU_CONFIG",
"GGML_OPENVINO_REQUANT_KQUANT",
"GGML_OPENVINO_NATIVE_SOFTPLUS",
// GGML_OPENVINO_KV_SLICE only changes dynamic runtime bindings. Dynamic
// attention graphs accept either shape and share the same compiled blob.
"GGML_OPENVINO_GDN_NATIVE_STATE",
Expand Down
34 changes: 0 additions & 34 deletions ggml/src/ggml-openvino/openvino/op/unary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <openvino/op/round.hpp>
#include <openvino/op/select.hpp>
#include <openvino/op/sigmoid.hpp>
#include <openvino/op/softplus.hpp>
#include <openvino/op/subtract.hpp>

namespace ov {
Expand Down Expand Up @@ -142,39 +141,6 @@ OutputVector translate_unary_expm1(const NodeContext & context) {
return rename_outputs_with_suffix({res}, context.get_name());
}

OutputVector translate_unary_softplus(const NodeContext & context) {
num_inputs_check(context, 1, 1);

if (ggml_openvino_getenv_int("GGML_OPENVINO_NATIVE_SOFTPLUS") != 0) {
return translate_1to1_match_1_input<ov::op::v4::SoftPlus>(context);
}

auto input = process_view_input_new(context, 0);
const auto element_type = input.get_element_type();
auto one = ov::op::v0::Constant::create(element_type, ov::Shape{}, {1.0f});

auto positive = std::make_shared<ov::op::v0::Relu>(input);
auto abs = std::make_shared<ov::op::v0::Abs>(input);
auto neg_abs = std::make_shared<ov::op::v0::Negative>(abs);
auto y = std::make_shared<ov::op::v0::Exp>(neg_abs);
// log1p(y) for y in (0, 1]. log(1 + y) loses a small y to rounding in 1 + y (all of it below x = -16 in f32),
// so y < 0.01 takes the series y - y^2/2 + y^3/3 - y^4/4, whose relative error there is below 2e-9.
auto c = [&](float v) {
return ov::op::v0::Constant::create(element_type, ov::Shape{}, {v});
};
std::shared_ptr<ov::Node> series = std::make_shared<ov::op::v1::Multiply>(y, c(0.25f));
series = std::make_shared<ov::op::v1::Subtract>(c(1.0f / 3), series);
series = std::make_shared<ov::op::v1::Subtract>(c(0.5f), std::make_shared<ov::op::v1::Multiply>(y, series));
series = std::make_shared<ov::op::v1::Subtract>(one, std::make_shared<ov::op::v1::Multiply>(y, series));
series = std::make_shared<ov::op::v1::Multiply>(y, series);
auto log_direct = std::make_shared<ov::op::v0::Log>(std::make_shared<ov::op::v1::Add>(one, y));
auto small = std::make_shared<ov::op::v1::Less>(y, c(0.01f));
auto log_term = std::make_shared<ov::op::v1::Select>(small, series, log_direct);
auto res = std::make_shared<ov::op::v1::Add>(positive, log_term);

return rename_outputs_with_suffix({res}, context.get_name());
}

} // namespace op
} // namespace ggml
} // namespace frontend
Expand Down
2 changes: 1 addition & 1 deletion ggml/src/ggml-openvino/openvino/op_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ std::unordered_map<std::string, CreatorFunction> get_supported_ops() {
{"GGML_UNARY_OP_EXPM1", op::translate_unary_expm1 },
{"GGML_UNARY_OP_SIGMOID", op::translate_1to1_match_1_input<v0::Sigmoid> },
{"GGML_UNARY_OP_SILU", op::translate_1to1_match_1_input<v4::Swish> },
{"GGML_UNARY_OP_SOFTPLUS", op::translate_unary_softplus },
{"GGML_UNARY_OP_SOFTPLUS", op::translate_1to1_match_1_input<v4::SoftPlus> },
{"GGML_UNARY_OP_TANH", op::translate_1to1_match_1_input<v0::Tanh> },
{"GGML_UNARY_OP_EXP", op::translate_1to1_match_1_input<v0::Exp> },
{"GGML_UNARY_OP_NEG", op::translate_1to1_match_1_input<v0::Negative> },
Expand Down
1 change: 0 additions & 1 deletion ggml/src/ggml-openvino/openvino/op_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ GGML_OP_CONVERTER(translate_sqr);
GGML_OP_CONVERTER(translate_rope);
GGML_OP_CONVERTER(translate_scale);
GGML_OP_CONVERTER(translate_sqrt);
GGML_OP_CONVERTER(translate_unary_softplus);
GGML_OP_CONVERTER(translate_soft_max);
GGML_OP_CONVERTER(translate_transpose);
GGML_OP_CONVERTER(translate_view);
Expand Down
Loading