Skip to content

Conversation

@ABNER-1
Copy link
Contributor

@ABNER-1 ABNER-1 commented Oct 20, 2025

The 3rd in #29

We recommend abstracting the Copier to allow easier adaptation for more scenarios. For instance, we have implemented a custom Copier for network storage scenarios, which can be highly optimized for specific use cases.

@ABNER-1 ABNER-1 changed the title add custom copier interface Introduce a Copier interface to support custom scenarios Oct 20, 2025
@ABNER-1 ABNER-1 force-pushed the custom_reader branch 3 times, most recently from 10b1d74 to 40a5d58 Compare October 20, 2025 11:14
@ABNER-1 ABNER-1 mentioned this pull request Oct 20, 2025
Copy link
Collaborator

@takeshi-yoshimura takeshi-yoshimura left a comment

Choose a reason for hiding this comment

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

Thank you for contributing the nice code for CopierInterface!

Maybe this is a discussion point, but I don't think new_gds_file_copier and splitting SafeTensorsFileLoader are necessary at this moment. I understand they makes the code cleaner, but I am a bit anxious that they will gradually cause the difficulty to follow where the object came from with future changes. so, could you please keep the copier construction and the class definition like before if it is possible.

pass


class DummyDeviceBuffer(fstcpp.gds_device_buffer):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks new codes do not use this class. Is this required for your future changes? what kind of code do you expect to use it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will implement an example copier to handle GPU memory allocation within the reader.
This is managed in C++ code, which releases python GIL, thus improving overall performance.

The DummyDeviceBuffer can help me seamlessly integrates into the framework's workflow.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see. Can you move this change to the future change?


class SafeTensorsFileLoader:
r"""Load .safetensors files lazily.
class BaseSafeTensorsFileLoader:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to split the class into two? Looks BaseSafeTensorsFileLoader is not reusable anywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This approach provides a clean way to implement a new copier and loader without modifying any code in the BaseSafeTensorsFileLoader, while also ensuring the existing interfaces in fastsafetensors remain unchanged.

@takeshi-yoshimura
Copy link
Collaborator

@ABNER-1
I made a change request last week, but do you have enough bandwidth to deal with this? In that case, I will take care of them as separate changes.

@ABNER-1
Copy link
Contributor Author

ABNER-1 commented Nov 6, 2025

@ABNER-1 I made a change request last week, but do you have enough bandwidth to deal with this? In that case, I will take care of them as separate changes.

Apologies for the delay; I was tied up with other tasks. I'm back on this now and will address all feedback this week.

Signed-off-by: yuanyuxing.yyx <[email protected]>
@ABNER-1
Copy link
Contributor Author

ABNER-1 commented Nov 7, 2025

Hi, @takeshi-yoshimura .

A well-designed copier interface allows us to leverage the two-phase loading and broadcasting mechanism of fastsafetensors while minimizing changes to existing abstractions and code.

In practice, different companies often utilize internal network storage protocols with highly customized loading SDKs (e.g., leveraging RDMA or GDR). With this interface, they would only need to implement a custom copier to integrate seamlessly.

This significantly expands the applicability of fastsafetensors. I hope this proposal can gain your approval.

@takeshi-yoshimura
Copy link
Collaborator

Thanks, let me see the change closely tomorrow.

@takeshi-yoshimura takeshi-yoshimura merged commit e99b606 into foundation-model-stack:main Nov 10, 2025
13 checks passed
@takeshi-yoshimura
Copy link
Collaborator

Merged. Thanks.
I will keep working on another PR.

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.

2 participants