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

Persist IF tensors to storage for large models #377

Closed
Xuzzo opened this issue Jul 13, 2023 · 0 comments · Fixed by #456
Closed

Persist IF tensors to storage for large models #377

Xuzzo opened this issue Jul 13, 2023 · 0 comments · Fixed by #456
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@Xuzzo
Copy link
Collaborator

Xuzzo commented Jul 13, 2023

Problem: As highlighted in a discussion in MR #375, a lot of the tensors we create for influence calculation end up being very large. For example, the influence factors are stored in a matrix of size (N_test_points, N_model_parameters). Often, these cannot fit into RAM (be it ordinary or on GPU).

A simple fix would use generators. Instead of creating all the influence factors, we could calculate batch-by-batch within the compute_influences_up and compute_influences_pert methods. Same can be said of grads within these methods. However, this would imply re-calculating influence factors or grads several times, with massive computational overhead.

A better fix would cache the tensors to disk. We could create a CachedTensor class that saves the tensors into files and loads them whenever needed, thus freeing the VRAM. Even the output of the compute_influences method could be a CachedTensor: one would only need to remember to flush it when it is no longer needed.

@Xuzzo Xuzzo added the enhancement New feature or request label Jul 13, 2023
@Xuzzo Xuzzo changed the title Cache IF tensors into storage for large models Cache IF tensors to storage for large models Aug 24, 2023
@mdbenito mdbenito changed the title Cache IF tensors to storage for large models Persist IF tensors to storage for large models Aug 31, 2023
@mdbenito mdbenito added this to the v0.8.0 milestone Aug 31, 2023
@mdbenito mdbenito modified the milestones: v0.8.0, v0.7.2 Oct 26, 2023
@schroedk schroedk mentioned this issue Nov 20, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants