Skip to content

Add FGDS (an alternative solution of GDS) copier - #101

Open
kk47 wants to merge 1 commit into
foundation-model-stack:mainfrom
kk47:main
Open

Add FGDS (an alternative solution of GDS) copier#101
kk47 wants to merge 1 commit into
foundation-model-stack:mainfrom
kk47:main

Conversation

@kk47

@kk47 kk47 commented Aug 26, 2026

Copy link
Copy Markdown

Add a new 'fgds' copier for direct GPU storage access, Providing an alternative solution with higher performance and easy-to-use alternative solution for existing GDS implementations.

FGDS micro benchmark shows that FGDS outperforms GDS by 11%~109%, and POSIX by 40%~143%. When loading the Qwen-32B model in the H100+NVME SSD environment, fgds copier shows 2.6x improvement than nogds copier.

Key changes:

  • Add fastsafetensors/cpp/fgds_ext.cpp: C++ pybind11 extension wrapping libfgds
  • Add fastsafetensors/cpp/fgds_ext.pyi: Type stubs for the extension
  • Add fastsafetensors/copier/fgds.py: Python FgdsFileCopier implementation
  • Register 'fgds' copier in fastsafetensors/copier/init.py
  • Add fgds_ext build target in setup.py
  • Add use_fgds parameter to SafeTensorsFileLoader and fastsafe_open

The FGDS copier follows the same pattern as the existing GDS copier:

  • Supports O_DIRECT file access
  • Uses async multi-threaded read submission
  • Registers GPU memory for direct I/O
  • Falls back to nogds copier when libfgds is unavailable
  • Properly deregisters memory and cleans up resources

Usage:
loader = SafeTensorsFileLoader(pg, device='cuda:0', use_fgds=True)
# or
with fastsafe_open(files, device='cuda:0', use_fgds=True) as f:
...

@takeshi-yoshimura

Copy link
Copy Markdown
Collaborator

@kk47 This is great! First, I want you to resolve the lint and test issues. The test seems to fail due to unconditional includes of Linux header files in windows backend.

Do you want to enable this for vllm? In that case, current entry point is now ParallelLoader. So please update it if you want to influence much broad users.

@kk47

kk47 commented Aug 28, 2026

Copy link
Copy Markdown
Author

@kk47 This is great! First, I want you to resolve the lint and test issues. The test seems to fail due to unconditional includes of Linux header files in windows backend.

Do you want to enable this for vllm? In that case, current entry point is now ParallelLoader. So please update it if you want to influence much broad users.

Hi @takeshi-yoshimura
Thank you for the prompt and helpful feedback!
I’ll get started on resolving the lint and test issues right away. Regarding your question about enabling this for vLLM: yes, I’d love to extend the support to vLLM as well. I’ll update the ParallelLoader entry point as you suggested to ensure it benefits a broader set of users. I’ll push the updates once the fixes and the vLLM integration are ready.

Thanks again for the guidance!

@kk47
kk47 force-pushed the main branch 5 times, most recently from 25033f8 to 8769bb3 Compare September 1, 2026 02:02
@takeshi-yoshimura

Copy link
Copy Markdown
Collaborator

@kk47
please take a look at https://github.com/foundation-model-stack/fastsafetensors/blob/main/docs/development.md#pre-commit-hooks for lint.

@takeshi-yoshimura

Copy link
Copy Markdown
Collaborator

or just run make lint before pushing your commits.

@kk47

kk47 commented Sep 2, 2026

Copy link
Copy Markdown
Author

or just run make lint before pushing your commits.

@kk47 kk47 closed this Sep 2, 2026
@kk47 kk47 reopened this Sep 2, 2026
@kk47

kk47 commented Sep 2, 2026

Copy link
Copy Markdown
Author

or just run make lint before pushing your commits.

OK, I‘ll run this and make it passed befor push again.

Add a new 'fgds' copier for direct GPU storage access,
The FGDS provides a high-performance, easy-to-use alternative to existing
GDS implementations.

FGDS micro benchmark shows that FGDS outperforms GDS by 11%~109%, and POSIX by
40%~143%. When loading the Qwen-32B model in the H100+NVME SSD environment,
fgds copier shows 2.6x improvement than nogds copier.

Key changes:
- Add fastsafetensors/cpp/fgds_ext.cpp: C++ pybind11 extension wrapping libfgds
- Add fastsafetensors/cpp/fgds_ext.pyi: Type stubs for the extension
- Add fastsafetensors/copier/fgds.py: Python FgdsFileCopier implementation
- Register 'fgds' copier in fastsafetensors/copier/__init__.py
- Add fgds_ext build target in setup.py
- Add use_fgds parameter to SafeTensorsFileLoader and fastsafe_open

The FGDS copier follows the same pattern as the existing GDS copier:
- Supports O_DIRECT file access
- Uses async multi-threaded read submission
- Registers GPU memory for direct I/O
- Falls back to nogds copier when libfgds is unavailable
- Properly deregisters memory and cleans up resources

Usage:
    loader = SafeTensorsFileLoader(pg, device='cuda:0', use_fgds=True)
    # or
    with fastsafe_open(files, device='cuda:0', use_fgds=True) as f:
        ...

Signed-off-by: Kai Kuang <kuangkai@kylinos.cn>
@takeshi-yoshimura

Copy link
Copy Markdown
Collaborator

@kk47
I am working on refactoring towards the release 0.4 now. I will take a closer look at your code soon later, but not merge this to 0.4. thanks.

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