Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disk caches should only write on some ranks #4000

Open
connorjward opened this issue Jan 29, 2025 · 0 comments
Open

Disk caches should only write on some ranks #4000

connorjward opened this issue Jan 29, 2025 · 0 comments

Comments

@connorjward
Copy link
Contributor

The way it is currently implemented, DictLikeDiskAccess writes to disk on all ranks. This is clearly inefficient. Instead we should try and use something like the compilation_comm (created here) and only write on one of the ranks that share a filesystem.

My idea for how to approach this is to modify DictLikeDiskAccess with a dummy: bool kwarg s.t. access on particular ranks can be masked. For example:

def __setitem__(self, key, value):
    if self.dummy:
        pass
    else:
        # actually set the value

This attribute could be set doing something like:

def _make_disk_cache(comm):
    filesystem_comm = comm.getAttr("filesystem_comm")
    dummy = filesystem_comm.rank != 0
    return DictLikeDiskAccess(cachedir, dummy=dummy)

@disk_only_cache(cache_factory=_make_disk_cache):
def cached_func(...):
    ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant