-
Notifications
You must be signed in to change notification settings - Fork 171
[Bug fix] remove max_memory from from_config init in hf_ptq #373
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -206,9 +206,7 @@ def get_model( | |
if auto_model_module != AutoModelForCausalLM: | ||
model_kwargs2.pop("trust_remote_code", None) | ||
model_kwargs2["torch_dtype"] = torch_dtype | ||
# DeciLMForCausalLM does not support max_memory argument | ||
if "architectures" in hf_config and "DeciLMForCausalLM" in hf_config.architectures: | ||
model_kwargs2.pop("max_memory", None) | ||
model_kwargs2.pop("max_memory", None) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about we inspect model's signature and keep kwargs if they are supported to avoid such issues in the future? |
||
model = from_config(hf_config, **model_kwargs2) | ||
|
||
max_memory = get_max_memory() | ||
|
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
do you actually want to remove line 166-171 as well?
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.
yeah sure I also thought of it. But I do not know why we added the
use_seq_device_map
in the first place. So should I remove the entire--use_seq_device_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.
I recalled that
--use_seq_device_map
was added by @sugunav14 for nemotron models that do not distribute evenly on GPUs when initializing with auto device_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.
@cjluo-nv What should we do here? The current fix works. If you are okay with the current fix, can you please approve it?
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.
max_memory is set at line 170. If we don't use it here, we probably don't need line 170. @sugunav14 could you chime in?
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.
yeah, seems like with this change max_memory is never used.
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.
@cjluo-nv @sugunav14 removing
max_memory
as in this PR will not cause an OOM.max_memory
is removed when loading withAutoModelForCausalLM.from_config
underinit_empy_weights
context. Looks like the fix in this PR is sufficient. Can you please approve this?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.
@sugunav14 The model initialized here uses AutoModel.from_config(). AutoModel.from_config no longer accepts extra kwargs such as
max_memory
(I tested with Llama3 and Qwen3).