Refactor func load_model to class ModelLoader #1909
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.
Description
part of #1758
This PR refactor the func
load_model
insrc/axolotl/utils/models.py
into a classModelLoader
. Different member functions of classModelLoader
are separated according to their features, and all the member vars ofModelLoader
are shared in these funcs. Moreover, this refactoring make the pipeline of model loading more clearly.TODO:
Mainly changes are listed here:
ModelLoader
load_model
into separate member funcscfg.load_in_Xbit
to kwargThe UML of
ModelLoader
:Motivation and Context
Why is this change required?
As the models loaded in Axolotl support more and more features, the func
load_model
is huge now. And this results in confusion about variable changes when abstracting part of funcload_model
(#1758 (review)). Refactoringload_model
will optimize the code structure and facilitate stable evolution when introducing more features in the future.How has this been tested?
open_llama_3b_v2
model, and here comes the screenshot of inferencing:However, I don't have access to Ampere or newer GPU, thus I cannot pass the UT on my local machine. It would be nice if all UTs could be tested on CI.