Skip to content
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

Refactor func load_model to class ModelLoader #1909

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

MengqingCao
Copy link

@MengqingCao MengqingCao commented Sep 12, 2024

Description

part of #1758

This PR refactor the func load_model in src/axolotl/utils/models.py into a class ModelLoader. Different member functions of class ModelLoader are separated according to their features, and all the member vars of ModelLoader are shared in these funcs. Moreover, this refactoring make the pipeline of model loading more clearly.

TODO:

  • add UT for ModelLoader

Mainly changes are listed here:

  • organize comman var into member var of class ModelLoader
  • split operations in load_model into separate member funcs
  • refactor cfg.load_in_Xbit to kwarg

The UML of ModelLoader:

9ef679eaeeff1fe01dbff0c4b67f81c

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 func load_model (#1758 (review)). Refactoring load_model will optimize the code structure and facilitate stable evolution when introducing more features in the future.

How has this been tested?

  1. part of UTs for ModelLoader is added and tests passed
  2. I tested to funtune, inference (on both terminal and gradio webui) on open_llama_3b_v2 model, and here comes the screenshot of inferencing:

GPU-INFERENCE

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.

  * organize comman var into member var of class ModelLoader
  * split operations in load_model into separate member funcs
  * refactor cfg.load_in_Xbit to kwarg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant