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

[PT] detach tensor in get_const_data #3199

Merged

Conversation

AlexanderDokuchaev
Copy link
Collaborator

@AlexanderDokuchaev AlexanderDokuchaev commented Jan 19, 2025

Changes

Return detached tensor from get_const_data function

Reason for changes

Memory leak

@github-actions github-actions bot added NNCF PT Pull requests that updates NNCF PyTorch experimental labels Jan 19, 2025
@github-actions github-actions bot added NNCF PTQ Pull requests that updates NNCF PTQ and removed experimental labels Jan 23, 2025
@AlexanderDokuchaev AlexanderDokuchaev changed the title disable grad [PT] detach tensor in get_const_data Jan 28, 2025
@AlexanderDokuchaev
Copy link
Collaborator Author

Reproducer

import torch
results = []
for _  in range(100):
    a = torch.rand((1,3,1000, 1000),requires_grad=True)
    b = torch.rand((1,3,1000, 1000),requires_grad=True)
    r = torch.sum(a + b)
    results.append(r)
image
import torch
results = []
for _  in range(100):
    a = torch.rand((1,3,1000, 1000),requires_grad=True)
    b = torch.rand((1,3,1000, 1000),requires_grad=True)
    r = torch.sum(a.detach() + b.detach())
    results.append(r)
image

@AlexanderDokuchaev AlexanderDokuchaev marked this pull request as ready for review January 28, 2025 16:48
@AlexanderDokuchaev AlexanderDokuchaev requested a review from a team as a code owner January 28, 2025 16:48
Copy link
Contributor

@alexsu52 alexsu52 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have an idea how to check that you covered all places in NNCF code?

@AlexanderDokuchaev
Copy link
Collaborator Author

No, but problem actual only for case when original tensor is replaced to new in the model which was calculated by using original.

@alexsu52 alexsu52 merged commit b0897b3 into openvinotoolkit:develop Jan 30, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NNCF PT Pull requests that updates NNCF PyTorch NNCF PTQ Pull requests that updates NNCF PTQ
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants