-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from ModelTC/temp_eval2
add down stream evaluation
- Loading branch information
Showing
12 changed files
with
195 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[submodule "lm-evaluation-harness"] | ||
path = lm-evaluation-harness | ||
url = https://github.com/ModelTC/llmc.git | ||
branch = lm-eval |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Submodule lm-evaluation-harness
added at
5ac2bb
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export CUDA_VISIBLE_DEVICES=4,5,6,7 | ||
llmc=./llmc | ||
lm_eval=./llmc/lm-evaluation-harness | ||
export PYTHONPATH=$llmc:$PYTHONPATH | ||
export PYTHONPATH=$llmc:$lm_eval:$PYTHONPATH | ||
# Replace the config file (i.e., RTN with algorithm-transformed model path or notate quant with original model path) | ||
# with the one you want to use. `--quarot` is depend on the transformation algorithm used before. | ||
accelerate launch --multi_gpu --num_processes 4 llmc/tools/llm_eval.py \ | ||
--config llmc/configs/quantization/RTN/rtn_quarot.yml \ | ||
--model hf \ | ||
--quarot \ | ||
--tasks lambada_openai,arc_easy \ | ||
--model_args parallelize=False \ | ||
--batch_size 64 \ | ||
--output_path ./save/lm_eval \ | ||
--log_samples |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import argparse | ||
import copy | ||
import functools | ||
import gc | ||
import os | ||
import sys | ||
|
||
import torch | ||
import yaml | ||
from loguru import logger | ||
from tqdm import tqdm | ||
from transformers import AutoConfig, AutoModelForCausalLM | ||
|
||
sys.path.append(os.path.join(os.path.dirname(__file__), '../lm-evaluation-harness')) | ||
sys.path.append(os.path.join(os.path.dirname(__file__), '../')) | ||
import lm_eval.__main__ as lm_eval | ||
import torch.nn as nn | ||
from easydict import EasyDict | ||
|
||
from llmc.compression.quantization import FakeQuantLinear, Quantizer | ||
from llmc.compression.quantization.base_blockwise_quantization import \ | ||
BaseBlockwiseQuantization | ||
from llmc.compression.quantization.module_utils import LlmcRMSNorm | ||
from llmc.data import BaseDataset, BaseTokenizer | ||
from llmc.eval import PerplexityEval | ||
from llmc.models import * | ||
from llmc.utils import check_config, mkdirs, seed_all | ||
from llmc.utils.registry_factory import ALGO_REGISTRY, MODEL_REGISTRY | ||
|
||
if __name__ == '__main__': | ||
logger.warning('This script only supports transformed/original model type!') | ||
parser = lm_eval.setup_parser() | ||
parser.add_argument('--config', type=str, required=True) | ||
parser.add_argument('--quarot', action='store_true') | ||
args = parser.parse_args() | ||
with open(args.config, 'r') as file: | ||
config = yaml.safe_load(file) | ||
config = EasyDict(config) | ||
args.config = config | ||
if 'pretrained' not in args.model_args: | ||
if 'paralleize=True' in args.model_args: | ||
logger.error("Please remove 'paralleize=True' from model_args!") | ||
sys.exit(1) | ||
args.model_args += ',pretrained=' + config.model.path | ||
lm_eval.cli_evaluate(args) |
This file contains 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