Closed zza234s closed 7 months ago
Describe the bug The "count_bytes" function could not return the expected result when a message's content includes a tensor object. https://github.com/alibaba/FederatedScope/blob/6dfe8d4474451c07cd7d69690a2df33a1f455f19/federatedscope/core/message.py#L259-L269
To Reproduce
I think the problem may be in the "asizeof" function. https://github.com/alibaba/FederatedScope/blob/6dfe8d4474451c07cd7d69690a2df33a1f455f19/federatedscope/core/message.py#L265
This function appears to inaccurately calculate the memory usage for pytorch tensor objects. For instance, it may return the same byte count even for tensors with very different shapes.
👍Thanks for the catching! We will fix it ASAP.
You can either use
sys.getsizeof(t.storage())
or
t.element_size() * t.nelement()
to a tensor to get memory usage.
Describe the bug The "count_bytes" function could not return the expected result when a message's content includes a tensor object. https://github.com/alibaba/FederatedScope/blob/6dfe8d4474451c07cd7d69690a2df33a1f455f19/federatedscope/core/message.py#L259-L269
To Reproduce
I think the problem may be in the "asizeof" function. https://github.com/alibaba/FederatedScope/blob/6dfe8d4474451c07cd7d69690a2df33a1f455f19/federatedscope/core/message.py#L265
This function appears to inaccurately calculate the memory usage for pytorch tensor objects. For instance, it may return the same byte count even for tensors with very different shapes.