-
Notifications
You must be signed in to change notification settings - Fork 251
configuring genai model deployment with model readonly filesystem #4139
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
base: main
Are you sure you want to change the base?
Changes from all commits
4e9850c
933e65a
84f9cbb
2fc1646
02846f3
8167677
eafe795
fdd58ed
d00e994
5916e53
e34585a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,7 @@ | |
|
|
||
| #include "../execution_context.hpp" | ||
| #include "src/filesystem/filesystem.hpp" | ||
| #include "src/graph_export/graph_export.hpp" | ||
| #include "src/metrics/metric.hpp" | ||
| #include "../model_metric_reporter.hpp" | ||
| #include "../ov_utils.hpp" | ||
|
|
@@ -60,6 +61,13 @@ const tensor_map_t MediapipeGraphDefinition::getOutputsInfo() const { | |
| } | ||
|
|
||
| Status MediapipeGraphDefinition::validateForConfigFileExistence() { | ||
| if (GraphExport::hasInMemoryGraphContent()) { | ||
| const std::string& content = GraphExport::getInMemoryGraphContent(); | ||
| this->chosenConfig = content; | ||
| this->mgconfig.setCurrentGraphPbTxtMD5(ovms::FileSystem::getStringMD5(content)); | ||
| SPDLOG_LOGGER_DEBUG(modelmanager_logger, "Using in-memory graph content for mediapipe graph definition: {}", this->getName()); | ||
| return StatusCode::OK; | ||
| } | ||
|
Comment on lines
63
to
+70
|
||
| std::ifstream ifs(this->mgconfig.getGraphPath()); | ||
| if (!ifs.is_open()) { | ||
| SPDLOG_LOGGER_ERROR(modelmanager_logger, "Failed to open mediapipe graph definition: {}, file: {}\n", this->getName(), this->mgconfig.getGraphPath()); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,6 +58,7 @@ | |
| #include "dags/pipelinedefinition.hpp" | ||
| #include "filesystem/filesystem.hpp" | ||
| #include "filesystem/filesystemfactory.hpp" | ||
| #include "graph_export/graph_export.hpp" | ||
| #include "logging.hpp" | ||
| #if (MEDIAPIPE_DISABLE == 0) | ||
| #include "mediapipe_internal/mediapipefactory.hpp" | ||
|
|
@@ -229,7 +230,8 @@ Status ModelManager::startFromConfig() { | |
|
|
||
| std::vector<MediapipeGraphConfig> mediapipesInConfigFile; | ||
| std::ifstream ifs(mpConfig.getGraphPath()); | ||
| if (ifs.is_open()) { | ||
| bool graphAvailable = ifs.is_open() || GraphExport::hasInMemoryGraphContent(); | ||
| if (graphAvailable) { | ||
| // Single model with graph.pbtxt, check if user passed model unsupported model parameters in cmd arguments | ||
|
Comment on lines
232
to
235
|
||
| status = ModelManager::validateUserSettingsInSingleModelCliGraphStart(config.getModelSettings()); | ||
| if (!status.ok()) | ||
|
|
@@ -473,10 +475,13 @@ bool ModelManager::CheckStartFromGraph(std::string inputPath, MediapipeGraphConf | |
| if (ifs.is_open()) { | ||
| SPDLOG_LOGGER_DEBUG(modelmanager_logger, "Graph: {} path: {} exists", mpConfig.getGraphName(), mpConfig.getGraphPath()); | ||
| return true; | ||
| } else { | ||
| SPDLOG_LOGGER_DEBUG(modelmanager_logger, "Graph: {} path: {} does not exist", mpConfig.getGraphName(), mpConfig.getGraphPath()); | ||
| return false; | ||
| } | ||
| if (GraphExport::hasInMemoryGraphContent()) { | ||
| SPDLOG_LOGGER_DEBUG(modelmanager_logger, "Graph: {} using in-memory graph content", mpConfig.getGraphName()); | ||
| return true; | ||
| } | ||
| SPDLOG_LOGGER_DEBUG(modelmanager_logger, "Graph: {} path: {} does not exist", mpConfig.getGraphName(), mpConfig.getGraphPath()); | ||
| return false; | ||
| } | ||
|
|
||
| Status ModelManager::validateUserSettingsInSingleModelCliGraphStart(const ModelsSettingsImpl& modelsSettings) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,6 +53,7 @@ | |
| #include "capi_frontend/server_settings.hpp" | ||
| #include "cli_parser.hpp" | ||
| #include "config.hpp" | ||
| #include "graph_export/graph_export.hpp" | ||
| #include "grpcservermodule.hpp" | ||
| #include "http_server.hpp" | ||
| #include "httpservermodule.hpp" | ||
|
|
@@ -378,16 +379,29 @@ Status Server::startModules(ovms::Config& config) { | |
| return status; | ||
| } | ||
| if (config.getServerSettings().serverMode == HF_PULL_MODE || config.getServerSettings().serverMode == HF_PULL_AND_START_MODE) { | ||
| INSERT_MODULE(HF_MODEL_PULL_MODULE_NAME, it); | ||
| START_MODULE(it); | ||
| if (!status.ok()) { | ||
| return status; | ||
| bool needsHfPull = !config.getServerSettings().hfSettings.sourceModel.empty(); | ||
| if (needsHfPull) { | ||
| INSERT_MODULE(HF_MODEL_PULL_MODULE_NAME, it); | ||
| START_MODULE(it); | ||
| if (!status.ok()) { | ||
| return status; | ||
| } | ||
| auto hfModule = dynamic_cast<const HfPullModelModule*>(it->second.get()); | ||
| status = hfModule->clone(); | ||
| // Return from modules only in --pull mode or error, otherwise start the rest of modules | ||
| if (config.getServerSettings().serverMode == HF_PULL_MODE || !status.ok()) | ||
| return status; | ||
| } else { | ||
| // --task with --model_path: create graph in memory without HF download | ||
| GraphExport graphExporter; | ||
| const auto& hfSettings = config.getServerSettings().hfSettings; | ||
| status = graphExporter.createServableConfig(config.modelPath(), hfSettings, false); | ||
| if (!status.ok()) { | ||
| SPDLOG_ERROR("Failed to create in-memory graph config: {}", status.string()); | ||
| return status; | ||
| } | ||
| SPDLOG_INFO("Graph config created in memory from model_path: {}", config.modelPath()); | ||
| } | ||
|
Comment on lines
381
to
404
|
||
| auto hfModule = dynamic_cast<const HfPullModelModule*>(it->second.get()); | ||
| status = hfModule->clone(); | ||
| // Return from modules only in --pull mode or error, otherwise start the rest of modules | ||
| if (config.getServerSettings().serverMode == HF_PULL_MODE || !status.ok()) | ||
| return status; | ||
| } | ||
|
|
||
| #if (PYTHON_DISABLE == 0) | ||
|
|
||
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.
When writeToFile==false, s_inMemoryGraphContent is populated, but there is no corresponding clearing when writeToFile==true (or before generating a new graph). This means a previous in-memory graph can persist and later be picked up by GraphExport::hasInMemoryGraphContent(), causing unrelated runs/tests to load stale graph content instead of reading graph.pbtxt from disk. Clear the in-memory content whenever you generate/write a file-based graph (and/or at the start of each server startup) so the in-memory fallback cannot leak across runs.