[fix] Update layerwise.py: avoid forced type conversion #1282
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.
During layerwise model initialization, if both use_bf16 and use_fp16 are set to false, use_fp16 is forcibly converted to true. However, in some scenarios, the warning’s granularity does not propagate to the Python terminal, causing users to overlook this implicit behavior and potentially introducing unexpected bugs.
Therefore, I have committed a version of the code that explicitly notifies the user of incorrect input parameters, making it more aligned with everyday usage.
在layerwise模型相关初始化时,当use_bf16和 use_fp16都为false时,use_fp16会被强制转换成true;然而在一些场景,warning的告警粒度传递不到python terminal中,让人关注不到这一隐性的情况,从而可能产生预期之外的bug。
因此commit一版代码,强制告知user传入参数有误,更符合日常使用。