-
Notifications
You must be signed in to change notification settings - Fork 128
[feat] added integration with OpenVINO Model Server #940
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
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 |
|---|---|---|
|
|
@@ -31,8 +31,9 @@ func BuildModel(ctx context.Context, client *Client, repo, revision, tag string, | |
|
|
||
| // Filter to model files (weights + configs) | ||
| weightFiles, configFiles := FilterModelFiles(files) | ||
| isOpenVINORepo := IsOpenVINOModel(files) | ||
|
|
||
| if len(weightFiles) == 0 { | ||
| if len(weightFiles) == 0 && !isOpenVINORepo { | ||
| return nil, fmt.Errorf("no model weight files (GGUF or SafeTensors) found in repository %s", repo) | ||
| } | ||
|
|
||
|
|
@@ -54,10 +55,20 @@ func BuildModel(ctx context.Context, client *Client, repo, revision, tag string, | |
| } | ||
| } | ||
|
|
||
| // Combine all files to download | ||
| allFiles := append(weightFiles, configFiles...) | ||
| if mmprojFile != nil { | ||
| allFiles = append(allFiles, *mmprojFile) | ||
| // Combine all files to download. | ||
| // For OpenVINO repositories, pull all repository files so the full IR layout is preserved. | ||
| var allFiles []RepoFile | ||
| if isOpenVINORepo { | ||
| for _, f := range files { | ||
| if f.Type == "file" { | ||
| allFiles = append(allFiles, f) | ||
| } | ||
| } | ||
|
Comment on lines
+61
to
+66
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Downloading all files in an OpenVINO repository can result in downloading unnecessary large weight files (such as if isOpenVINORepo {
xmlStems := make(map[string]bool)
for _, f := range files {
if f.Type == "file" && strings.HasSuffix(strings.ToLower(f.Path), ".xml") {
xmlStems[f.Path[:len(f.Path)-4]] = true
}
}
for _, f := range files {
if f.Type == "file" {
lowerPath := strings.ToLower(f.Path)
if strings.HasSuffix(lowerPath, ".safetensors") || strings.HasSuffix(lowerPath, ".gguf") || strings.HasSuffix(lowerPath, ".dduf") {
continue
}
if strings.HasSuffix(lowerPath, ".bin") {
stem := f.Path[:len(f.Path)-4]
if !xmlStems[stem] {
continue
}
}
allFiles = append(allFiles, f)
}
}
}References
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dtrawins does this make sense? You know more about this repo format/file format than me |
||
| } else { | ||
| allFiles = append(weightFiles, configFiles...) | ||
| if mmprojFile != nil { | ||
| allFiles = append(allFiles, *mmprojFile) | ||
| } | ||
| } | ||
|
|
||
| if progressWriter != nil { | ||
|
|
@@ -91,7 +102,7 @@ func BuildModel(ctx context.Context, client *Client, repo, revision, tag string, | |
| } | ||
|
|
||
| model, err := buildModelFromFiles( | ||
| result.LocalPaths, weightFiles, configFiles, mmprojFile, tempDir, createdTime, | ||
| result.LocalPaths, weightFiles, configFiles, mmprojFile, tempDir, createdTime, isOpenVINORepo, | ||
| ) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("build model: %w", err) | ||
|
|
@@ -111,26 +122,30 @@ func buildModelFromFiles( | |
| mmprojFile *RepoFile, | ||
| tempDir string, | ||
| createdTime *time.Time, | ||
| allowNoStandardWeights bool, | ||
| ) (types.ModelArtifact, error) { | ||
| // Check if this is a safetensors model - use V0.2 packaging | ||
| if isSafetensorsModel(weightFiles) { | ||
| return buildSafetensorsModelV02(tempDir, createdTime) | ||
| // Safetensors and OpenVINO repos are packaged with V0.2 layer-per-file packaging. | ||
| if isSafetensorsModel(weightFiles) || allowNoStandardWeights { | ||
| return buildDirectoryModelV02(tempDir, createdTime, allowNoStandardWeights) | ||
| } | ||
|
|
||
| // For GGUF models, use V0.1 packaging (backward compatible) | ||
| return buildGGUFModelV01(localPaths, weightFiles, configFiles, mmprojFile, createdTime) | ||
| } | ||
|
|
||
| // buildSafetensorsModelV02 builds a safetensors model using V0.2 layer-per-file packaging. | ||
| // buildDirectoryModelV02 builds a model using V0.2 layer-per-file packaging. | ||
| // It uses builder.FromDirectory which recursively scans the tempDir and creates one layer | ||
| // per file, preserving nested directory structure with filepath annotations. | ||
| // If createdTime is non-nil, it is used as the creation timestamp for the OCI config | ||
| // to produce deterministic digests. Otherwise time.Now() is used. | ||
| func buildSafetensorsModelV02(tempDir string, createdTime *time.Time) (types.ModelArtifact, error) { | ||
| func buildDirectoryModelV02(tempDir string, createdTime *time.Time, allowNoStandardWeights bool) (types.ModelArtifact, error) { | ||
| var dirOpts []builder.DirectoryOption | ||
| if createdTime != nil { | ||
| dirOpts = append(dirOpts, builder.WithCreatedTime(*createdTime)) | ||
| } | ||
| if allowNoStandardWeights { | ||
| dirOpts = append(dirOpts, builder.WithAllowNoWeightFiles()) | ||
| } | ||
|
|
||
| b, err := builder.FromDirectory(tempDir, dirOpts...) | ||
| if err != nil { | ||
|
|
||
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 add openvino examples, but we should avoid replacing the existing ones