Skip to content

Commit 8996da2

Browse files
authored
Add format dduf (#793)
* feat: add support for DDUF format in backend and client handling * deprecate diffusers format (use dduf instead)
1 parent c4a1f76 commit 8996da2

8 files changed

Lines changed: 17 additions & 11 deletions

File tree

cmd/cli/search/backend_resolution.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func backendFromFormat(format disttypes.Format) string {
9595
return backendLlamaCpp
9696
case disttypes.FormatSafetensors:
9797
return backendVLLM
98-
case disttypes.FormatDiffusers:
98+
case disttypes.FormatDDUF, disttypes.FormatDiffusers: //nolint:staticcheck // FormatDiffusers kept for backward compatibility
9999
return backendDiffusers
100100
default:
101101
return backendUnknown

cmd/cli/search/backend_resolution_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ func TestBackendFromFormat(t *testing.T) {
2020
}{
2121
{name: "gguf", format: disttypes.FormatGGUF, want: backendLlamaCpp},
2222
{name: "safetensors", format: disttypes.FormatSafetensors, want: backendVLLM},
23-
{name: "diffusers", format: disttypes.FormatDiffusers, want: backendDiffusers},
23+
{name: "dduf", format: disttypes.FormatDDUF, want: backendDiffusers},
24+
{name: "diffusers (deprecated)", format: disttypes.FormatDiffusers, want: backendDiffusers}, //nolint:staticcheck // FormatDiffusers kept for backward compatibility
2425
{name: "unknown", format: "", want: backendUnknown},
2526
}
2627

pkg/distribution/builder/from_directory.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func FromDirectory(dirPath string, opts ...DirectoryOption) (*Builder, error) {
163163
weightFiles = append(weightFiles, path)
164164
case files.FileTypeDDUF:
165165
if detectedFormat == "" {
166-
detectedFormat = types.FormatDiffusers
166+
detectedFormat = types.FormatDDUF
167167
}
168168
weightFiles = append(weightFiles, path)
169169
case files.FileTypeUnknown, files.FileTypeConfig, files.FileTypeLicense, files.FileTypeChatTemplate:

pkg/distribution/format/dduf.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func init() {
2020

2121
// Name returns the format identifier for DDUF.
2222
func (d *DDUFFormat) Name() types.Format {
23-
return types.FormatDiffusers
23+
return types.FormatDDUF
2424
}
2525

2626
// MediaType returns the OCI media type for DDUF layers.
@@ -39,7 +39,7 @@ func (d *DDUFFormat) DiscoverShards(path string) ([]string, error) {
3939
// DDUF files are zip archives containing model config, so we extract what we can.
4040
func (d *DDUFFormat) ExtractConfig(paths []string) (types.Config, error) {
4141
if len(paths) == 0 {
42-
return types.Config{Format: types.FormatDiffusers}, nil
42+
return types.Config{Format: types.FormatDDUF}, nil
4343
}
4444

4545
// Calculate total size across all files
@@ -59,7 +59,7 @@ func (d *DDUFFormat) ExtractConfig(paths []string) (types.Config, error) {
5959
// In the future, we could extract model_index.json from the DDUF archive
6060
// to get architecture details, etc.
6161
return types.Config{
62-
Format: types.FormatDiffusers,
62+
Format: types.FormatDDUF,
6363
Architecture: "diffusers",
6464
Size: formatSize(totalSize),
6565
Diffusers: map[string]string{

pkg/distribution/format/format.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func DetectFromPath(path string) (Format, error) {
6262
case files.FileTypeSafetensors:
6363
return Get(types.FormatSafetensors)
6464
case files.FileTypeDDUF:
65-
return Get(types.FormatDiffusers)
65+
return Get(types.FormatDDUF)
6666
case files.FileTypeUnknown, files.FileTypeConfig, files.FileTypeLicense, files.FileTypeChatTemplate:
6767
return nil, fmt.Errorf("unable to detect format from path: %s (file type: %s)", utils.SanitizeForLog(path), ft)
6868
}

pkg/distribution/internal/bundle/unpack.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func unpackLegacy(dir string, model types.Model) (*Bundle, error) {
6262
if err := unpackSafetensors(bundle, model); err != nil {
6363
return nil, fmt.Errorf("unpack safetensors files: %w", err)
6464
}
65-
case types.FormatDiffusers:
65+
case types.FormatDiffusers, types.FormatDDUF: //nolint:staticcheck // FormatDiffusers kept for backward compatibility
6666
if err := unpackDDUF(bundle, model); err != nil {
6767
return nil, fmt.Errorf("unpack DDUF file: %w", err)
6868
}
@@ -124,7 +124,7 @@ func detectModelFormat(model types.Model) types.Format {
124124
// Check for DDUF files
125125
ddufPaths, err := model.DDUFPaths()
126126
if err == nil && len(ddufPaths) > 0 {
127-
return types.FormatDiffusers
127+
return types.FormatDDUF
128128
}
129129

130130
return ""

pkg/distribution/modelpack/types.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,10 @@ func (m *Model) GetFormat() types.Format {
232232
return types.FormatGGUF
233233
case "safetensors":
234234
return types.FormatSafetensors
235+
case "dduf":
236+
return types.FormatDDUF
235237
case "diffusers":
236-
return types.FormatDiffusers
238+
return types.FormatDiffusers //nolint:staticcheck // FormatDiffusers kept for backward compatibility
237239
default:
238240
return types.Format(f)
239241
}

pkg/distribution/types/config.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ const (
5050

5151
FormatGGUF = Format("gguf")
5252
FormatSafetensors = Format("safetensors")
53-
FormatDiffusers = Format("diffusers")
53+
FormatDDUF = Format("dduf")
54+
// Deprecated: FormatDiffusers is kept for backward compatibility with models
55+
// that have "format": "diffusers" in their config. Use FormatDDUF instead.
56+
FormatDiffusers = Format("diffusers")
5457

5558
// OCI Annotation keys for model layers
5659
// See https://github.com/opencontainers/image-spec/blob/main/annotations.md

0 commit comments

Comments
 (0)