[Fix] Fix bugs on traverse_dict#141
Merged
LZHgrla merged 4 commits intoInternLM:mainfrom Oct 23, 2023
Merged
Conversation
HIT-cwh
reviewed
Sep 26, 2023
| for key, value in d.items(): | ||
| if isinstance(value, dict): | ||
| if 'type' in value and dataclasses.is_dataclass(value['type']): | ||
| traverse_dict(value) |
Collaborator
There was a problem hiding this comment.
后续遍历可能会增加时间复杂度,虽然traverse的耗时非常少
Contributor
Author
There was a problem hiding this comment.
原版代码只做了“一层”嵌套的处理,这个PR主要是为了涵盖class build和torch.float16嵌套“非常深”的情况,要递归到最深层依次做处理。实际耗时基本无感。
以下面为例
llm=dict(
pretrained_model_name_or_path='internlm/internlm-7b',
quantization_config=dict(
bnb_4bit_compute_dtype='torch.float16',
bnb_4bit_quant_type='nf4',
bnb_4bit_use_double_quant=True,
llm_int8_has_fp16_weight=False,
llm_int8_threshold=6.0,
load_in_4bit=True,
load_in_8bit=False,
type='transformers.BitsAndBytesConfig'),
torch_dtype='torch.float16',
trust_remote_code=True,
type='transformers.AutoModelForCausalLM.from_pretrained')在原版代码,torch_dtype='torch.float16',会被处理为torch.float16;但再深一层的bnb_4bit_compute_dtype='torch.float16',,这一行会缺失处理,而导致报错
HIT-cwh
approved these changes
Oct 23, 2023
llkn-2
pushed a commit
to llkn-2/xtuner
that referenced
this pull request
Jul 31, 2024
* fix traverse_dict bugs * fix arguments note * update requirements
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.
Support to reuse the auto-saved configs from mmengine