-
Notifications
You must be signed in to change notification settings - Fork 217
Validate create graph parameters #3290
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
Validate create graph parameters #3290
Conversation
8c9921f
to
1b2c917
Compare
@@ -92,6 +92,66 @@ bool Config::validate() { | |||
std::cerr << "Error: --task parameter not set." << std::endl; |
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.
Remove // TODO: CVS-1667
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.
Not removed.
std::cerr << "truncate: " << settings.truncate << " is not allowed. Supported values: true, false" << std::endl; | ||
return false; | ||
} | ||
} |
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.
Add check for source_model and model_repository_path if they are set and add unit tests.
src/config.cpp
Outdated
} | ||
|
||
if (serverSettings.hfSettings.sourceModel.rfind("OpenVINO/", 0) != 0) { | ||
std::cerr << "For now only OpenVINO models are supported"; |
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 think this should be generic check not only for text_generation. @dtrawins
885923a
to
42d22fb
Compare
src/config.cpp
Outdated
@@ -92,6 +92,67 @@ bool Config::validate() { | |||
std::cerr << "Error: --task parameter not set." << std::endl; | |||
return false; | |||
} | |||
#if (PYTHON_DISABLE == 1) |
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.
#if (PYTHON_DISABLE == 1) can be removed IMHO. We base optimum-cli functionality on external tools/python/environment not on internal ovms compilation flags. This check should be generic until I change it in optimum-cli enabling PR. @dtrawins
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 think this is a valid check. The version without python shouldn't pull models outside of OV organization. Otherwise the pulled model will not work. It might change in the future but for how it looks reasonable.
@rasapala do you have in mind replacing it with a logic for checking if optimum-cli is present in runtime? It would be also fine when we have this detection.
// clang-format on | ||
std::string fullPath = FileSystem::joinPath({directoryPath, "graph.pbtxt"}); | ||
return FileSystem::createFileOverwrite(fullPath, oss.str()); | ||
} | ||
|
||
static Status validateSubconfigSchema(const std::string& subconfig, const std::string& type) { | ||
rapidjson::Document subconfigJson; | ||
rapidjson::ParseResult parseResult = subconfigJson.Parse(subconfig.c_str()); |
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 am for parsing subconfig and mediapipe graph once it is created. @dtrawins want to remove it. Lets decide now.
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.
@rasapala subconfig will not be used then new embeddings and rerank calculators are merged.
src/graph_export/graph_export.cpp
Outdated
::mediapipe::CalculatorGraphConfig config; | ||
bool success = ::google::protobuf::TextFormat::ParseFromString(oss.str(), &config); | ||
if (!success) { | ||
SPDLOG_ERROR("Created graph config couldn't be parsed - some parameters values are invalid."); |
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.
Created graph config couldn't be parsed - check used task parameters values.
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 have mixed feelings if we should include this check in the graph export. It will be checked in the model initialization.
Do we know which parameters should cause such error? How is printed out? The log format might look strange for the CLI interface.
return StatusCode::JSON_INVALID; | ||
} | ||
if (validateJsonAgainstSchema(subconfigJson, MEDIAPIPE_SUBCONFIG_SCHEMA.c_str()) != StatusCode::OK) { | ||
SPDLOG_ERROR("Created {} subconfig file is not in valid configuration format", type); |
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.
Created graph config couldn't be parsed - check used task parameters values.
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.
@dtrawins please respond.
Please change std::string "true":"false" flags to bool in cxxopts and settingsImpl. |
src/config.cpp
Outdated
return false; | ||
} | ||
|
||
std::vector allowedTargeDevices = {"CPU", "GPU", "NPU", "HETERO"}; |
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.
std::vector allowedTargeDevices = {"CPU", "GPU", "NPU", "HETERO"}; | |
std::vector allowedTargetDevices = {"CPU", "GPU", "NPU", "HETERO"}; |
src/config.cpp
Outdated
return false; | ||
} | ||
|
||
std::vector allowedTargeDevices = {"CPU", "GPU", "NPU", "HETERO"}; |
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.
that might be to restrictive
// clang-format on | ||
std::string fullPath = FileSystem::joinPath({directoryPath, "graph.pbtxt"}); | ||
return createFile(fullPath, oss.str()); | ||
} | ||
|
||
static Status validateSubconfigSchema(const std::string& subconfig, const std::string& type) { |
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.
this is not needed
(char*)modelName.c_str(), | ||
(char*)"--model_repository_path", | ||
(char*)downloadPath.c_str(), | ||
(char*)"--enable_prefix_caching", |
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.
we should be bool value
(char*)modelName.c_str(), | ||
(char*)"--model_repository_path", | ||
(char*)downloadPath.c_str(), | ||
(char*)"--dynamic_split_fuse", |
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.
this could be bool flag
(char*)"--task", | ||
(char*)"embeddings", | ||
(char*)"--normalize", | ||
(char*)"INVALID", |
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.
this could be bool option
src/config.cpp
Outdated
@@ -92,6 +92,67 @@ bool Config::validate() { | |||
std::cerr << "Error: --task parameter not set." << std::endl; | |||
return false; | |||
} | |||
#if (PYTHON_DISABLE == 1) |
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 think this is a valid check. The version without python shouldn't pull models outside of OV organization. Otherwise the pulled model will not work. It might change in the future but for how it looks reasonable.
@rasapala do you have in mind replacing it with a logic for checking if optimum-cli is present in runtime? It would be also fine when we have this detection.
src/config.cpp
Outdated
return false; | ||
} | ||
|
||
if (std::find(allowedBoolValues.begin(), allowedBoolValues.end(), settings.truncate) == allowedBoolValues.end()) { |
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.
truncate option will be effective only when convert_tokenizer is used? Maybe this parameter should be dropped for now?
src/graph_export/graph_export.cpp
Outdated
::mediapipe::CalculatorGraphConfig config; | ||
bool success = ::google::protobuf::TextFormat::ParseFromString(oss.str(), &config); | ||
if (!success) { | ||
SPDLOG_ERROR("Created graph config couldn't be parsed - some parameters values are invalid."); |
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 have mixed feelings if we should include this check in the graph export. It will be checked in the model initialization.
Do we know which parameters should cause such error? How is printed out? The log format might look strange for the CLI interface.
// clang-format on | ||
std::string fullPath = FileSystem::joinPath({directoryPath, "graph.pbtxt"}); | ||
return FileSystem::createFileOverwrite(fullPath, oss.str()); | ||
} | ||
|
||
static Status validateSubconfigSchema(const std::string& subconfig, const std::string& type) { | ||
rapidjson::Document subconfigJson; | ||
rapidjson::ParseResult parseResult = subconfigJson.Parse(subconfig.c_str()); |
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.
@rasapala subconfig will not be used then new embeddings and rerank calculators are merged.
0dc248d
to
e63a6f2
Compare
src/test/ovmsconfig_test.cpp
Outdated
}; | ||
|
||
int arg_count = 6; | ||
EXPECT_EXIT(ovms::Config::instance().parse(arg_count, n_argv), ::testing::ExitedWithCode(OVMS_EX_USAGE), "or now OVMS version without python supports pulling OpenVINO models only"); |
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.
EXPECT_EXIT(ovms::Config::instance().parse(arg_count, n_argv), ::testing::ExitedWithCode(OVMS_EX_USAGE), "or now OVMS version without python supports pulling OpenVINO models only"); | |
EXPECT_EXIT(ovms::Config::instance().parse(arg_count, n_argv), ::testing::ExitedWithCode(OVMS_EX_USAGE), "Only OpenVINO models supported"); |
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.
1 change.
🛠 Summary
CVS-166727
🧪 Checklist
``