Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ ovms_cc_library(
srcs = ["cli_parser.cpp"],
deps = [
"@com_github_jarro2783_cxxopts//:cxxopts",
"@com_github_tencent_rapidjson//:rapidjson",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depend on src/port/rapidjson*

"libovms_server_settings",
"libovms_version",
"//src/filesystem:libovmsfilesystem",
Expand All @@ -373,6 +374,8 @@ ovms_cc_library(
"//src/graph_export:t2s_graph_cli_parser",
"//src/graph_export:s2t_graph_cli_parser",
"//src/graph_export:image_generation_graph_cli_parser",
"//src/pull_module:curl_downloader",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we do need to add those includes here? We are spilling dependencies.

"//src/pull_module:hf_env_vars",
],
visibility = ["//visibility:public",],
)
Expand Down Expand Up @@ -2158,8 +2161,6 @@ cc_binary(
linkstatic = True,
)



cc_binary(
name = "optimum-cli",
srcs = [
Expand Down Expand Up @@ -2273,6 +2274,7 @@ cc_test(
"test/tensor_conversion_test.cpp",
"test/tensorinfo_test.cpp",
"test/tensorutils_test.cpp",
"test/task_determine_test.cpp",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add as separate test library target and make those new config files as data field there.

"test/test_http_utils.hpp",
"test/tfs_rest_parser_binary_inputs_test.cpp",
"test/tfs_rest_parser_column_test.cpp",
Expand Down Expand Up @@ -2467,7 +2469,7 @@ cc_test(
"//src:libcustom_node_image_transformation.so",
"//src:libcustom_node_add_one.so",
"//src:libcustom_node_horizontal_ocr.so",
],
] + glob(["test/models_config_json/**"]),
deps = [
"optimum-cli",
"//src:ovms_lib",
Expand Down
360 changes: 349 additions & 11 deletions src/cli_parser.cpp

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/cli_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#pragma once

#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <variant>
Expand All @@ -38,13 +39,16 @@ class CLIParser {
std::unique_ptr<cxxopts::Options> options;
std::unique_ptr<cxxopts::ParseResult> result;
std::variant<GraphCLIParser, RerankGraphCLIParser, EmbeddingsGraphCLIParser, ImageGenerationGraphCLIParser, TextToSpeechGraphCLIParser, SpeechToTextGraphCLIParser> graphOptionsParser;
std::optional<std::string> inferredTaskParameter;

public:
CLIParser() = default;
static std::string determineDefaultTaskParameter(const std::optional<std::string>& modelPath, const std::optional<std::string>& sourceModel, const std::optional<std::string>& modelRepositoryPath);
std::variant<bool, std::pair<int, std::string>> parse(int argc, char** argv);
void prepare(ServerSettingsImpl*, ModelsSettingsImpl*);

protected:
std::string getEffectiveTaskParameter() const;
void prepareServer(ServerSettingsImpl& serverSettings);
void prepareModel(ModelsSettingsImpl& modelsSettings, HFSettingsImpl& hfSettings);
void prepareGraph(ServerSettingsImpl& serverSettings, HFSettingsImpl& hfSettings, const std::string& modelName);
Expand Down
6 changes: 3 additions & 3 deletions src/llm/http_llm_calculator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ class HttpLLMCalculator : public CalculatorBase {

absl::Status Close(CalculatorContext* cc) final {
OVMS_PROFILE_FUNCTION();
SPDLOG_LOGGER_DEBUG(llm_calculator_logger, "LLMCalculator [Node: {} ] Close", cc->NodeName());
SPDLOG_LOGGER_TRACE(llm_calculator_logger, "LLMCalculator [Node: {} ] Close", cc->NodeName());
return absl::OkStatus();
}

absl::Status Open(CalculatorContext* cc) final {
OVMS_PROFILE_FUNCTION();
SPDLOG_LOGGER_DEBUG(llm_calculator_logger, "LLMCalculator [Node: {}] Open start", cc->NodeName());
SPDLOG_LOGGER_TRACE(llm_calculator_logger, "LLMCalculator [Node: {}] Open start", cc->NodeName());
ovms::GenAiServableMap servableMap = cc->InputSidePackets().Tag(LLM_SESSION_SIDE_PACKET_TAG).Get<ovms::GenAiServableMap>();
auto it = servableMap.find(cc->NodeName());
RET_CHECK(it != servableMap.end()) << "Could not find initialized LLM node named: " << cc->NodeName();
Expand All @@ -90,7 +90,7 @@ class HttpLLMCalculator : public CalculatorBase {
if (!this->executionContextHolder) {
this->executionContext = servable->createExecutionContext();
}
SPDLOG_LOGGER_DEBUG(llm_calculator_logger, "LLMCalculator [Node: {}] Open end", cc->NodeName());
SPDLOG_LOGGER_TRACE(llm_calculator_logger, "LLMCalculator [Node: {}] Open end", cc->NodeName());
return absl::OkStatus();
}
absl::Status handleGenerationError(CalculatorContext* cc, const char* errorMessage) {
Expand Down
8 changes: 8 additions & 0 deletions src/pull_module/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ ovms_cc_library(
visibility = ["//visibility:public"],
)

ovms_cc_library(
name = "hf_env_vars",
hdrs = ["hf_env_vars.hpp"],
deps = [],
visibility = ["//visibility:public"],
)

ovms_cc_library(
name = "gguf_downloader",
srcs = ["gguf_downloader.cpp"],
Expand Down Expand Up @@ -109,6 +116,7 @@ ovms_cc_library(
srcs = ["hf_pull_model_module.cpp"],
hdrs = ["hf_pull_model_module.hpp"],
deps = [
":hf_env_vars",
":curl_downloader",
":libgit2",
"gguf_downloader",
Expand Down
22 changes: 22 additions & 0 deletions src/pull_module/hf_env_vars.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//****************************************************************************
// Copyright 2025 Intel Corporation

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2026

//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//****************************************************************************
#pragma once

namespace ovms {
inline constexpr const char* HF_TOKEN_ENV_VAR = "HF_TOKEN";
inline constexpr const char* HF_ENDPOINT_ENV_VAR = "HF_ENDPOINT";
inline constexpr const char* DEFAULT_HF_ENDPOINT = "https://huggingface.co";
} // namespace ovms
5 changes: 3 additions & 2 deletions src/pull_module/hf_pull_model_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "optimum_export.hpp"
#include "curl_downloader.hpp"
#include "gguf_downloader.hpp"
#include "hf_env_vars.hpp"
#include "../graph_export/graph_export.hpp"
#include "../logging.hpp"
#include "../module_names.hpp"
Expand Down Expand Up @@ -293,11 +294,11 @@ const std::string HfPullModelModule::GetProxy() const {
}

const std::string HfPullModelModule::GetHfToken() const {
return getEnvReturnOrDefaultIfNotSet("HF_TOKEN");
return getEnvReturnOrDefaultIfNotSet(HF_TOKEN_ENV_VAR);
}

const std::string HfPullModelModule::GetHfEndpoint() const {
std::string hfEndpoint = getEnvReturnOrDefaultIfNotSet("HF_ENDPOINT", "https://huggingface.co");
std::string hfEndpoint = getEnvReturnOrDefaultIfNotSet(HF_ENDPOINT_ENV_VAR, DEFAULT_HF_ENDPOINT);
if (!endsWith(hfEndpoint, "/")) {
hfEndpoint.append("/");
}
Expand Down
9 changes: 9 additions & 0 deletions src/test/models_config_json/Kokoro/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"return_dict": true,
"output_hidden_states": false,
"dtype": null,
"chunk_size_feed_forward": 0,
"is_encoder_decoder": false,
"architectures": null,
"n_mels": 80
}
8 changes: 8 additions & 0 deletions src/test/models_config_json/NullArch/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"return_dict": true,
"output_hidden_states": false,
"dtype": null,
"chunk_size_feed_forward": 0,
"is_encoder_decoder": false,
"architectures": null
}
4 changes: 4 additions & 0 deletions src/test/models_config_json/Qwen3-8B/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"architectures": ["Qwen3ForCausalLM"],
"model_type": "qwen3"
}
4 changes: 4 additions & 0 deletions src/test/models_config_json/Qwen3-Embedding-0.6B/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"architectures": ["Qwen3ForCausalLM"],
"model_type": "qwen3"
}
4 changes: 4 additions & 0 deletions src/test/models_config_json/Qwen3-Reranker-0.6B/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"architectures": ["Qwen3ForCausalLM"],
"model_type": "qwen3"
}
5 changes: 5 additions & 0 deletions src/test/models_config_json/bge/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"architectures": ["BertModel"],
"model_type": "bert",
"hidden_size": 768
}
4 changes: 4 additions & 0 deletions src/test/models_config_json/bge_reranker/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"architectures": ["XLMRobertaForSequenceClassification"],
"model_type": "xlm-roberta"
}
6 changes: 6 additions & 0 deletions src/test/models_config_json/cross_encoder/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"architectures": ["BertForSequenceClassification"],
"model_type": "bert",
"hidden_size": 768,
"num_labels": 2
}
5 changes: 5 additions & 0 deletions src/test/models_config_json/flux/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"architectures": ["FluxTransformer2DModel"],
"model_type": "flux",
"hidden_size": 3072
}
5 changes: 5 additions & 0 deletions src/test/models_config_json/flux_pipeline/model_index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"_class_name": "FluxPipeline",
"_diffusers_version": "0.34.0",
"_name_or_path": "black-forest-labs/FLUX.1-dev"
}
4 changes: 4 additions & 0 deletions src/test/models_config_json/gemma4/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"architectures": ["Gemma4ForConditionalGeneration"],
"model_type": "gemma4"
}
5 changes: 5 additions & 0 deletions src/test/models_config_json/invalid_architecture/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"architectures": [
"InvalidArchitecture"
]
}
4 changes: 4 additions & 0 deletions src/test/models_config_json/lfm/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"architectures": ["Lfm2MoeForCausalLM"],
"model_type": "lfm2_moe"
}
6 changes: 6 additions & 0 deletions src/test/models_config_json/llama/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"architectures": ["LlamaForCausalLM"],
"model_type": "llama",
"hidden_size": 4096,
"num_hidden_layers": 32
}
4 changes: 4 additions & 0 deletions src/test/models_config_json/no_architectures/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"model_type": "bert",
"hidden_size": 768
}
5 changes: 5 additions & 0 deletions src/test/models_config_json/parlertts/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"architectures": ["ParlerTTSForConditionalGeneration"],
"model_type": "parlertts",
"hidden_size": 768
}
5 changes: 5 additions & 0 deletions src/test/models_config_json/phi3/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"architectures": ["Phi3ForCausalLM"],
"model_type": "phi3",
"hidden_size": 3072
}
5 changes: 5 additions & 0 deletions src/test/models_config_json/qwen2_embedding/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"architectures": ["Qwen2Model"],
"model_type": "qwen2",
"hidden_size": 1024
}
6 changes: 6 additions & 0 deletions src/test/models_config_json/qwen2_rerank/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"architectures": ["Qwen2ForSequenceClassification"],
"model_type": "qwen2",
"hidden_size": 1024,
"num_labels": 2
}
5 changes: 5 additions & 0 deletions src/test/models_config_json/qwen3/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"architectures": ["Qwen3ForCausalLM"],
"model_type": "qwen3",
"hidden_size": 1024
}
5 changes: 5 additions & 0 deletions src/test/models_config_json/qwen3_6/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"architectures": [
"Qwen3_5MoeForConditionalGeneration"
]
}
6 changes: 6 additions & 0 deletions src/test/models_config_json/qwen3_asr/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"architectures": ["Qwen3ASRForConditionalGeneration"],
"model_type": "qwen3_asr",
"return_dict": true,
"output_hidden_states": false
}
4 changes: 4 additions & 0 deletions src/test/models_config_json/qwen3_multi_arch/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"architectures": ["Qwen3ASRForConditionalGeneration", "Qwen3ConditionalGeneration"],
"model_type": "qwen3_multi_arch"
}
5 changes: 5 additions & 0 deletions src/test/models_config_json/sdxl/model_index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"_class_name": "StableDiffusionXLPipeline",
"_diffusers_version": "0.34.0",
"_name_or_path": "stabilityai/stable-diffusion-xl-base-1.0"
}
5 changes: 5 additions & 0 deletions src/test/models_config_json/seamlessm4t/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"architectures": ["SeamlessM4TModel"],
"model_type": "seamless_m4t",
"hidden_size": 512
}
5 changes: 5 additions & 0 deletions src/test/models_config_json/speecht5/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"architectures": ["SpeechT5ForTextToSpeech"],
"model_type": "speecht5",
"hidden_size": 256
}
5 changes: 5 additions & 0 deletions src/test/models_config_json/stable_diffusion/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"architectures": ["UNet2DConditionModel"],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add these files to data field in unit test build target. If you dont do that, the unit tests will not re-run once this file change.

Example: https://github.com/openvinotoolkit/model_server/blob/main/src/BUILD#L2337-L2364

"model_type": "unet",
"in_channels": 9
}
5 changes: 5 additions & 0 deletions src/test/models_config_json/t5_encoder/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"architectures": ["T5EncoderModel"],
"model_type": "t5",
"d_model": 512
}
4 changes: 4 additions & 0 deletions src/test/models_config_json/trinity/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"architectures": ["AfmoeForCausalLM"],
"model_type": "afmoe"
}
5 changes: 5 additions & 0 deletions src/test/models_config_json/whisper/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"architectures": ["WhisperForConditionalGeneration"],
"model_type": "whisper",
"hidden_size": 512
}
6 changes: 6 additions & 0 deletions src/test/models_config_json/xlm_roberta/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"architectures": ["XLMRobertaForSequenceClassification"],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see its possible to have more than 1 architecture (its a list). How would OVMS behave? Can you add test for that behavior?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory this is possible but rarely if ever happens. Added tests to cover it. First architecture will be used.

"model_type": "xlm-roberta",
"hidden_size": 768,
"num_labels": 2
}
Loading