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

fix graph_processor buffer_alloc_id calculus #15426

Merged
merged 6 commits into from
Nov 30, 2024

Conversation

mbezuljTT
Copy link
Contributor

@mbezuljTT mbezuljTT commented Nov 25, 2024

Problem description

buffer_alloc_id was assigned per memory address, however this created wrong results when capturing composite op that might be allocating and deallocating entire tensors, so two buffers might have the same address.

new buffer alloc id is provided from buffer unique id

old graph capture
image

new graph capture
image

Copy link
Member

@ayerofieiev-tt ayerofieiev-tt left a comment

Choose a reason for hiding this comment

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

Please add a test

@mbezuljTT
Copy link
Contributor Author

turns out as much I wanted to hash there was no way to distinguish two buffers of the same spec allocated and deallocated. I had to add buffer id to the buffer object. @abhullar-tt please take a look

@ayerofieiev-tt added test, fixed other issue; there was one map id_to_counter that was used between buffers and tensors; this worked just because tensor ids started from 0, and buffer ids were pointers
image

@mbezuljTT mbezuljTT force-pushed the mbezulj/2411-fix_buffer_alloc_id branch from a01fecc to 3bceb6e Compare November 26, 2024 05:25
introduce buffer unique id, as an atomic static counter
split id_to_counter to buffer_id_to_counter and tensor_id_to_counter
@mbezuljTT mbezuljTT force-pushed the mbezulj/2411-fix_buffer_alloc_id branch from 3bceb6e to 8027a83 Compare November 27, 2024 10:05
@@ -300,6 +302,8 @@ class Buffer final {
std::shared_ptr<const BufferPageMapping> buffer_page_mapping_;

std::weak_ptr<Buffer> weak_self;
size_t unique_id_;
Copy link
Member

Choose a reason for hiding this comment

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

please init with 0

Copy link
Member

@ayerofieiev-tt ayerofieiev-tt left a comment

Choose a reason for hiding this comment

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

I really don't like the atomic static counter in the buffer, but I don't have a good explanation why. Just letting you know.

@dmakoviichuk-tt PTAL at this PR too.

@mbezuljTT
Copy link
Contributor Author

I really don't like the atomic static counter in the buffer, but I don't have a good explanation why. Just letting you know.

@dmakoviichuk-tt PTAL at this PR too.

FWIW atomics are already used for tensor, operation and device ids 🤷

@ayerofieiev-tt
Copy link
Member

ayerofieiev-tt commented Nov 29, 2024

Alright, let’s go. People had their time.
if anyone will have a suggestion, it can be done in the next PR.

Before merging please make sure to run CI and link post commit runs.

Thank you, Marko!

@mbezuljTT mbezuljTT merged commit 273a940 into main Nov 30, 2024
142 checks passed
@mbezuljTT mbezuljTT deleted the mbezulj/2411-fix_buffer_alloc_id branch November 30, 2024 08:46
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

Successfully merging this pull request may close these issues.

5 participants