Repository navigation
Add FGDS (an alternative solution of GDS) copier - #111
Conversation
|
The old PR is #101 and closed for conflict resons. |
|
@kk47 At minimum, I would like the implementation to follow these requirements:
These are structural issues rather than individual bugs, so I would prefer to address the overall design first before reviewing smaller implementation details. |
|
@takeshi-yoshimura Thank you for the structural feedback. I have reworked the FGDS copier accordingly and would appreciate it if you could take another look. |
6bf6d04 to
8accd9a
Compare
|
@takeshi-yoshimura Sorry for taking so long to resolve the unittest failure. The issue was that torch.cuda.caching_allocator_alloc in framework.alloc_tensor_memory returns an offset within a GPU memory segment, whereas fgds_regmem requires a base pointer obtained directly from cudaMalloc. Setting the minimum allocation size to 2 MB resolved the page alignment problem. |
takeshi-yoshimura
left a comment
There was a problem hiding this comment.
@kk47
Thanks for reworking the implementation around the existing extension and library-loading design. I added one more request to make sure minimizing changes for current users who do not enable FGDS.
| // GPU is available, so we only attempt the load when gpu_found is set. | ||
| fgds_found = false; | ||
| #ifndef _MSC_VER | ||
| if (gpu_found) { |
There was a problem hiding this comment.
Please make loading libfgds.so strictly opt-in. Currently, this block runs whenever the shared load_library_functions() detects a GPU, even when use_fgds=False and another copier (gds, nogds, unified, or dstorage) is selected.
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/copier/fgds.py: Python FgdsFileCopier implementation
- Register 'fgds' copier in fastsafetensors/copier/__init__.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 <[email protected]>
1d19926
into
foundation-model-stack:main
|
@kk47 Merged. Thanks! |
The FGDS copier for fastsafetensors has been merged upstream (foundation-model-stack/fastsafetensors#111), so the manual patch is no longer needed. Update README.md and docs/fgds-fastsafetensor.md accordingly, and remove the obsolete patch file. Signed-off-by: Kai Kuang <[email protected]>
The FGDS copier for fastsafetensors has been merged upstream (foundation-model-stack/fastsafetensors#111), so the manual patch is no longer needed. Update README.md and docs/fgds-fastsafetensor.md accordingly, and remove the obsolete patch file. Signed-off-by: Kai Kuang <[email protected]>
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:
The FGDS copier follows the same pattern as the existing GDS copier:
Usage:
loader = SafeTensorsFileLoader(pg, device='cuda:0', use_fgds=True)
# or
with fastsafe_open(files, device='cuda:0', use_fgds=True) as f:
...