-
Notifications
You must be signed in to change notification settings - Fork 11
added loading util for specific layers #144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: shanjiaz <[email protected]>
📦 Build Artifacts Available |
Signed-off-by: shanjiaz <[email protected]>
Signed-off-by: shanjiaz <[email protected]>
Signed-off-by: shanjiaz <[email protected]>
Signed-off-by: shanjiaz <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Added a few suggestions
for name in layer_names: | ||
shard = weight_map.get(name) | ||
if shard is None: | ||
logger.warning(f"Tensor '{name}' not found in index weight_map.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better to make this an error.
available = set(f.keys()) | ||
for name in names: | ||
if name not in available: | ||
logger.warning( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
raise FileNotFoundError(f"Expected local file missing: {p}") | ||
return p | ||
# Treat as repo_id on the Hub | ||
logger.info("Loading from huggingface directory: {}", model_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This (or the other logger.info call) is going to print out each time this function is called. If we load multiple values (i.e. embed_tokens.weight
and lm_head.weight
) it would be nice to also include the file_name
in these log calls.
We were loading the full verifier model only to get the embeddings, specific layers. This util helps saving memory by loading only the shards we needed and returns a dict of layer name -> layers.
Tested locally: