Skip to content

Quant diff #606

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ dist/
.clangd
CMakeUserPresets.json
tmp_autoround/
outputs/
models/ldm/stable-diffusion-v1/*.ckpt
27 changes: 27 additions & 0 deletions auto_round_diff/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright (c) 2023 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from .autoround import AutoRound, AutoRoundAdam, AutoRoundOPT
from auto_round.utils import LazyImport

def __getattr__(name):
if name == 'AutoHfQuantizer':
from auto_round.inference.auto_quantizer import AutoHfQuantizer
return AutoHfQuantizer
if name == 'AutoRoundConfig':
from auto_round.inference.auto_quantizer import AutoRoundConfig
return AutoRoundConfig

raise AttributeError(f"auto-round has no attribute '{name}'")

from .version import __version__
84 changes: 84 additions & 0 deletions auto_round_diff/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Copyright (c) 2024 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import sys
sys.path.append('.')
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '2'

# def run_eval():
# from auto_round.script.llm import setup_eval_parser
# args = setup_eval_parser()
# if args.eval_task_by_task:
# from auto_round.script.llm import eval_task_by_task
# eval_task_by_task(
# model=args.model,
# device=args.device,
# tasks=args.tasks,
# batch_size=args.eval_bs,
# trust_remote_code=not args.disable_trust_remote_code,
# eval_model_dtype=args.eval_model_dtype
# )
# else:
# from auto_round.script.llm import eval
# eval(args)


# def run():
# if "--eval" in sys.argv:
# sys.argv.remove("--eval")
# run_eval()
# else:
# from auto_round.script.llm import setup_parser, tune
# args = setup_parser()
# tune(args)

# def run_best():
# from auto_round.script.llm import setup_best_parser, tune
# args = setup_best_parser()
# tune(args)

# def run_light():
# from auto_round.script.llm import setup_light_parser, tune
# args = setup_light_parser()
# tune(args)

# def run_fast():
# from auto_round.script.llm import setup_fast_parser, tune
# args = setup_fast_parser()
# tune(args)

def run_diffusion():
if "--eval" in sys.argv:
from auto_round_diff.script.diffusion import setup_lmeval_parser, eval
sys.argv.remove("--eval")
args = setup_lmeval_parser()
eval(args)
elif "--sample" in sys.argv:
pass
else:
from auto_round_diff.script.diffusion import setup_parser, tune
args = setup_parser()
tune(args)

def switch():
if "--dm" in sys.argv:
sys.argv.remove("--dm")
run_diffusion()
else:
pass
# run()

if __name__ == '__main__':
switch()

Loading