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

add some new features for layer-wise quant #1899

Closed
wants to merge 2 commits into from

Conversation

n1ck-guo
Copy link
Contributor

@n1ck-guo n1ck-guo commented Jul 3, 2024

Type of Change

feature

Description

add some new features for layer-wise quant, include get_weight, get_bias, update, and save/load. Make it more easy to use, like a normal model.

Expected Behavior & Potential Risk

None

How has this PR been tested?

how to reproduce the test (including hardware information)

Dependency Change?

None

Copy link

github-actions bot commented Jul 3, 2024

⛈️ Required checks status: Has failure 🔴

Warning
If you do not have the access to re-run the Probot, please contact XuehaoSun for help. If you push a new commit, all of the workflow will be re-triggered.

Groups summary

🟢 Code Scan Tests workflow
Check ID Status Error details
Code-Scan success
Code-Scan (Bandit Code Scan Bandit) success
Code-Scan (DocStyle Code Scan DocStyle) success
Code-Scan (Pylint Code Scan Pylint) success

These checks are required after the changes to neural_compressor/torch/algorithms/layer_wise/utils.py.

🔴 Model Tests 3x workflow
Check ID Status Error details
Model-Test-3x failure
Model-Test-3x (Generate Report GenerateReport) no_status
Model-Test-3x (Run PyTorch Model opt_125m_woq_gptq_int4) success
Model-Test-3x (Run PyTorch Model opt_125m_woq_gptq_int4_dq_bnb) failure
Model-Test-3x (Run PyTorch Model opt_125m_woq_gptq_int4_dq_ggml) failure

These checks are required after the changes to neural_compressor/torch/algorithms/layer_wise/utils.py.

🔴 Unit Tests 3x-PyTorch workflow
Check ID Status Error details
UT-3x-Torch failure
UT-3x-Torch (Coverage Compare CollectDatafiles) failure download
UT-3x-Torch (Unit Test 3x Torch Unit Test 3x Torch) success
UT-3x-Torch (Unit Test 3x Torch baseline Unit Test 3x Torch baseline) success

These checks are required after the changes to neural_compressor/torch/algorithms/layer_wise/utils.py.


Thank you for your contribution! 💜

Note
This comment is automatically generated and will be updates every 180 seconds within the next 6 hours. If you have any other questions, contact chensuyue or XuehaoSun for help.

Copy link
Contributor

@Kaihui-intel Kaihui-intel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add some UT verification functionality?

Comment on lines +35 to +36
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(filename)s L%(lineno)d: %(message)s")
logger = logging.getLogger("layer_wise_tools")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(filename)s L%(lineno)d: %(message)s")
logger = logging.getLogger("layer_wise_tools")
from neural_compressor.torch.utils import logger

@@ -18,19 +18,24 @@

import gc
import json
import logging
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import logging

logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(filename)s L%(lineno)d: %(message)s")
logger = logging.getLogger("layer_wise_tools")

LWQ_WORKSPACE = os.path.join("layer_wise_tmp")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LWQ_WORKSPACE = os.path.join("layer_wise_tmp")
from neural_compressor.common import options
LWQ_WORKSPACE = os.path.join(options.workspace, "lwq_tmpdir")

@@ -121,7 +126,7 @@ def dowload_hf_model(repo_id, cache_dir=None, repo_type=None, revision=None):
return file_path


def load_empty_model(pretrained_model_name_or_path, cls=AutoModelForCausalLM, **kwargs):
def load_empty_model(pretrained_model_name_or_path, cls=AutoModelForCausalLM, save_path=None, **kwargs):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

save_path defaults to LWQ_WORKSPACE

Comment on lines +148 to +149
if save_path is None:
save_path = LWQ_WORKSPACE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove if use default value

Comment on lines +420 to +423
pretrained_model_name_or_path, cls=AutoModelForCausalLM, device="cpu", clean_weight=True, saved_path=None, **kwargs
):
if saved_path is None:
saved_path = LWQ_WORKSPACE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pretrained_model_name_or_path, cls=AutoModelForCausalLM, device="cpu", clean_weight=True, saved_path=None, **kwargs
):
if saved_path is None:
saved_path = LWQ_WORKSPACE
pretrained_model_name_or_path, cls=AutoModelForCausalLM, device="cpu", clean_weight=True, saved_path=LWQ_WORKSPACE, **kwargs
):

m.forward = partial(_forward, m, n)

try:
model.forward(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it applicable to all or most models?

@Kaihui-intel Kaihui-intel marked this pull request as draft July 5, 2024 07:59
@Kaihui-intel
Copy link
Contributor

marked draft and will migrate to #1883

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.

2 participants