From a3238f7533c110cd30c83bd3c5e97b099fdad46a Mon Sep 17 00:00:00 2001 From: pnkcaht Date: Thu, 5 Feb 2026 14:01:31 -0500 Subject: [PATCH 1/2] fix: avoid re-downloading models already present in local store Signed-off-by: pnkcaht --- pkg/distribution/distribution/client.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pkg/distribution/distribution/client.go b/pkg/distribution/distribution/client.go index b5ba001d..1d0746a6 100644 --- a/pkg/distribution/distribution/client.go +++ b/pkg/distribution/distribution/client.go @@ -238,6 +238,28 @@ func (c *Client) PullModel(ctx context.Context, reference string, progressWriter originalReference := reference // Normalize the model reference reference = c.normalizeModelName(reference) + + // Fast-path: if the model already exists locally by normalized reference, + // do not hit the registry or re-download. + if localModel, err := c.store.Read(reference); err == nil { + c.log.Infoln("Model found in local store by tag:", utils.SanitizeForLog(reference)) + + cfg, err := localModel.Config() + if err != nil { + return fmt.Errorf("getting cached model config: %w", err) + } + + if err := progress.WriteSuccess( + progressWriter, + fmt.Sprintf("Using cached model: %s", cfg.GetSize()), + oci.ModePull, + ); err != nil { + c.log.Warnf("Writing progress: %v", err) + } + + return nil + } + c.log.Infoln("Starting model pull:", utils.SanitizeForLog(reference)) // Handle bearer token for registry authentication From ad99ceecbdb1d73c3c9793da1b4a81f9e40fe5df Mon Sep 17 00:00:00 2001 From: pnkcaht Date: Thu, 5 Feb 2026 14:10:25 -0500 Subject: [PATCH 2/2] fix: limit cache fast-path to immutable digest references Signed-off-by: pnkcaht --- pkg/distribution/distribution/client.go | 34 +++++++++++++------------ 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/pkg/distribution/distribution/client.go b/pkg/distribution/distribution/client.go index 1d0746a6..601e41d5 100644 --- a/pkg/distribution/distribution/client.go +++ b/pkg/distribution/distribution/client.go @@ -239,25 +239,27 @@ func (c *Client) PullModel(ctx context.Context, reference string, progressWriter // Normalize the model reference reference = c.normalizeModelName(reference) - // Fast-path: if the model already exists locally by normalized reference, - // do not hit the registry or re-download. - if localModel, err := c.store.Read(reference); err == nil { - c.log.Infoln("Model found in local store by tag:", utils.SanitizeForLog(reference)) + // Fast-path only for immutable digest references. + // Tags may be mutable and must be checked against the registry. + if strings.Contains(reference, "@") { + if localModel, err := c.store.Read(reference); err == nil { + c.log.Infoln("Model found in local store by digest:", utils.SanitizeForLog(reference)) - cfg, err := localModel.Config() - if err != nil { - return fmt.Errorf("getting cached model config: %w", err) - } + cfg, err := localModel.Config() + if err != nil { + return fmt.Errorf("getting cached model config: %w", err) + } - if err := progress.WriteSuccess( - progressWriter, - fmt.Sprintf("Using cached model: %s", cfg.GetSize()), - oci.ModePull, - ); err != nil { - c.log.Warnf("Writing progress: %v", err) - } + if err := progress.WriteSuccess( + progressWriter, + fmt.Sprintf("Using cached model: %s", cfg.GetSize()), + oci.ModePull, + ); err != nil { + c.log.Warnf("Writing progress: %v", err) + } - return nil + return nil + } } c.log.Infoln("Starting model pull:", utils.SanitizeForLog(reference))