From f41849c0893c70562c72ff797b7e7105e2020e6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacio=20L=C3=B3pez=20Luna?= Date: Thu, 26 Mar 2026 10:28:22 +0100 Subject: [PATCH 1/2] feat: add support for DDUF format in backend and client handling --- cmd/cli/search/backend_resolution.go | 2 +- pkg/distribution/builder/from_directory.go | 2 +- pkg/distribution/distribution/client.go | 4 ++-- pkg/distribution/format/dduf.go | 6 +++--- pkg/distribution/format/format.go | 2 +- pkg/distribution/internal/bundle/unpack.go | 4 ++-- pkg/distribution/modelpack/types.go | 2 ++ pkg/distribution/types/config.go | 5 ++++- 8 files changed, 16 insertions(+), 11 deletions(-) diff --git a/cmd/cli/search/backend_resolution.go b/cmd/cli/search/backend_resolution.go index 2d88e2253..c49623e1e 100644 --- a/cmd/cli/search/backend_resolution.go +++ b/cmd/cli/search/backend_resolution.go @@ -95,7 +95,7 @@ func backendFromFormat(format disttypes.Format) string { return backendLlamaCpp case disttypes.FormatSafetensors: return backendVLLM - case disttypes.FormatDiffusers: + case disttypes.FormatDDUF, disttypes.FormatDiffusers: return backendDiffusers default: return backendUnknown diff --git a/pkg/distribution/builder/from_directory.go b/pkg/distribution/builder/from_directory.go index fdef17114..5c7f53a2a 100644 --- a/pkg/distribution/builder/from_directory.go +++ b/pkg/distribution/builder/from_directory.go @@ -163,7 +163,7 @@ func FromDirectory(dirPath string, opts ...DirectoryOption) (*Builder, error) { weightFiles = append(weightFiles, path) case files.FileTypeDDUF: if detectedFormat == "" { - detectedFormat = types.FormatDiffusers + detectedFormat = types.FormatDDUF } weightFiles = append(weightFiles, path) case files.FileTypeUnknown, files.FileTypeConfig, files.FileTypeLicense, files.FileTypeChatTemplate: diff --git a/pkg/distribution/distribution/client.go b/pkg/distribution/distribution/client.go index 9e8c44f4a..bc6922de4 100644 --- a/pkg/distribution/distribution/client.go +++ b/pkg/distribution/distribution/client.go @@ -776,9 +776,9 @@ func (c *Client) GetBundle(ref string) (types.ModelBundle, error) { func GetSupportedFormats() []types.Format { if platform.SupportsVLLM() { - return []types.Format{types.FormatGGUF, types.FormatSafetensors, types.FormatDiffusers} + return []types.Format{types.FormatGGUF, types.FormatSafetensors, types.FormatDDUF, types.FormatDiffusers} } - return []types.Format{types.FormatGGUF, types.FormatDiffusers} + return []types.Format{types.FormatGGUF, types.FormatDDUF, types.FormatDiffusers} } func checkCompat(image types.ModelArtifact, log *slog.Logger, reference string, progressWriter io.Writer) error { diff --git a/pkg/distribution/format/dduf.go b/pkg/distribution/format/dduf.go index d4fe6e838..e0d42d2ec 100644 --- a/pkg/distribution/format/dduf.go +++ b/pkg/distribution/format/dduf.go @@ -20,7 +20,7 @@ func init() { // Name returns the format identifier for DDUF. func (d *DDUFFormat) Name() types.Format { - return types.FormatDiffusers + return types.FormatDDUF } // MediaType returns the OCI media type for DDUF layers. @@ -39,7 +39,7 @@ func (d *DDUFFormat) DiscoverShards(path string) ([]string, error) { // DDUF files are zip archives containing model config, so we extract what we can. func (d *DDUFFormat) ExtractConfig(paths []string) (types.Config, error) { if len(paths) == 0 { - return types.Config{Format: types.FormatDiffusers}, nil + return types.Config{Format: types.FormatDDUF}, nil } // Calculate total size across all files @@ -59,7 +59,7 @@ func (d *DDUFFormat) ExtractConfig(paths []string) (types.Config, error) { // In the future, we could extract model_index.json from the DDUF archive // to get architecture details, etc. return types.Config{ - Format: types.FormatDiffusers, + Format: types.FormatDDUF, Architecture: "diffusers", Size: formatSize(totalSize), Diffusers: map[string]string{ diff --git a/pkg/distribution/format/format.go b/pkg/distribution/format/format.go index b905e57b0..9b6fbf24e 100644 --- a/pkg/distribution/format/format.go +++ b/pkg/distribution/format/format.go @@ -62,7 +62,7 @@ func DetectFromPath(path string) (Format, error) { case files.FileTypeSafetensors: return Get(types.FormatSafetensors) case files.FileTypeDDUF: - return Get(types.FormatDiffusers) + return Get(types.FormatDDUF) case files.FileTypeUnknown, files.FileTypeConfig, files.FileTypeLicense, files.FileTypeChatTemplate: return nil, fmt.Errorf("unable to detect format from path: %s (file type: %s)", utils.SanitizeForLog(path), ft) } diff --git a/pkg/distribution/internal/bundle/unpack.go b/pkg/distribution/internal/bundle/unpack.go index 82e923b33..f09407858 100644 --- a/pkg/distribution/internal/bundle/unpack.go +++ b/pkg/distribution/internal/bundle/unpack.go @@ -62,7 +62,7 @@ func unpackLegacy(dir string, model types.Model) (*Bundle, error) { if err := unpackSafetensors(bundle, model); err != nil { return nil, fmt.Errorf("unpack safetensors files: %w", err) } - case types.FormatDiffusers: + case types.FormatDiffusers, types.FormatDDUF: if err := unpackDDUF(bundle, model); err != nil { return nil, fmt.Errorf("unpack DDUF file: %w", err) } @@ -124,7 +124,7 @@ func detectModelFormat(model types.Model) types.Format { // Check for DDUF files ddufPaths, err := model.DDUFPaths() if err == nil && len(ddufPaths) > 0 { - return types.FormatDiffusers + return types.FormatDDUF } return "" diff --git a/pkg/distribution/modelpack/types.go b/pkg/distribution/modelpack/types.go index af4345afc..69ffa5f53 100644 --- a/pkg/distribution/modelpack/types.go +++ b/pkg/distribution/modelpack/types.go @@ -158,6 +158,8 @@ func (m *Model) GetFormat() types.Format { return types.FormatGGUF case "safetensors": return types.FormatSafetensors + case "dduf": + return types.FormatDDUF case "diffusers": return types.FormatDiffusers default: diff --git a/pkg/distribution/types/config.go b/pkg/distribution/types/config.go index 6236f6cf8..c74d4e4bb 100644 --- a/pkg/distribution/types/config.go +++ b/pkg/distribution/types/config.go @@ -50,7 +50,10 @@ const ( FormatGGUF = Format("gguf") FormatSafetensors = Format("safetensors") - FormatDiffusers = Format("diffusers") + FormatDDUF = Format("dduf") + // FormatDiffusers is kept for backward compatibility with models that have "format": "diffusers" in their config. + // New models use FormatDDUF instead. + FormatDiffusers = Format("diffusers") // OCI Annotation keys for model layers // See https://github.com/opencontainers/image-spec/blob/main/annotations.md From 370536ba139c2a58d302f3e8f0ba000750e344d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacio=20L=C3=B3pez=20Luna?= Date: Thu, 26 Mar 2026 10:33:06 +0100 Subject: [PATCH 2/2] deprecate diffusers format (use dduf instead) --- cmd/cli/search/backend_resolution.go | 2 +- cmd/cli/search/backend_resolution_test.go | 3 ++- pkg/distribution/distribution/client.go | 4 ++-- pkg/distribution/internal/bundle/unpack.go | 2 +- pkg/distribution/modelpack/types.go | 2 +- pkg/distribution/types/config.go | 4 ++-- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/cmd/cli/search/backend_resolution.go b/cmd/cli/search/backend_resolution.go index c49623e1e..bc0b30298 100644 --- a/cmd/cli/search/backend_resolution.go +++ b/cmd/cli/search/backend_resolution.go @@ -95,7 +95,7 @@ func backendFromFormat(format disttypes.Format) string { return backendLlamaCpp case disttypes.FormatSafetensors: return backendVLLM - case disttypes.FormatDDUF, disttypes.FormatDiffusers: + case disttypes.FormatDDUF, disttypes.FormatDiffusers: //nolint:staticcheck // FormatDiffusers kept for backward compatibility return backendDiffusers default: return backendUnknown diff --git a/cmd/cli/search/backend_resolution_test.go b/cmd/cli/search/backend_resolution_test.go index be203cfd0..9f0f6c032 100644 --- a/cmd/cli/search/backend_resolution_test.go +++ b/cmd/cli/search/backend_resolution_test.go @@ -20,7 +20,8 @@ func TestBackendFromFormat(t *testing.T) { }{ {name: "gguf", format: disttypes.FormatGGUF, want: backendLlamaCpp}, {name: "safetensors", format: disttypes.FormatSafetensors, want: backendVLLM}, - {name: "diffusers", format: disttypes.FormatDiffusers, want: backendDiffusers}, + {name: "dduf", format: disttypes.FormatDDUF, want: backendDiffusers}, + {name: "diffusers (deprecated)", format: disttypes.FormatDiffusers, want: backendDiffusers}, //nolint:staticcheck // FormatDiffusers kept for backward compatibility {name: "unknown", format: "", want: backendUnknown}, } diff --git a/pkg/distribution/distribution/client.go b/pkg/distribution/distribution/client.go index bc6922de4..3d0f3c117 100644 --- a/pkg/distribution/distribution/client.go +++ b/pkg/distribution/distribution/client.go @@ -776,9 +776,9 @@ func (c *Client) GetBundle(ref string) (types.ModelBundle, error) { func GetSupportedFormats() []types.Format { if platform.SupportsVLLM() { - return []types.Format{types.FormatGGUF, types.FormatSafetensors, types.FormatDDUF, types.FormatDiffusers} + return []types.Format{types.FormatGGUF, types.FormatSafetensors, types.FormatDDUF, types.FormatDiffusers} //nolint:staticcheck // FormatDiffusers kept for backward compatibility } - return []types.Format{types.FormatGGUF, types.FormatDDUF, types.FormatDiffusers} + return []types.Format{types.FormatGGUF, types.FormatDDUF, types.FormatDiffusers} //nolint:staticcheck // FormatDiffusers kept for backward compatibility } func checkCompat(image types.ModelArtifact, log *slog.Logger, reference string, progressWriter io.Writer) error { diff --git a/pkg/distribution/internal/bundle/unpack.go b/pkg/distribution/internal/bundle/unpack.go index f09407858..293a979ac 100644 --- a/pkg/distribution/internal/bundle/unpack.go +++ b/pkg/distribution/internal/bundle/unpack.go @@ -62,7 +62,7 @@ func unpackLegacy(dir string, model types.Model) (*Bundle, error) { if err := unpackSafetensors(bundle, model); err != nil { return nil, fmt.Errorf("unpack safetensors files: %w", err) } - case types.FormatDiffusers, types.FormatDDUF: + case types.FormatDiffusers, types.FormatDDUF: //nolint:staticcheck // FormatDiffusers kept for backward compatibility if err := unpackDDUF(bundle, model); err != nil { return nil, fmt.Errorf("unpack DDUF file: %w", err) } diff --git a/pkg/distribution/modelpack/types.go b/pkg/distribution/modelpack/types.go index 69ffa5f53..db693ff2f 100644 --- a/pkg/distribution/modelpack/types.go +++ b/pkg/distribution/modelpack/types.go @@ -161,7 +161,7 @@ func (m *Model) GetFormat() types.Format { case "dduf": return types.FormatDDUF case "diffusers": - return types.FormatDiffusers + return types.FormatDiffusers //nolint:staticcheck // FormatDiffusers kept for backward compatibility default: return types.Format(f) } diff --git a/pkg/distribution/types/config.go b/pkg/distribution/types/config.go index c74d4e4bb..0a8240f90 100644 --- a/pkg/distribution/types/config.go +++ b/pkg/distribution/types/config.go @@ -51,8 +51,8 @@ const ( FormatGGUF = Format("gguf") FormatSafetensors = Format("safetensors") FormatDDUF = Format("dduf") - // FormatDiffusers is kept for backward compatibility with models that have "format": "diffusers" in their config. - // New models use FormatDDUF instead. + // Deprecated: FormatDiffusers is kept for backward compatibility with models + // that have "format": "diffusers" in their config. Use FormatDDUF instead. FormatDiffusers = Format("diffusers") // OCI Annotation keys for model layers