-
Notifications
You must be signed in to change notification settings - Fork 218
Cmake builds libgit2 and --pull_hf_mode for ovms #3105
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
Conversation
src/server.cpp
Outdated
parser.prepare(&serverSettings, &modelsSettings); | ||
parser.prepare(&serverSettings, &modelsSettings, &hfDownloader); | ||
|
||
if (hfDownloader.pull_hf_model) { |
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.
Shouldn't this be responsibility of ServableModule?
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 we should separate the server mode and hf download mode.
…t/model_server into CVS-163308_libgt2
create_package.sh
Outdated
@@ -84,6 +84,11 @@ patchelf --debug --set-rpath '$ORIGIN' /ovms_release/lib/libopenvino.so | |||
patchelf --debug --set-rpath '$ORIGIN' /ovms_release/lib/lib*plugin.so | |||
if [ -f /ovms_release/lib/libopenvino_nvidia_gpu_plugin.so ] && [ "$BASE_OS" != "redhat" ]; then patchelf --replace-needed libcutensor.so.1 /usr/lib/x86_64-linux-gnu/libcutensor/11/libcutensor.so.1 /ovms_release/lib/libopenvino_nvidia_gpu_plugin.so ; fi | |||
|
|||
wget https://github.com/git-lfs/git-lfs/releases/download/v3.6.1/git-lfs-linux-arm64-v3.6.1.tar.gz |
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 duplicated with dockerfile
src/cli_parser.cpp
Outdated
@@ -126,6 +127,20 @@ void CLIParser::parse(int argc, char** argv) { | |||
"Absolute path to json configuration file", | |||
cxxopts::value<std::string>(), "CONFIG_PATH"); | |||
|
|||
options->add_options("pull hf model") | |||
("pull_hf_model", |
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.
pull would be simpler and in like with ollama
src/cli_parser.cpp
Outdated
"HF source model path", | ||
cxxopts::value<std::string>(), | ||
"HF_SOURCE") | ||
("repo_path", |
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.
what is repo path?
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.
destination path for git clone. Needed for testing in current status.
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 will be changed in implementation of other tasks.
src/hf_pull_model_module.hpp
Outdated
|
||
class HfPullModelModule : public Module { | ||
protected: | ||
mutable HFSettingsImpl hfSettings; |
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.
Why mutable?
src/hf_pull_model_module.cpp
Outdated
@@ -0,0 +1,78 @@ | |||
//*************************************************************************** | |||
// Copyright 2022 Intel Corporation |
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.
year
src/BUILD
Outdated
@@ -2712,6 +2715,7 @@ cc_test( | |||
"test/pipelinedefinitionstatus_test.cpp", | |||
"test/predict_validation_test.cpp", | |||
"test/prediction_service_test.cpp", | |||
"test/pull_hf_model_test.cpp", |
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.
yes but it will rebuild unnecessarily if any of ovms_tests dependency is changed
+ git_process_free(process); | ||
+ git__free(payload); | ||
+ return; | ||
+ | ||
+on_error: | ||
+ git_process_free(process); | ||
+ git__free(payload); | ||
+ return; | ||
+} |
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.
+ git_process_free(process); | |
+ git__free(payload); | |
+ return; | |
+ | |
+on_error: | |
+ git_process_free(process); | |
+ git__free(payload); | |
+ return; | |
+} | |
+on_exit: | |
+ git_process_free(process); | |
+ git__free(payload); | |
+ return; | |
+} |
You will need to rename on_error everywhere as well.
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.
on_error is standard label in this library.
+ git_process_free(process); | ||
+ git__free(payload); | ||
+ return; | ||
+ | ||
+on_error: | ||
+ git_process_free(process); | ||
+ git__free(payload); | ||
+ return; | ||
+} |
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.
+ git_process_free(process); | |
+ git__free(payload); | |
+ return; | |
+ | |
+on_error: | |
+ git_process_free(process); | |
+ git__free(payload); | |
+ return; | |
+} | |
+on_exit_: | |
+ git_process_free(process); | |
+ git__free(payload); | |
+ return; | |
+} |
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.
on_error: is the library convention.
src/config.cpp
Outdated
@@ -30,6 +30,7 @@ | |||
|
|||
#include "capi_frontend/server_settings.hpp" | |||
#include "cli_parser.hpp" | |||
#include "libgt2/libgt2.hpp" |
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
src/config.hpp
Outdated
@@ -48,7 +48,7 @@ class Config { | |||
ServerSettingsImpl serverSettings; | |||
|
|||
public: | |||
ServerSettingsImpl getServerSettings() { | |||
const ServerSettingsImpl getServerSettings() const { |
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.
Since we return const why no const&?
src/hf_pull_model_module.cpp
Outdated
return StatusCode::HF_FAILED_TO_INIT_LIBGIT2; | ||
} | ||
std::unique_ptr<HfDownloader> hfDownloader = std::make_unique<HfDownloader>(this->hfSettings.sourceModel, this->hfSettings.repoPath, this->hfSettings.pullHfModelMode); | ||
// TODO: Do we want to set timeout for this operation ? |
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.
Do we have ticket for that?
src/test/pull_hf_model_test.cpp
Outdated
std::unique_ptr<std::thread> t; | ||
|
||
void ServerPullHfModel(std::string& sourceModel, std::string& repoPath) { | ||
::SetUpServerForDownload(this->t, this->server, sourceModel, repoPath); |
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 don't need to start whole server to verify HfDownloader
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 can use the class functionality but I wanted to have integration tests -> end to end with small model.
This can be late reused to test final solution.
src/libgt2/libgt2.cpp
Outdated
return hfEndpoint; | ||
} | ||
|
||
std::string HfDownloader::GetRepoUrl(std::string& hfEndpoint) { |
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 tests for creating url based on various TOKEN, ENDPOINTS. Add negative tests
ci/build_test_OnCommit.groovy
Outdated
@@ -82,6 +82,7 @@ pipeline { | |||
when { expression { image_build_needed == "true" } } | |||
steps { | |||
sh "echo build --remote_cache=${env.OVMS_BAZEL_REMOTE_CACHE_URL} > .user.bazelrc" | |||
sh "echo test:linux --test_env https_proxy=${env.HTTPS_PROXY} > .user.bazelrc" |
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.
Wouldn't this overwrite effect of the command above? ">>" probably should be used
src/cli_parser.cpp
Outdated
@@ -26,6 +26,7 @@ | |||
#include <ntstatus.h> | |||
#endif | |||
#include "capi_frontend/server_settings.hpp" | |||
#include "libgt2/libgt2.hpp" |
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.
Bump
src/BUILD
Outdated
@@ -340,6 +340,7 @@ cc_library( | |||
"@com_github_jarro2783_cxxopts//:cxxopts", | |||
"libovms_server_settings", | |||
"libovms_version", | |||
"//src/libgt2:libgt2", |
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.
dependency leakage
src/BUILD
Outdated
@@ -549,6 +550,8 @@ cc_library( | |||
"get_model_metadata_impl.hpp", | |||
"global_sequences_viewer.hpp", | |||
"global_sequences_viewer.cpp", | |||
"hf_pull_model_module.hpp", |
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.
separate target
@@ -93,6 +93,10 @@ bool Config::check_hostname_or_ip(const std::string& input) { | |||
} | |||
|
|||
bool Config::validate() { | |||
// TODO: Add validation of all parameters once the CLI model export flags will be implemented |
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 TODO should be part of a ticket.
src/hf_pull_model_module.cpp
Outdated
// 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. | ||
//***************************************************************************** |
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.
shouldn't those two files be in libgt2 dir?
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 can move it there.
src/libgt2/libgt2.cpp
Outdated
} | ||
|
||
bool HfDownloader::CheckIfProxySet() { | ||
const char* envCred = std::getenv("https_proxy"); |
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 still do have get env in HfDownloader
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.
Removed today.
src/libgt2/libgt2.cpp
Outdated
if (envCred) { | ||
hfEndpoint = std::string(envCred); | ||
} else { | ||
SPDLOG_DEBUG("HF_ENDPOINT environment variable not set"); |
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.
Is this reason to stop OVMS if we require to pull but endpoint is not set?
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 use default endpoint huggingface.co
src/test/pull_hf_model_test.cpp
Outdated
|
||
ASSERT_EQ(hfDownloader->GetRepoUrl(hfEndpoint), "https://www.new_hf.com/model/name"); | ||
|
||
ASSERT_EQ(hfDownloader->GetRepositoryUrlWithPassword(hfEndpoint), "https://123$$o_O123!AAbb:[email protected]_hf.com/model/name"); |
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.
Approach with envs with leak env in case of failura at asserts. We could have instead
ASSERT_EQ(HfDownloader(modelName, downloadPath, false, hfEndpoint, hf_token, useProxy).GetRepositoryUrlWithPassword(), "https://123$$o_O123!AAbb:[email protected]_hf.com/model/name");
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.
Then you could easily add additional lines for testing incorrect downloadPaths vaildation, invalid modelName convetions (special characters?), endpoint not being proper url, etc. instead of having setup envs separaterly each time.
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.
Added task for additional validation of variables from the user.
src/libgt2/libgt2.hpp
Outdated
std::string hfEndpoint; | ||
std::string hfToken; | ||
std::string httpProxy; | ||
bool pullHfModelMode; |
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.
Why is this here? Either we create module for pulling or not. I don't see a point.
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.
Left from previous implementation. Good catch to remove.
ASSERT_EQ(hfDownloader->getEndpoint(), "www.new_hf.com/"); | ||
ASSERT_EQ(hfDownloader->GetRepoUrl(), "https://www.new_hf.com/model/name"); |
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.
Those are verified in GetRepositoryUrlWithPassword. We don't need to test if setting those values in constructor works.
Only checking for proxy makes sense but even then it is better to document what is considered proxy not set for hf downloader with
EXPECT_EQ(TestHfDownloader(modelName, downloadPath, false, hfEndpoint, hfToken, "").isProxySet(), false)
or
EXPECT_EQ(TestHfDownloader(modelName, downloadPath, false, hfEndpoint, hfToken, "").isProxySet(), 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.
This is standard unit test approach to test all methods of a class. Specifically when one method returns values that are used in another method. I can change the EXPECT_EQ for proxy though for better readability.
Co-authored-by: Adrian Tobiszewski <[email protected]>
🛠 Summary
JIRA CVS-163308
Current usage:
bazel-bin/src/ovms --pull_hf_model --source_model OpenVINO/TinyLlama-1.1B-Chat-v1.0-int8-ov --repo_path /download
🧪 Checklist
``