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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IntegratedGradients] Memory leaks when calculating IG and LIG #866

Open
roma-glushko opened this issue Feb 16, 2022 · 4 comments
Open

[IntegratedGradients] Memory leaks when calculating IG and LIG #866

roma-glushko opened this issue Feb 16, 2022 · 4 comments

Comments

@roma-glushko
Copy link

馃悰 Bug

I'm experiencing RAM leaks when calculating word attributions through https://github.com/cdpierse/transformers-interpret library which delegates the most of the heavy lifting to Captum. So I assume this issue is relevant to Captum.

To Reproduce

My setup is described in detail in the following issue: cdpierse/transformers-interpret#78

Expected behavior

Every time the model gets a request that should contain interpretability information, Captum calculates IG/LIG using some amount of RAM and then clean all the used RAM once that is done, so at the end of the request processing we have almost the same amount of memory used by the model service.

Environment

 - Captum / PyTorch Version (e.g., 1.0 / 0.4.0): 0.4.0/1.9.1
 - OS: registry.access.redhat.com/ubi8/python-39:latest docker image
 - How you installed Captum / PyTorch: via Poetry
 - Python version: 3.9
 - CUDA/cuDNN version: N/A, running on CPU
@NarineK
Copy link
Contributor

NarineK commented Feb 17, 2022

@roma-glushko, this is interesting because LIG and IG are stateless, there shouldn't be any memory leak. Have you tried to use another layer method such as captum.attr.LayerActivation ? Do you see similar issue ?

@roma-glushko
Copy link
Author

Hey @NarineK, thank you for the replay!
Unfortunately, I have no idea about that. Maybe @cdpierse has any.

In any case, I could track it down on the python side. My gut feeling that the issue goes beyond the Python realm and may lay in the C/C++ level. Although I have no direct evidence of that, other than I could not find any gradient leaks debugging Python codebase.

@jakobamb
Copy link

Hi @NarineK, any news on this? I am experiencing similar issues with a transformer model. Are you planning on looking into this? I could try to create a minimal example if this helps.

@NarineK
Copy link
Contributor

NarineK commented Apr 14, 2022

@jakobamb if you could send me a minimal example that will help me with the debugging. Thank you1

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

3 participants