Use Overlay mode for writable local layers
mainThe --overlay flag creates a writable local layer on top of a remote source.
How it works:
- Reads: Returns files from the remote source OR files already present in the local layer. If a name exists in both, the local copy wins.
- Writes: All new files, directories, or modifications land only on the local disk. The remote source is never touched.
- Persistence: Local files survive an unmount/remount.
Use Case: A shared compilation cache where multiple machines mount the same bucket with --overlay. They read existing artifacts from the bucket but write new ones locally, effectively creating a per-machine cache layer.
Limitations:
- You cannot modify, rename, or delete files that exist only on the remote. These operations will fail with a permission error.
- You cannot shadow an existing remote name with a new local file after the mount is active. To do this, place the file in the mount-point directory before starting the mount.
- Symlinks in the local layer are hidden from the merged view to prevent escaping the mount point.
# Producer (writes compiled artifacts to the bucket)
hf-mount start bucket myorg/torch-compile-cache "$TORCHINDUCTOR_CACHE_DIR"
# Consumer (reads from the bucket, compiles locally on miss)
hf-mount start --overlay bucket myorg/torch-compile-cache "$TORCHINDUCTOR_CACHE_DIR"