-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[GPU] Skip state initializer subgraphs of cross attention for decoder stateful model #28164
Open
andrew-k-park
wants to merge
10
commits into
openvinotoolkit:master
Choose a base branch
from
andrew-k-park:andrew_skip_init_subgraph
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 all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
37fe1fb
Skip init subgraph
yeonbok 50e2962
tmp hard coding
yeonbok 4ba7622
Add flag to set _init_subgragh_executed
andrew-k-park 25fdd1a
Implementations based on updated design
andrew-k-park 3c5a974
Clean up code
andrew-k-park 70ba5f0
model cache support
andrew-k-park 97ade83
add test for mark_state_init_subgraphs opt pass
andrew-k-park 7f54dec
Fix failed test cases for variable_test_common
andrew-k-park 2e87a91
Apply comments
andrew-k-park d43ae11
Apply additional comments
andrew-k-park 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 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 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
60 changes: 60 additions & 0 deletions
60
src/plugins/intel_gpu/src/graph/graph_optimizer/mark_state_init_subgraphs.cpp
This file contains 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,60 @@ | ||
// Copyright (C) 2024 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "read_value_inst.h" | ||
#include "pass_manager.h" | ||
#include <queue> | ||
|
||
#include "intel_gpu/graph/program.hpp" | ||
|
||
using namespace cldnn; | ||
|
||
void mark_state_init_subgraphs::mark_init_subgraph(program& p, read_value_node& node) { | ||
const auto& variable_id = node.get_primitive()->variable_id; | ||
if (p.contains_state(variable_id)) | ||
return; | ||
|
||
std::queue<program_node*> q; | ||
q.push(&node); | ||
|
||
auto can_be_marked = [&](const program_node* dep_node) { | ||
if (p.has_state_initializers(variable_id, dep_node->id())) | ||
return false; | ||
|
||
for (auto& u : dep_node->get_users()) { | ||
if (u == &node) | ||
continue; | ||
if (p.has_state_initializers(variable_id, u->id())) | ||
continue; | ||
else | ||
return false; | ||
} | ||
GPU_DEBUG_TRACE_DETAIL << "marked " << dep_node->id() << " as node in a init_subgraph for " << node.id() << std::endl; | ||
return true; | ||
}; | ||
|
||
while (!q.empty()) { | ||
auto cur_size = q.size(); | ||
for (size_t i = 0; i < cur_size; ++i) { | ||
auto& cur_node = q.front(); | ||
q.pop(); | ||
for (auto& dep : cur_node->get_dependencies()) { | ||
if (can_be_marked(dep.first)) { | ||
p.set_state_initializers(variable_id, dep.first->id()); | ||
q.push(dep.first); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
void mark_state_init_subgraphs::run(program& p) { | ||
auto rit = p.get_processing_order().rbegin(); | ||
for (; rit != p.get_processing_order().rend(); rit++) { | ||
auto& node = *rit; | ||
if (node->is_type<read_value>()) { | ||
mark_init_subgraph(p, node->as<read_value>()); | ||
} | ||
} | ||
} |
This file contains 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 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 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 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 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't get why you add this
variable.set
here. Could you explain? My expectation is that set should be called by either assign or kv_cache node, not read_value.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For cross attention block of whisper decoder stateful model, originally read_value has assign as user node. But since LoRA adapter update(https://github.com/openvinotoolkit/openvino/pull/26951/files#diff-1ad765a71b01b7bc7785efa67e742843153f65236bba833b3baa9644d1d7c538R79) is merged, assign primitives are not created because the input is read_value. Therefore, in this case(when the user of read_value is not assign or kv_cache), there is no choice but to set the state directly in read_value