Repository navigation
Update the llama.cpp to utilize OV frontend op translations - #342
preetha-intel wants to merge 6 commits into
Conversation
|
Thanks for contributing! Development happens on |
|
Could we stage this migration behind an opt-in CMake flag, keeping the existing translations as the default for now? This change replaces a substantial translation and fusion layer. Retaining the legacy path temporarily would let us compare correctness, model/device coverage, and performance, while providing an easy rollback. The GGUF frontend dependency should only be required when the new path is enabled. Once validation gives us confidence, we can switch the default and remove the legacy implementation in a follow-up PR. @ravi9, what do you think about taking this incremental approach? |
|
Sure, an incremental approach with the opt-in CMake flag sounds good. |
61a6258 to
df21ad8
Compare
be796d8 to
25e3135
Compare
|
hey @ravi9 and @cavusmustafa!! Thank you!! |
2545829 to
68abd50
Compare
a74e40b to
d97e07f
Compare
ba80126 to
45e6c13
Compare
6abf2ae to
75dbeb5
Compare
|
@cavusmustafa @ravi9 I have all my changes moved to a new directory and added the cmake option. Can you review and merge this. |
45e6c13 to
51fc2f9
Compare
75dbeb5 to
be120bd
Compare
Thanks for the update @preetha-intel. Looking into the changes, I see two main folders for both legacy frontend and gguf frontend. This could lead to have duplicate copies of same code structures and also I don't think this would be approved to be merged into llama.cpp upstream repo.
Instead, is it possible to convert this into a structure that they still share the same directory but differs in a few places below?
// frontend.h: exactly one implementation is compiled in
std::shared_ptr<GgmlOvDecoder> ov_frontend_make_decoder(...);
std::shared_ptr<ov::Model> ov_frontend_convert(const std::shared_ptr<GgmlOvDecoder> & decoder, bool naive);
ggml_openvino_op_support ov_frontend_supports_op(const ggml_tensor * op);
const char * ov_frontend_name(); |
fcf6088 to
2371fe4
Compare
Agreed on the single directory. The requested changes is still a work in progress. But I am in need of few clarifications. I refactored the current PR with a state that the legacy path will be replaced once GGUF frontend validation is done, so removing it later should be a simple rename and not another restructure. ** Regarding Index accessors** The GGUF frontend doesn't need the index-based accessors. Indices only exist in the legacy path because its translator reads the whole graph through one decoder and addresses nodes by position. The GGUF frontend gets one node-scoped decoder per node from As a result, the index lives only in Impact on other open PRs with the suggested structure
|
4c0d07b to
12b1ca5
Compare
Hi @preetha-intel, for 'node_idx', the proposed solution sounds good. Is there any blockers for it? For rename, that's right it could impact all other PRs as the folder name change. Maybe we can start with keeping the legacy folder name as "openvino" as a first step? Still this PR will be a big change and we cannot fully avoid impacting other PRs but this could minimize it. |
a546d03 to
c3358cb
Compare
|
I have updated the file structure as per the earlier comment to maintain the common code for both llama.cpp and ov frontend. But its highly conflicting with any pushes to the master as it touches the core llama.cpp files. |
27fb980 to
fe2c7b6
Compare
2fae454 to
5728d35
Compare
|
@preetha-intel: I've updated the contributing guide. Review it, and you could also share it with your AI agent so it helps with the PRs. Following are a few updates and comments based on AI agent review: Rebased Notes:
Fixed in 5728d35
Results (default OFF build, OpenVINO 2026.5, Panther Lake)
Remaining issues
Next steps
|
5b4342a to
a274a39
Compare
Add GGML_OPENVINO_GGUF_FRONTEND (default OFF). When ON, the backend is built from ggml/src/ggml-openvino-ggml-frontend/, where GgmlOvDecoder is a bridge to the OpenVINO GGUF frontend (openvino::frontend::gguf), which owns the op translations; the supports_op answer is a static op list kept in step with the frontend's op table. The in-tree translator in ggml/src/ggml-openvino/ stays untouched and remains the default, so changes to it keep applying. The frontend variant carries the earlier decoder/utils work: eltwise rank alignment, scale-before-MatMul on GPU/NPU to keep f16 in range, SWA/KV-state handling and the stateful mask rewrite. Also wire the new directory into CODEOWNERS, the labeler, the OpenVINO CI path filters and docs/backend/OPENVINO.md. Squashes the previous branch commits (legacy bridge removal, eltwise rank alignment, scale-before-MatMul, opt-in CMake option) after the rebase onto the rewritten dev_backend_openvino: their net effect on ggml-openvino/ was the CMake switch only.
The frontend directory duplicated ggml-quants, ggml-openvino-extra and model-cache from the in-tree backend. Keep a single copy in ggml-openvino/, compile it in both build modes, and leave forwarding headers in ggml-openvino-ggml-frontend/ so a fix to quantization, the model cache or device selection lands once. Add ggml_openvino_manual_gqa_attn_enabled() and ggml_openvino_scale_reorder_enabled() (GGML_OPENVINO_DISABLE_SCALE_REORDER) to the shared device config, and include the new switch in the model-cache key.
…supports_op rules
…dapters Fold ggml-openvino-ggml-frontend/ into ggml-openvino/. The backend is shared; frontend.h is the seam to the frontend that converts ggml graphs, and exactly one implementation is built: frontend-ggml/ (default) or frontend-gguf/ (GGML_OPENVINO_GGUF_FRONTEND=ON). GgmlOvDecoder keeps the shared graph analysis with no OV frontend base class. GgmlOvLegacyDecoder adds the index-based accessors, op_params and op_case for the in-tree translator; GgmlOvGgufDecoder adds get_attribute, describe_view, describe_kv_view and node-scoped visit_subgraph for the GGUF frontend.
5728d35 to
82d6df3
Compare


Add GGML decoder to support OV GGUF Frontend.
Overview
This PR adds an opt-in way for the OpenVINO backend to translate graphs with the OpenVINO GGUF frontend instead of the in-tree translator.
A new CMake option, GGML_OPENVINO_GGUF_FRONTEND, is OFF by default. When it is OFF, the build is exactly what dev_backend_openvino builds today. The in-tree translator sources, model-cache.cpp and ggml-openvino-extra.h are not modified, so open PRs against the in-tree translator are unaffected.
When it is ON, the backend is built from a new directory, ggml/src/ggml-openvino-ggml-frontend/. There, GgmlOvDecoder passes ggml graphs to the OpenVINO GGUF frontend (openvino::frontend::gguf), which owns the op translations. Configuration fails with an explicit error if the OpenVINO build does not provide that target.
Changes
New directory: ggml/src/ggml-openvino-ggml-frontend/
CMake changes
Openvino Frontend changes PR : openvinotoolkit/openvino#38769