-
Notifications
You must be signed in to change notification settings - Fork 367
modify unflatten for vllm #3297
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
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/3297
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit cdc5ca2 with merge base 6c78c4d ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
1788f28 to
0e290bb
Compare
0e290bb to
cdc5ca2
Compare
| def unflatten_tensor_state_dict( | ||
| tensors_data_dict: Dict[str, Any], | ||
| metadata: Dict[str, Any], | ||
| is_last_file: bool = False, |
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 seems hacky, why not just return the tensor names that's incomplete back to user?
| raise ValueError(f"Unsupported tensor type: {tensor_type}") | ||
|
|
||
| for tensor_name in to_be_deleted: | ||
| del tensors_data_dict[tensor_name] |
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's not a good practice to modify input, is it necessary?
jerryzh168
left a comment
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.
I think current impl is a bit hacky, what we can do is:
unflatten_tensor_state_dict with incomplete state_dict:
return a tuple of (unflattened_state_dict, unused part of incomplete_state_dict)
next call: combine the new state_dict input, with the previous unconsumed part
Summary
We keep track of what has been processed by deleting processed keys from the original state dict. This is for the case when not all tensor attributes are available to us when loading, so we reconstruct the tensor subclasses with missing attributes in a later call.
We expect the state dict to be empty after loading is complete
Test
python test/prototype/safetensors/test_safetensors_support.py