-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[GGUF FE] Stateful conversion, op-translator fixes and test infrastructure #37435
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
Open
mvafin
wants to merge
3
commits into
openvinotoolkit:master
Choose a base branch
from
mvafin:mvafin/gguf/frontend-groundwork
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/frontends/gguf/include/openvino/frontend/gguf/make_stateful.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| // Copyright (C) 2018-2026 Intel Corporation | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <memory> | ||
| #include <set> | ||
| #include <string> | ||
|
|
||
| #include "openvino/frontend/gguf/visibility.hpp" | ||
| #include "openvino/pass/pass.hpp" | ||
|
|
||
| namespace ov::frontend::gguf::pass { | ||
|
|
||
|
|
||
|
|
||
| class GGUF_FRONTEND_API MakeStateful : public ov::pass::ModelPass { | ||
| public: | ||
| OPENVINO_MODEL_PASS_RTTI("gguf::MakeStateful"); | ||
|
|
||
| /// \param skip_caches Friendly names of cache Parameters to leave stateless. A sliding-window | ||
| /// cache is evicted from the front rather than only appended to, so an append-grown | ||
| /// Variable would not reproduce it; such caches keep the stateless form. | ||
| /// \param append_axis Cache axis the new rows are appended along (the token axis). -1 infers it | ||
| /// as the cache Parameter's single dynamic axis, which is how a graph that does not | ||
| /// preallocate the cache states its token axis. Pass an explicit axis for a fully static | ||
| /// (preallocated) cache, where there is nothing to infer from. | ||
| /// \param beam_idx_name Name of the beam-reorder input, which this pass ADDS to the model (it | ||
| /// belongs to the state, so no decoder declares it; see the note above). The past cache is | ||
| /// gathered by it along the batch axis before the append Concat. With batch 1 / | ||
| /// beam_idx [0] that Gather is an identity, but emitting it is what lets CPU's | ||
| /// stateful_sdpa_fusion match, and it is what makes beam search work. A model that | ||
| /// already carries a Parameter of this name has it reused instead. | ||
| explicit MakeStateful(std::set<std::string> skip_caches = {}, | ||
| int64_t append_axis = -1, | ||
| std::string beam_idx_name = "beam_idx") | ||
| : m_skip_caches(std::move(skip_caches)), | ||
| m_append_axis(append_axis), | ||
| m_beam_idx_name(std::move(beam_idx_name)) {} | ||
|
|
||
| bool run_on_model(const std::shared_ptr<ov::Model>& model) override; | ||
|
|
||
| private: | ||
| std::set<std::string> m_skip_caches; | ||
| int64_t m_append_axis; | ||
| std::string m_beam_idx_name; | ||
| }; | ||
|
|
||
| } // namespace ov::frontend::gguf::pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.