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

[dattri.trak] Improving memory efficiency when calculating TRAK #154

Open
KurisuTheAmadeus opened this issue Nov 29, 2024 · 0 comments
Open

Comments

@KurisuTheAmadeus
Copy link

Current Implementation of TRAK calculates final result using

    return (running_xinv_XTX_XT @ self.Q.diag().to(self.device)).T

and the introduction of diag matrix creates large memory overhead, especially in the case when number of training data points is large.
A possible fix is as follows

        if train_dataloader is not None:
            return (running_xinv_XTX_XT * running_Q.to(self.device).unsqueeze(0)).T
        return (running_xinv_XTX_XT * self.Q.to(self.device).unsqueeze(0)).T

and I have verified the equivalency using two different setups.

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

No branches or pull requests

1 participant