File size: 2,102 Bytes
7feac49 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# Copyright (c) Alibaba, Inc. and its affiliates.
from typing import Type
import gradio as gr
from swift.ui.base import BaseUI
class Quantization(BaseUI):
group = 'llm_train'
locale_dict = {
'quantization_tab': {
'label': {
'zh': '量化参数设置',
'en': 'Quantization settings'
},
},
'quant_method': {
'label': {
'zh': '量化方式',
'en': 'Quantization method'
},
'info': {
'zh': '如果制定了量化位数,本参数默认为bnb',
'en': 'Default is bnb if quantization_bit is specified'
}
},
'quant_bits': {
'label': {
'zh': '量化bit数',
'en': 'Quantization bit'
},
'info': {
'zh': '设置量化bit数, 0代表不进行量化',
'en': 'Set the quantization bit, 0 for no quantization'
}
},
'bnb_4bit_compute_dtype': {
'label': {
'zh': 'bnb_4bit_compute_dtype',
'en': 'bnb_4bit_compute_dtype'
},
},
'bnb_4bit_quant_type': {
'label': {
'zh': 'bnb_4bit_quant_type',
'en': 'bnb_4bit_quant_type'
},
},
'bnb_4bit_use_double_quant': {
'label': {
'zh': 'bnb_4bit_use_double_quant',
'en': 'bnb_4bit_use_double_quant'
},
},
}
@classmethod
def do_build_ui(cls, base_tab: Type['BaseUI']):
with gr.Accordion(elem_id='quantization_tab', open=False):
with gr.Row():
gr.Dropdown(elem_id='quant_bits', value=None)
gr.Dropdown(elem_id='quant_method', value=None)
gr.Dropdown(elem_id='bnb_4bit_compute_dtype', value=None)
gr.Dropdown(elem_id='bnb_4bit_quant_type', value=None)
gr.Checkbox(elem_id='bnb_4bit_use_double_quant', value=None)
|