Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

Python: Expose GQA Extension in Python bindings (#36054)

Dmitry Matveev342e0482b4d8
diff --git a/src/bindings/python/src/openvino/op/__init__.py b/src/bindings/python/src/openvino/op/__init__.py
index 215174f6213..01309ee48c5 100644
--- a/src/bindings/python/src/openvino/op/__init__.py
+++ b/src/bindings/python/src/openvino/op/__init__.py
@@ -11,6 +11,7 @@ Low level wrappers for the c++ api in ov::op.
from openvino._pyopenvino.op import Constant
from openvino._pyopenvino.op import assign
from openvino._pyopenvino.op import _PagedAttentionExtension
+from openvino._pyopenvino.op import _GroupQueryAttentionExtension
from openvino._pyopenvino.op import Parameter
from openvino._pyopenvino.op import if_op
from openvino._pyopenvino.op import loop
diff --git a/src/bindings/python/src/pyopenvino/graph/ops/internal/gqa_extension.cpp b/src/bindings/python/src/pyopenvino/graph/ops/internal/gqa_extension.cpp
new file mode 100644
index 00000000000..2141a1d1047
--- /dev/null
+++ b/src/bindings/python/src/pyopenvino/graph/ops/internal/gqa_extension.cpp
@@ -0,0 +1,23 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "pyopenvino/graph/ops/internal/gqa_extension.hpp"
+
+#include "openvino/core/op_extension.hpp"
+#include "openvino/op/group_query_attention.hpp"
+#include "openvino/op/op.hpp"
+#include "pyopenvino/core/common.hpp"
+
+namespace py = pybind11;
+
+void regclass_graph_op_GroupQueryAttention(py::module m) {
+ using ov::op::internal::GroupQueryAttention;
+
+ py::class_<ov::OpExtension<GroupQueryAttention>,
+ std::shared_ptr<ov::OpExtension<GroupQueryAttention>>,
+ ov::Extension>(m, "_GroupQueryAttentionExtension")
+ .def(py::init<>())
+ .doc() = "Extension that registers GroupQueryAttention for IR deserialization. "
+ "Pass an instance to core.add_extension() before reading an IR that contains this op.";
+}
diff --git a/src/bindings/python/src/pyopenvino/graph/ops/internal/gqa_extension.hpp b/src/bindings/python/src/pyopenvino/graph/ops/internal/gqa_extension.hpp
new file mode 100644
index 00000000000..fa209f85a3d
--- /dev/null
+++ b/src/bindings/python/src/pyopenvino/graph/ops/internal/gqa_extension.hpp
@@ -0,0 +1,11 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <pybind11/pybind11.h>
+
+namespace py = pybind11;
+
+void regclass_graph_op_GroupQueryAttention(py::module m);
diff --git a/src/bindings/python/src/pyopenvino/pyopenvino.cpp b/src/bindings/python/src/pyopenvino/pyopenvino.cpp
index 20879b46b51..cb614a72d6f 100644
--- a/src/bindings/python/src/pyopenvino/pyopenvino.cpp
+++ b/src/bindings/python/src/pyopenvino/pyopenvino.cpp
@@ -1,5 +1,6 @@
// Copyright (C) 2018-2026 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
+//
#include <pybind11/pybind11.h>
@@ -57,6 +58,7 @@
#include "pyopenvino/graph/ops/if.hpp"
#include "pyopenvino/graph/ops/loop.hpp"
#include "pyopenvino/graph/ops/paged_attention_extension.hpp"
+#include "pyopenvino/graph/ops/internal/gqa_extension.hpp"
#include "pyopenvino/graph/ops/parameter.hpp"
#include "pyopenvino/graph/ops/read_value.hpp"
#include "pyopenvino/graph/ops/result.hpp"
@@ -242,6 +244,7 @@ PYBIND11_MODULE(_pyopenvino, m) {
regclass_graph_op_Assign(m_op);
regclass_graph_op_Constant(m_op);
regclass_graph_op_PagedAttentionExtension(m_op);
+ regclass_graph_op_GroupQueryAttention(m_op);
regclass_graph_op_Parameter(m_op);
regclass_graph_op_ReadValue(m_op);
regclass_graph_op_Result(m_op);
diff --git a/src/bindings/python/tests/test_graph/test_gqa_extension.py b/src/bindings/python/tests/test_graph/test_gqa_extension.py
new file mode 100644
index 00000000000..2a039d58ad9
--- /dev/null
+++ b/src/bindings/python/tests/test_graph/test_gqa_extension.py
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+# Copyright (C) 2018-2026 Intel Corporation
+# SPDX-License-Identifier: Apache-2.0
+
+import pytest
+
+from openvino import Core, Extension
+from openvino.op import _GroupQueryAttentionExtension
+
+
+def test_gqa_extension_is_extension():
+ ext = _GroupQueryAttentionExtension()
+ assert isinstance(ext, Extension)
+
+
+def test_gqa_extension_add_to_core():
+ ext = _GroupQueryAttentionExtension()
+ core = Core()
+ core.add_extension(ext) # must not raise