Skip to content

Commit

Permalink
delete debug prints
Browse files Browse the repository at this point in the history
  • Loading branch information
itikhono committed Dec 17, 2024
1 parent bc54ab8 commit 879ae7a
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ ov::pass::PositionIDsReplacer::PositionIDsReplacer(const Output<Node>& position_
auto add = pattern::wrap_type<v1::Add>({mul, position_embed});

ov::matcher_pass_callback callback = [=](ov::pass::pattern::Matcher& m) {
// std::cout << "XXXXXX PositionIDsReplacer" << std::endl;
const auto& pattern_map = m.get_pattern_value_map();
replace_node(pattern_map.at(position_ids_pattern).get_node_shared_ptr(), position_ids.get_node_shared_ptr());
return true;
Expand All @@ -62,7 +61,6 @@ ov::pass::PositionIDsReplacerQwen::PositionIDsReplacerQwen(const Output<Node>& p
const auto& pattern_map = m.get_pattern_value_map();
auto max_context_len = pattern_map.at(max_context_len_pattern).get_node_shared_ptr();
if (max_context_len->get_friendly_name() != "max_context_len") {
// std::cout << "XXXX return false;" << std::endl;
return false;
}

Expand All @@ -80,10 +78,6 @@ ov::pass::PositionIDsReplacerQwen::PositionIDsReplacerQwen(const Output<Node>& p
replace_node(slice_2, reshape);

gather->validate_and_infer_types();
/* std::cout << "slice_2 in(0) " << slice_2->input(0).get_partial_shape() << std::endl;
std::cout << "slice_2 out " << slice_2->output(0).get_partial_shape() << std::endl;
std::cout << "gather in " << gather->input(0).get_partial_shape() << std::endl;
std::cout << "gather out " << gather->output(0).get_partial_shape() << std::endl;*/
return true;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ ov::pass::PrevSequenceLengthPattern::PrevSequenceLengthPattern(std::shared_ptr<o
auto seq = pattern::wrap_type<v8::Gather>({kv_shape, pattern::any_input(), pattern::any_input()});

ov::matcher_pass_callback callback = [=](ov::pass::pattern::Matcher& m) {
std::cout << "XXXXXX PrevSequenceLengthPattern" << std::endl;
// TODO: Check that seq has axis that really takes sequence len but not any other dimension -- use symbolics or
// look at the constant input
// Detect the case by taking initialization expression for ReadValue and compare it with the second gather index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ ov::pass::TotalSequenceLengthPattern::TotalSequenceLengthPattern(
ov::matcher_pass_callback callback = [=](ov::pass::pattern::Matcher& m) {
// TODO: Check that seq has axis that really takes sequence len but not any other dimension --
// use symbolic infra or look at the constant input
std::cout << "XXXXXX TotalSequenceLengthPattern" << std::endl;
const auto& pattern_map = m.get_pattern_value_map();

auto concat = ov::as_type_ptr<v0::Concat>(pattern_map.at(kv_concat).get_node_shared_ptr());
Expand Down Expand Up @@ -109,24 +108,22 @@ ov::pass::TotalSequenceLengthPatternQwen::TotalSequenceLengthPatternQwen(
const std::shared_ptr<ov::op::v0::Parameter>& max_context_len) {
MATCHER_SCOPE(TotalSequenceLengthPatternQwen);

auto kv_past = pattern::wrap_type<v6::ReadValue>({pattern::any_input()});
auto kv_gather = pattern::wrap_type<v8::Gather>({kv_past, pattern::any_input(), pattern::any_input()});
auto kv_shape = pattern::wrap_type<v3::ShapeOf>({kv_gather});
auto seq_past = pattern::wrap_type<v8::Gather>({kv_shape, pattern::any_input(), pattern::any_input()});
auto prev_max_seq_len = pattern::wrap_type<v0::Parameter>();
auto opt_convert_1 = pattern::optional<v0::Convert>(prev_max_seq_len);
auto opt_reshape_1 = pattern::optional<v1::Reshape>({opt_convert_1, pattern::any_input()});

auto input_ids = pattern::wrap_type<v0::Parameter>();
auto unsqueeze = pattern::wrap_type<v0::Unsqueeze>({input_ids, pattern::any_input()});
auto optional_reshape = pattern::optional<v1::Reshape>({unsqueeze, pattern::any_input()});
auto optional_convert = pattern::optional<v0::Convert>(optional_reshape);
auto kv_shape_current = pattern::wrap_type<v3::ShapeOf>({optional_convert});
auto opt_reshape_2 = pattern::optional<v1::Reshape>({unsqueeze, pattern::any_input()});
auto opt_convert_2 = pattern::optional<v0::Convert>(opt_reshape_2);
auto kv_shape_current = pattern::wrap_type<v3::ShapeOf>({opt_convert_2});
auto seq_current = pattern::wrap_type<v8::Gather>({kv_shape_current, pattern::any_input(), pattern::any_input()});

auto pattern_total_seq = pattern::wrap_type<v1::Add>({seq_current, seq_past});
auto pattern_total_seq = pattern::wrap_type<v1::Add>({seq_current, opt_reshape_1});

ov::matcher_pass_callback callback = [=](ov::pass::pattern::Matcher& m) {
// TODO: Check that seq has axis that really takes sequence len but not any other dimension --
// use symbolic infra or look at the constant input
std::cout << "XXXXXX TotalSequenceLengthPatternQwen" << std::endl;
const auto& pattern_map = m.get_pattern_value_map();
auto total_seq = pattern_map.at(pattern_total_seq).get_node_shared_ptr();

Expand Down
4 changes: 2 additions & 2 deletions src/core/include/openvino/core/version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
* @brief Defines OpenVINO patch version
*/

#define OPENVINO_VERSION_MAJOR 2024
#define OPENVINO_VERSION_MINOR 5
#define OPENVINO_VERSION_MAJOR 2025
#define OPENVINO_VERSION_MINOR 0
#define OPENVINO_VERSION_PATCH 0

namespace ov {
Expand Down
4 changes: 2 additions & 2 deletions src/core/src/pass/sdpa_to_paged_attention.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "openvino/op/subtract.hpp"
#include "openvino/op/unsqueeze.hpp"
#include "openvino/pass/manager.hpp"
#include "openvino/pass/visualize_tree.hpp"
#include "transformations/sdpa_to_paged_attention/position_ids_replacer.hpp"
#include "transformations/sdpa_to_paged_attention/prev_sequence_length_pattern.hpp"
#include "transformations/sdpa_to_paged_attention/state_management_pattern.hpp"
Expand Down Expand Up @@ -128,9 +127,10 @@ bool ov::pass::SDPAToPagedAttention::run_on_model(const std::shared_ptr<ov::Mode
score_results,
m_use_block_indices_inputs,
m_use_score_outputs);
manager.register_pass<TotalSequenceLengthPatternQwen>(max_context_len);

manager.register_pass<PrevSequenceLengthPattern>(prev_max_seq_len, batch_dim);
manager.register_pass<TotalSequenceLengthPattern>(max_context_len);
manager.register_pass<TotalSequenceLengthPatternQwen>(max_context_len);
manager.register_pass<PositionIDsReplacer>(unsqueezed_position_ids->output(0));
manager.register_pass<PositionIDsReplacerQwen>(unsqueezed_position_ids->output(0));
manager.run_passes(model);
Expand Down
18 changes: 9 additions & 9 deletions src/core/src/pass/visualize_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ static void collect_symbol_print_values(const std::shared_ptr<ov::Model>& m,
bool ov::pass::VisualizeTree::run_on_model(const std::shared_ptr<ov::Model>& f) {
RUN_ON_MODEL_SCOPE(VisualizeTree);

static const bool ovasp = true;
static const bool ovasp = ov::util::getenv_bool("OV_VISUALIZE_APPLY_SYMBOLIC_PROPAGATION");
if (ovasp) {
std::cerr << "Warning: OV_VISUALIZE_APPLY_SYMBOLIC_PROPAGATION enabled. ov::pass::SymbolicPropagation will be "
"triggered"
Expand Down Expand Up @@ -561,11 +561,11 @@ std::string ov::pass::VisualizeTree::get_attributes(std::shared_ptr<Node> node)
std::stringstream label;
label << "label=\"" << get_node_name(node);

static const bool nvtos = true;
static const bool nvtot = true;
static const bool nvtio = true;
static const bool nvtrti = true;
static const bool ovpvl = true;
static const bool nvtos = ov::util::getenv_bool("OV_VISUALIZE_TREE_OUTPUT_SHAPES");
static const bool nvtot = ov::util::getenv_bool("OV_VISUALIZE_TREE_OUTPUT_TYPES");
static const bool nvtio = ov::util::getenv_bool("OV_VISUALIZE_TREE_IO");
static const bool nvtrti = ov::util::getenv_bool("OV_VISUALIZE_TREE_RUNTIME_INFO");
static const bool ovpvl = ov::util::getenv_bool("OV_VISUALIZE_PARTIAL_VALUES_AND_LABELS");

if (nvtos || nvtot || nvtio) {
if (nvtio) {
Expand Down Expand Up @@ -618,7 +618,7 @@ std::string ov::pass::VisualizeTree::get_attributes(std::shared_ptr<Node> node)
}

std::string ov::pass::VisualizeTree::get_node_name(std::shared_ptr<Node> node) {
static const bool nvtmn = true;
static const bool nvtmn = ov::util::getenv_bool("OV_VISUALIZE_TREE_MEMBERS_NAME");
std::string rc = (nvtmn ? std::string("friendly_name: ") : "") + node->get_friendly_name();
if (node->get_friendly_name() != node->get_name()) {
rc += "\\n" + (nvtmn ? std::string("name: ") : "") + node->get_name();
Expand All @@ -627,7 +627,7 @@ std::string ov::pass::VisualizeTree::get_node_name(std::shared_ptr<Node> node) {
rc += "\\n" + (nvtmn ? std::string("type_name: ") : "") + std::string(type_info.version_id) +
"::" + std::string(type_info.name);

static const bool nvttn = true;
static const bool nvttn = ov::util::getenv_bool("OV_VISUALIZE_TREE_TENSORS_NAME");
if (nvttn) {
auto to_string = [](const std::unordered_set<std::string>& names) {
std::stringstream ss;
Expand Down Expand Up @@ -665,7 +665,7 @@ std::string ov::pass::VisualizeTree::get_node_name(std::shared_ptr<Node> node) {
}
}

static const bool nvtrti = true;
static const bool nvtrti = ov::util::getenv_bool("OV_VISUALIZE_TREE_RUNTIME_INFO");
if (nvtrti) {
const auto& rt = node->get_rt_info();
if (!rt.empty()) {
Expand Down
4 changes: 0 additions & 4 deletions src/frontends/ir/src/frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
#include "input_model.hpp"
#include "openvino/core/any.hpp"
#include "openvino/core/so_extension.hpp"
#include "openvino/pass/sdpa_to_paged_attention.hpp"
#include "openvino/pass/visualize_tree.hpp"
#include "openvino/runtime/aligned_buffer.hpp"
#include "openvino/runtime/shared_buffer.hpp"
#include "openvino/util/file_util.hpp"
Expand Down Expand Up @@ -304,8 +302,6 @@ std::string FrontEnd::get_name() const {
void FrontEnd::normalize(const std::shared_ptr<ov::Model>& model) const {
ov::pass::Manager manager("Frontend:IR:normalize");
manager.register_pass<pass::ResolveNameCollisions>();
// manager.register_pass<pass::VisualizeTree>("baichuan_sdpa.svg");
// manager.register_pass<pass::SDPAToPagedAttention>();
manager.run_passes(model);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1775,26 +1775,15 @@ struct AttentionExecutor : public PagedAttentionExecutor {
auto H = q.size(1) / S;
auto h_each_group_len = 1;
if (Hk != H) {
h_each_group_len = H / Hk;
h_each_group_len = H / Hk;
}
auto B_seq = past_lens.size(0);
std::cout << "1 assert " << std::endl;
q.assert_dims({B_token, H * S});

std::cout << "b token" << B_token << std::endl;
std::cout << "Hk " << Hk << std::endl;
std::cout << "S " << S << std::endl;
std::cout << "SV " << SV << std::endl;
std::cout << "3 assert " << std::endl;
v.assert_dims({B_token, Hk * SV});
std::cout << "2 assert " << std::endl;
q.assert_dims({B_token, H * S});
k.assert_dims({B_token, Hk * S});

std::cout << "4 assert " << std::endl;
v.assert_dims({B_token, Hk * SV});
q = q.reshape({B_token, H, 1, S});
std::cout << "5 assert " << std::endl;
k = k.reshape({B_token, Hk, 1, S});
std::cout << "6 assert " << std::endl;
v = v.reshape({B_token, Hk, 1, SV});
if (k_cache.m_dt == ov::element::Type_t::u8) {
k_cache.assert_dims({0, Hk, block_size, S + sizeof(float) * 2}, true);
Expand All @@ -1803,20 +1792,15 @@ struct AttentionExecutor : public PagedAttentionExecutor {
k_cache.assert_dims({0, Hk, block_size, S}, true);
v_cache.assert_dims({k_cache.m_dims[0], Hk, block_size, SV});
}
std::cout << "7 assert " << std::endl;
past_lens.assert_dims({B_seq});
std::cout << "8 assert " << std::endl;
subsequence_begins.assert_dims({B_seq + 1});
std::cout << "9 assert " << std::endl;
block_indices.assert_dims({0}, true);
std::cout << "10 assert " << std::endl;
block_indices_begins.assert_dims({B_seq + 1});
if (scale == 0.0f)
scale = 1.0f / sqrt(S);
if (alibi_slopes) {
alibi_slopes.assert_dims({H});
}
std::cout << "11 assert " << std::endl;
output_emb.assert_dims({B_token, H * SV});
output_emb = output_emb.reshape({B_token, 1, H * SV});

Expand Down
7 changes: 1 addition & 6 deletions src/plugins/intel_cpu/src/nodes/scaled_attn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -973,11 +973,7 @@ struct ScaledDotProductAttention::AttentionExecutor : public ScaledDotProductAtt
SV = v_input.size(3);
L0 = present_key.size(2) - L1;
auto Hk = k_input.size(1);
std::cout << "B: " << B << std::endl;
std::cout << "Hk: " << Hk << std::endl;
std::cout << "S: " << S << std::endl;
std::cout << "L1: " << L1 << std::endl;
std::cout << "SV: " << SV << std::endl;

if (fuse_concat) {
k_input.assert_dims({B, Hk, L1, S});
v_input.assert_dims({B, Hk, L1, SV});
Expand Down Expand Up @@ -1199,7 +1195,6 @@ void ScaledDotProductAttention::createPrimitive() {
}

void ScaledDotProductAttention::execute(dnnl::stream strm) {
std::cout << "XXXXXXX SDPA 2" << std::endl;
auto orginSDPInputNumber = getOriginalInputsNumber() - (m_config.config.fuse_concat ? 3 : 0);
std::vector<MemoryPtr> inputs(orginSDPInputNumber);
auto output = getDstMemoryAtPort(0);
Expand Down

0 comments on commit 879ae7a

Please sign in to comment.