Skip to content

init quant diffusion models #600

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 2 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
28 changes: 28 additions & 0 deletions auto_round_diff/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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 .mllm import AutoRoundMLLM
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__
107 changes: 107 additions & 0 deletions auto_round_diff/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# 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'] = '1'

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_mllm():
if "--eval" in sys.argv:
from auto_round.script.mllm import setup_lmeval_parser, eval
sys.argv.remove("--eval")
args = setup_lmeval_parser()
eval(args)
elif "--lmms" in sys.argv:
sys.argv.remove("--lmms")
run_lmms()
else:
from auto_round.script.mllm import setup_parser, tune
args = setup_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 run_lmms():
# from auto_round.script.lmms_eval import setup_lmms_args, eval
from auto_round.script.mllm import setup_lmms_parser, lmms_eval
args = setup_lmms_parser()
lmms_eval(args)

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

if __name__ == '__main__':
switch()

Loading