Skip to content

Conversation

@8W9aG
Copy link
Contributor

@8W9aG 8W9aG commented Mar 31, 2025

  • Add a new experimental flag —x-localimage for use with —x-fastpush
  • When activated, the flag uses the .cog tmp directory as an rsync for the source code without
    weights
  • It separates the different build steps into different build contexts
  • On run/predict/train/serve it loads the weights in as volume mounts
  • This allows it to not reload the context each time a small file is changed for weights

* Add a new experimental flag —x-localimage for use
with —x-fastpush
* When activated, the flag uses the .cog tmp
directory as an rsync for the source code without
weights
* It separates the different build steps into
different build contexts
* On run/predict/train/serve it loads the weights
in as volume mounts
* This allows it to not reload the context each
time a small file is changed for weights
@8W9aG 8W9aG requested a review from nevillelyh April 2, 2025 19:51
if imageName, err = image.BuildBase(cfg, projectDir, buildUseCudaBaseImage, DetermineUseCogBaseImage(cmd), buildProgressOutput); err != nil {
return err
}
if buildFast {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can you just throw this into the block above

if cfg.Build.Fast {
    buildFast = true
    imageName = config.DockerImageName(projectDir)
} else {
    ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I don't think we can, config fast build overwrites any CLI flag which is the first block, but in the 2nd block we need to know whether the fast build flag is in general on and overwrite the imageName


// Rsync local src with our srcdir
if g.localImage {
err := g.rsyncSrc(srcDir, weights)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could just be me not understanding correctly but what we're doing here

  • Symlinking everything in g.Dir to a subdirectory
  • Hard link to all the symlinks?

I guess I'm a bit confused why we're doing the rsync first?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our process is:

  1. If a local image flag is used, created a src directory in .cog
  2. Create the necessary hard links and directories to mirror whats in the users current directory (sans weights and dockerignore directives), if it is symlink use the target path
  3. Tag that as a unique build context so it only changes the docker build when the user changes their code

8W9aG added 3 commits April 3, 2025 09:50
* Synchronise directories between different golang
modules
@8W9aG 8W9aG requested a review from NikhilSinha1 April 3, 2025 14:19
@8W9aG
Copy link
Contributor Author

8W9aG commented Apr 3, 2025

Going to merge this to build a new release

@8W9aG 8W9aG merged commit 05deb64 into main Apr 3, 2025
21 checks passed
@8W9aG 8W9aG deleted the sackfield/add-local-image-flag branch April 3, 2025 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants