feat: add UnifiedLoader with config-driven loader dispatch#70
Open
ABNER-1 wants to merge 1 commit intofoundation-model-stack:mainfrom
Open
feat: add UnifiedLoader with config-driven loader dispatch#70ABNER-1 wants to merge 1 commit intofoundation-model-stack:mainfrom
ABNER-1 wants to merge 1 commit intofoundation-model-stack:mainfrom
Conversation
88f2d15 to
0a75403
Compare
Signed-off-by: yuanyuxing.yyx <yuanyuxing.yyx@alibaba-inc.com>
takeshi-yoshimura
requested changes
May 3, 2026
Collaborator
takeshi-yoshimura
left a comment
There was a problem hiding this comment.
please resolve my comments. thanks!
| ] | ||
| dependencies = [ | ||
| "typer>=0.9.0", | ||
| "pyyaml>=6.0", |
Collaborator
There was a problem hiding this comment.
I want to avoid new dependencies. Can we only use JSON?
| return cls | ||
|
|
||
|
|
||
| class UnifiedLoader: |
Collaborator
There was a problem hiding this comment.
I am not sure if UnifiedLoader is correct naming from user's perspective. AutoLoader?
|
|
||
| The base loader extension defaults to `copier_type: "gds"` (GPU Direct Storage). | ||
|
|
||
| ## Default Call Chain |
Collaborator
There was a problem hiding this comment.
This section is too detailed for users. Maybe you can just delete this section.
| loader.close() | ||
| ``` | ||
|
|
||
| No config file. Uses `loader="base"`, `nogds`, serial mode. |
| print("=== Way 1: Default config ===") | ||
| loader = UnifiedLoader(pg, args.files, device=args.device) | ||
| for key, tensor in loader.iterate_weights(): | ||
| print(f" {key}: shape={tensor.shape}") |
Collaborator
There was a problem hiding this comment.
Please use logger instead of print in this file.
| # --- Way 2: Config file in working directory --- | ||
| # Place a fastsafetensors.yaml in the working directory: | ||
| # | ||
| # loader: "threefs" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implement #65
Add a config-driven
UnifiedLoaderthat automatically dispatches to the appropriate loader class (SafeTensorsFileLoaderorThreeFSLoader) based on a YAML/JSON configuration file.Configuration
docs/configuration.md(new): Comprehensive configuration guide with 5 usage examplesREADME.md: Add Configuration section linking to docsUsage
Configuration via
fastsafetensors.yamlorFASTSAFETENSORS_CONFIGenv var.Default Config (GDS)
When no config file is present,
UnifiedLoaderuses the following defaults:The default call chain:
3FS Config Example
To use the 3FS high-performance I/O loader, create a
fastsafetensors.yaml:The 3FS call chain: